-
Notifications
You must be signed in to change notification settings - Fork 430
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 name col to CrontabSchedule model #478
base: main
Are you sure you want to change the base?
Changes from 7 commits
9be0fd7
5eeb123
27927ad
58f1743
d96af9c
35ac4dc
b3ecccc
21de9a1
9bb7fa4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2 on 2021-12-17 07:58 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('django_celery_beat', '0015_edit_solarschedule_events_choices'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='crontabschedule', | ||
name='name', | ||
field=models.CharField(blank=True, help_text='Short Description For This Cron Schedule', max_length=200, null=True, verbose_name='Name'), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,6 +299,13 @@ class CrontabSchedule(models.Model): | |
'Timezone to Run the Cron Schedule on. Default is UTC.'), | ||
) | ||
|
||
name = models.CharField( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would also like to have unit tests for new proposed changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't run any test from test_schedulers.py with the current setup. |
||
max_length=200, unique=False, | ||
null=True, blank=True, | ||
verbose_name=_('Name'), | ||
help_text=_('Short Description For This Cron Schedule'), | ||
) | ||
|
||
class Meta: | ||
"""Table information.""" | ||
|
||
|
@@ -308,10 +315,12 @@ class Meta: | |
'day_of_week', 'hour', 'minute', 'timezone'] | ||
|
||
def __str__(self): | ||
return '{0} {1} {2} {3} {4} (m/h/dM/MY/d) {5}'.format( | ||
|
||
return '{0} {1} {2} {3} {4} (m/h/dM/MY/d) {5} {6}'.format( | ||
cronexp(self.minute), cronexp(self.hour), | ||
cronexp(self.day_of_month), cronexp(self.month_of_year), | ||
cronexp(self.day_of_week), str(self.timezone) | ||
cronexp(self.day_of_week), str(self.timezone), | ||
'[{}]'.format(self.name) if self.name else '', | ||
) | ||
|
||
@property | ||
|
@@ -593,9 +602,9 @@ def expires_(self): | |
def __str__(self): | ||
fmt = '{0.name}: {{no schedule}}' | ||
if self.interval: | ||
fmt = '{0.name}: {0.interval}' | ||
fmt = '{0.name}' | ||
if self.crontab: | ||
fmt = '{0.name}: {0.crontab}' | ||
fmt = '{0.name}' | ||
if self.solar: | ||
fmt = '{0.name}: {0.solar}' | ||
if self.clocked: | ||
|
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.
why str is removed?
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.
When using str there is no possible way to sort\group tasks by name.
Name is an essential feature that can be used to make sort easy and cron tasks more meaningful.
In this example, I can add prefixes in the name, and be able to group all tasks by any logical human-understandable meaning.
In addition, I think there is no need to add extra fields in the name when we have separate Crontab, Interval columns in the table already.