from django.core.management.base import BaseCommand
-from karmaworld.apps.notes.models import *
-from karmaworld.apps.courses.models import *
+from karmaworld.apps.courses.tasks import fix_note_counts
class Command(BaseCommand):
help = """Set the field file_count on every Course and School
to the correct value."""
def handle(self, *args, **kwargs):
- for c in Course.objects.all():
- c.update_note_count()
- print "Updated course {c}".format(c=c)
-
- for s in School.objects.all():
- s.update_note_count()
- print "Updated school {s}".format(s=s)
-
-
+ fix_note_counts()
--- /dev/null
+from karmaworld.apps.courses.models import Course
+from karmaworld.apps.courses.models import School
+
+from celery import task
+from celery.utils.log import get_task_logger
+
+logger = get_task_logger(__name__)
+
+@task(name="fix_note_counts")
+def fix_note_counts():
+ """
+ Set the field file_count on every Course and School to the correct value.
+ """
+
+ for c in Course.objects.all():
+ c.update_note_count()
+ print "Updated course {c}".format(c=c)
+
+ for s in School.objects.all():
+ s.update_note_count()
+ print "Updated school {s}".format(s=s)
'task': 'get_extract_keywords_results',
'schedule': timedelta(minutes=20),
},
+ 'update-scoreboard': {
+ 'task': 'fix_note_counts',
+ 'schedule': timedelta(days=1),
+ },
}
CELERY_TIMEZONE = 'UTC'