djeuscan: use crontabs and depends on djcelery migrations

Signed-off-by: Corentin Chary <corentin.chary@gmail.com>
This commit is contained in:
Corentin Chary 2012-07-26 21:18:43 +02:00
parent 89408dde2b
commit 8d65eaea1f

View File

@ -4,34 +4,38 @@ from south.v2 import DataMigration
class Migration(DataMigration): class Migration(DataMigration):
depends_on = (
("djcelery", "0001_initial"),
)
def forwards(self, orm): def forwards(self, orm):
every_minute = orm["djcelery.IntervalSchedule"].objects.create( every_day = orm["djcelery.CrontabSchedule"].objects.create(
every=1, period="minutes" minute = "00",
hour = "01",
day_of_week = "*",
day_of_month = "*",
month_of_year = "*"
) )
every_day = orm["djcelery.IntervalSchedule"].objects.create( every_week = orm["djcelery.CrontabSchedule"].objects.create(
every=1, period="days" minute = "00",
) hour = "03",
every_week = orm["djcelery.IntervalSchedule"].objects.create( day_of_week = "1",
every=7, period="days" day_of_month = "*",
) month_of_year = "*"
orm["djcelery.PeriodicTask"].objects.create(
name="Refresh package queries",
task="djeuscan.tasks.consume_refresh_package_request",
interval=every_minute
) )
orm["djcelery.PeriodicTask"].objects.create( orm["djcelery.PeriodicTask"].objects.create(
name="Daily portage update", name="Daily portage update",
task="djeuscan.tasks.update_portage", task="djeuscan.tasks.update_portage",
interval=every_day crontab=every_day
) )
orm["djcelery.PeriodicTask"].objects.create( orm["djcelery.PeriodicTask"].objects.create(
name="Weekly upstream update", name="Weekly upstream update",
task="djeuscan.tasks.update_upstream", task="djeuscan.tasks.update_upstream",
interval=every_week crontab=every_week
) )
def backwards(self, orm): def backwards(self, orm):
orm["djcelery.IntervalSchedule"].objects.all().delete() orm["djcelery.CrontabSchedule"].objects.all().delete()
orm["djcelery.PeriodicTask"].objects.all().delete() orm["djcelery.PeriodicTask"].objects.all().delete()