Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store PeriodicTask's name #253

Closed
lvelvee opened this issue Nov 9, 2021 · 4 comments
Closed

Store PeriodicTask's name #253

lvelvee opened this issue Nov 9, 2021 · 4 comments

Comments

@lvelvee
Copy link
Contributor

lvelvee commented Nov 9, 2021

Would there be a way to store the Periodic tasks name with the result ? @stuartaccent 's method only store the task name like demoapp.tasks.add, cannot store table 'django_celery_beat_periodictask''s name field.

Originally posted by @guohongze in #7 (comment)

@lvelvee
Copy link
Contributor Author

lvelvee commented Nov 16, 2021

I'm glad to make some contributions, but the two repositories ( django-celery-results and django-celery-beat ) have to make some changes simultaneously, is this possible to be merged?

@auvipy
Copy link
Member

auvipy commented Nov 16, 2021

what changes are you willing to make? start with one repo first

@lvelvee
Copy link
Contributor Author

lvelvee commented Nov 16, 2021

This is part of the patch of my previous project:

--- a/vendors/django-celery-beat/django_celery_beat/schedulers.py	(revision 7c7af2034bb51d1143544a5f47604cb5c74b2633)
+++ b/vendors/django-celery-beat/django_celery_beat/schedulers.py	(revision 61ac7c03c7ecc6e7e02cb84c1b423f5be1cb84be)
@@ -85,6 +85,7 @@
             self.options['expires'] = getattr(model, 'expires_')
 
         self.options['headers'] = loads(model.headers or '{}')
+        self.options['periodic_task_name'] = model.name
 
         self.total_run_count = model.total_run_count
         self.model = model


--- a/vendors/django-celery-results/django_celery_results/backends/database.py	(revision 7c7af2034bb51d1143544a5f47604cb5c74b2633)
+++ b/vendors/django-celery-results/django_celery_results/backends/database.py	(revision 61ac7c03c7ecc6e7e02cb84c1b423f5be1cb84be)
@@ -39,6 +39,7 @@
         )
 
         task_name = getattr(request, 'task', None)
+        periodic_task_name = getattr(request, 'properties', None)['periodic_task_name']
         worker = getattr(request, 'hostname', None)
 
         # Get input arguments
@@ -72,6 +73,7 @@
             traceback=traceback,
             meta=meta,
             task_name=task_name,
+            periodic_task_name=periodic_task_name,
             task_args=task_args,
             task_kwargs=task_kwargs,
             worker=worker,


--- a/vendors/django-celery-results/django_celery_results/models.py	(revision 7c7af2034bb51d1143544a5f47604cb5c74b2633)
+++ b/vendors/django-celery-results/django_celery_results/models.py	(revision 61ac7c03c7ecc6e7e02cb84c1b423f5be1cb84be)
@@ -28,6 +28,10 @@
         unique=True,
         verbose_name=_('Task ID'),
         help_text=_('Celery ID for the Task that was run'))
+    periodic_task_name = models.CharField(
+        null=True, max_length=255,
+        verbose_name=_('Periodic Task Name'),
+        help_text=_('Name of the Periodic Task which was run'))
     task_name = models.CharField(
         null=True, max_length=255,
         verbose_name=_('Task Name'),

@auvipy
Copy link
Member

auvipy commented Nov 17, 2021

you can come with a patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants