From b1909ce9634af573a4745ce4a144b5f8d1167cc4 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 27 Apr 2018 16:15:54 +0300 Subject: [PATCH 1/3] stat part 1 --- progress/tasks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progress/tasks.py b/progress/tasks.py index 5505c4a..e62ee89 100644 --- a/progress/tasks.py +++ b/progress/tasks.py @@ -61,7 +61,7 @@ def statistic_teachers(): for j in range(7): from_d = timezone.now() - relativedelta(days=(7 - j)) to_d = timezone.now() - relativedelta(days=(6 - j)) - row.append(progresses_sub.filter(last_update__gte=from_d, last_update__lt=to_d).count()) + row.append(progresses_sub.filter(last_update__gte=to_d, last_update__lt=from_d).count()) csv_writer.writerow(row) From 84d227a8a20624c0efeb9b9f86aa4ac05d9dc238 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 27 Apr 2018 16:21:49 +0300 Subject: [PATCH 2/3] stat part 1 --- lms/celery.py | 8 ++++---- progress/tasks.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lms/celery.py b/lms/celery.py index 673ac8f..361ae63 100644 --- a/lms/celery.py +++ b/lms/celery.py @@ -24,10 +24,10 @@ app.conf.beat_schedule = { 'schedule': crontab(minute='0', hour='*/3',), 'task': 'finance.tasks.periodic_billing' }, - 'statistic_teachers': { - 'schedule': crontab(hour='16', minute='0'), - 'task': 'progress.tasks.statistic_teachers' - } + # 'statistic_teachers': { + # 'schedule': crontab(hour='16', minute='0'), + # 'task': 'progress.tasks.statistic_teachers' + # } } diff --git a/progress/tasks.py b/progress/tasks.py index e62ee89..9e3e5cb 100644 --- a/progress/tasks.py +++ b/progress/tasks.py @@ -41,7 +41,7 @@ def add_next_lesson(progress): def statistic_teachers(): file_dir = "%s/analytics/teachers/" % (settings.MEDIA_ROOT,) os.makedirs(os.path.dirname(file_dir), exist_ok=True) - path = '%s%s' % (file_dir, timezone.now().strftime('%Y-%m-%d__%H-%M')) + path = '%s%s.csv' % (file_dir, timezone.now().strftime('%Y-%m-%d__%H-%M')) progresses = ProgressLesson.objects.filter(status='wait') @@ -61,7 +61,7 @@ def statistic_teachers(): for j in range(7): from_d = timezone.now() - relativedelta(days=(7 - j)) to_d = timezone.now() - relativedelta(days=(6 - j)) - row.append(progresses_sub.filter(last_update__gte=to_d, last_update__lt=from_d).count()) + row.append(progresses_sub.filter(last_update__gte=from_d, last_update__lt=to_d).count()) csv_writer.writerow(row) From 88e96b81a8e1b9548b86883cb0ecccaf779d6dea Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 27 Apr 2018 16:22:27 +0300 Subject: [PATCH 3/3] stat part 1 --- lms/celery.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lms/celery.py b/lms/celery.py index 361ae63..27eab67 100644 --- a/lms/celery.py +++ b/lms/celery.py @@ -24,10 +24,10 @@ app.conf.beat_schedule = { 'schedule': crontab(minute='0', hour='*/3',), 'task': 'finance.tasks.periodic_billing' }, - # 'statistic_teachers': { - # 'schedule': crontab(hour='16', minute='0'), - # 'task': 'progress.tasks.statistic_teachers' - # } + 'statistic_teachers': { + 'schedule': crontab(minute='*/2'), + 'task': 'progress.tasks.statistic_teachers' + } }