-
Notifications
You must be signed in to change notification settings - Fork 431
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
Adding human readable descriptions of crontab schedules #622
Conversation
2d096c6
to
8fef408
Compare
def changeform_view(self, request, object_id=None, form_url='', | ||
extra_context=None): | ||
extra_context = extra_context or {} | ||
crontabs = CrontabSchedule.objects.all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of calling all, can we reduce the number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I'm not sure how we'd decide which to include. My goal here is to provide natural language translations for all available crontabs.
The best argument for reducing the number is possible slow response times when loading the page. But, based on other sites I've used that load a lot of data into javascript objects onto the DOM, my hunch is that there would have to be hundreds (if not thousands) of CrontabSchedule objects before it would impact performance of this page. Additionally, since this is an admin-only view, any hit to responsiveness would never be seen by end users.
Do you have thoughts on how we might choose which ones to reduce it to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we show 20/25 per page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me how paginating this would work.
My goal with this change is to update the human readable description anytime the user changes the select list of defined crontabs. So, if I change from 5 * * * *
to 0 10 * * 1
, I want the description to change from "At 5 minutes past the hour" to "At 10:00 AM, only on Monday" to verify that the change is what I expect.
If the code only loads 20 per page, what happens if I choose a crontab that wasn't part of the 20 that were loaded?
This could be implemented as ajax/XHR so that the description is readable only on demand. Since django-celery-beat doesn't currently have any custom endpoints defined, this seems like a bigger change. Alternately, there could be a setting to disable this if a site has so many CrontabSchedules defined that loading this admin page is onerous.
Can you tell me more about your objection to having all defined on this page?
`${originalCrontabHelp}<br/>Translation: ${additional}`); | ||
}; | ||
|
||
django.jQuery(".field-crontab_translation").hide() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this django.jQuery being used from django admin itself? is it possible to switch to plain vanilla JS here? ES 6 without any dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From django documentation:
To avoid conflicts with user-supplied scripts or libraries, Django’s jQuery (version 3.6.0) is namespaced as django.jQuery.
Since this namespaced jQuery comes with Django admin, this seems like the best choice for using jQuery. It's probably possible to use ES 6 w/o dependencies but jQuery is not an extra dependency, so I think using this is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok make sense
Updated all .po files with new help string. Added translations for es and de
for more information, see https://pre-commit.ci
def changeform_view(self, request, object_id=None, form_url='', | ||
extra_context=None): | ||
extra_context = extra_context or {} | ||
crontabs = CrontabSchedule.objects.all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we show 20/25 per page?
I am not sure why CI is failing. can you check please? |
django_celery_beat/models.py
Outdated
@@ -616,7 +626,7 @@ def schedule(self): | |||
if self.interval: | |||
return self.interval.schedule | |||
if self.crontab: | |||
return self.crontab.schedule | |||
return self.crontab |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some unit tests are failed because of this change.
Can you elaborate more on why we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently closed PR #621 because I realized the changes are already covered in yours.
Hope this can give you an idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can merge part of your PR first @khanh96le
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure @auvipy. I saw that you already reopened it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the change you made in #621, @khanh96le! That's an improved list view!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure @auvipy. I saw that you already reopened it
can you give this PR another round of review?
builds are now passing after merging your PR @khanh96le |
The human readable text of all crontabs is loaded into the context of the PeriodicTask detail view. This could be a problem for sites that have a very large number of crontab schedules. --- we need to find a solution for this |
Partially addresses #612
What I did
What is missing
Possible problems