diff --git a/TODO.md b/TODO.md index 874cbd98..78d2cfdd 100644 --- a/TODO.md +++ b/TODO.md @@ -314,8 +314,6 @@ https://code.djangoproject.com/ticket/24576 # inspecting django db connection for asserting db readines? or performing a query # wake up django mailer on send_mail -# all signals + accouns.register() services.register() on apps.py - from orchestra.contrib.tasks import task import time, sys @task(name='rata') @@ -355,3 +353,8 @@ make django admin taskstate uncollapse fucking traceback, ( if exists ?) # backend.context and backned.instance provided when an action is called? like forms.cleaned_data: do it on manager.generation(backend.context = backend.get_context()) or in backend.__getattr__ ? also backend.head,tail,content switching on manager.generate()? resorce monitoring more efficient, less mem an better queries for calc current data + +# best_price rating method + + +# error reporting on periodic tasks diff --git a/orchestra/bin/orchestra-beat b/orchestra/bin/orchestra-beat index 535b954a..83f4722c 100755 --- a/orchestra/bin/orchestra-beat +++ b/orchestra/bin/orchestra-beat @@ -94,6 +94,7 @@ class crontab_parser(object): 'Invalid beginning range: {0} < {1}.'.format(i, self.min_)) return i + class Setting(object): def __init__(self, manage): self.manage = manage diff --git a/orchestra/contrib/mailer/settings.py b/orchestra/contrib/mailer/settings.py index c001c978..1eb9cb1e 100644 --- a/orchestra/contrib/mailer/settings.py +++ b/orchestra/contrib/mailer/settings.py @@ -7,5 +7,5 @@ MAILER_DEFERE_SECONDS = Setting('MAILER_DEFERE_SECONDS', MAILER_MESSAGES_CLEANUP_DAYS = Setting('MAILER_MESSAGES_CLEANUP_DAYS', - 10 + 7 ) diff --git a/orchestra/contrib/mailer/tasks.py b/orchestra/contrib/mailer/tasks.py index 651a0c96..ed5e86eb 100644 --- a/orchestra/contrib/mailer/tasks.py +++ b/orchestra/contrib/mailer/tasks.py @@ -1,9 +1,11 @@ +from datetime import timedelta + from django.utils import timezone from celery.task.schedules import crontab from orchestra.contrib.tasks import task, periodic_task -from . import engine +from . import engine, settings @task @@ -17,4 +19,4 @@ def cleanup_messages(): delta = timedelta(days=settings.MAILER_MESSAGES_CLEANUP_DAYS) now = timezone.now() epoch = (now-delta) - Message.objects.filter(state=Message.SENT, last_retry__lt=epoc).delete() + return Message.objects.filter(state=Message.SENT, last_retry__lt=epoch).delete() diff --git a/orchestra/contrib/orchestration/settings.py b/orchestra/contrib/orchestration/settings.py index af93e90b..cea71474 100644 --- a/orchestra/contrib/orchestration/settings.py +++ b/orchestra/contrib/orchestration/settings.py @@ -39,5 +39,5 @@ ORCHESTRATION_DISABLE_EXECUTION = Setting('ORCHESTRATION_DISABLE_EXECUTION', ORCHESTRATION_BACKEND_CLEANUP_DAYS = Setting('ORCHESTRATION_BACKEND_CLEANUP_DAYS', - 15 + 7 ) diff --git a/orchestra/contrib/orchestration/tasks.py b/orchestra/contrib/orchestration/tasks.py index 4c06b794..9c9bb679 100644 --- a/orchestra/contrib/orchestration/tasks.py +++ b/orchestra/contrib/orchestration/tasks.py @@ -5,6 +5,7 @@ from django.utils import timezone from orchestra.contrib.tasks import periodic_task +from . import settings from .models import BackendLog @@ -12,4 +13,4 @@ from .models import BackendLog def backend_logs_cleanup(): days = settings.ORCHESTRATION_BACKEND_CLEANUP_DAYS epoch = timezone.now()-timedelta(days=days) - BackendLog.objects.filter(created_at__lt=epoch).delete() + return BackendLog.objects.filter(created_at__lt=epoch).delete() diff --git a/orchestra/contrib/tasks/apps.py b/orchestra/contrib/tasks/apps.py index a6fd8f7e..ceb4e24b 100644 --- a/orchestra/contrib/tasks/apps.py +++ b/orchestra/contrib/tasks/apps.py @@ -1,4 +1,5 @@ from django.apps import AppConfig +from django.utils.module_loading import autodiscover_modules from orchestra.core import administration @@ -12,3 +13,4 @@ class TasksConfig(AppConfig): administration.register(TaskState, icon='Edit-check-sheet.png') administration.register(PeriodicTask, parent=TaskState, icon='Appointment.png') administration.register(WorkerState, parent=TaskState, dashboard=False) + autodiscover_modules('tasks')