Skip to content

Commit

Permalink
Correcting job schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Dec 13, 2022
1 parent 5a54684 commit d91217b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions core/common/tasks.py
Expand Up @@ -10,13 +10,14 @@
from django.core.mail import EmailMessage
from django.core.management import call_command
from django.template.loader import render_to_string
from django.utils import timezone
from django_elasticsearch_dsl.registries import registry
from pydash import get

from core.celery import app
from core.common.constants import CONFIRM_EMAIL_ADDRESS_MAIL_SUBJECT, PASSWORD_RESET_MAIL_SUBJECT
from core.common.utils import write_export_file, web_url, get_resource_class_from_resource_name, get_export_service, \
get_start_of_month, get_end_of_month, get_prev_month
get_end_of_month

logger = get_task_logger(__name__)

Expand Down Expand Up @@ -727,8 +728,9 @@ def monthly_usage_report(): # pragma: no cover
# runs on first of every month
# reports usage of prev month
from core.reports.models import MonthlyUsageReport
prev_month = get_prev_month()
report = MonthlyUsageReport(verbose=True, start=get_start_of_month(prev_month), end=get_end_of_month(prev_month))
now = timezone.now()
prev_month = now.replace(month=now.month - 1, day=1).date()
report = MonthlyUsageReport(verbose=True, start=prev_month, end=get_end_of_month(prev_month))
report.prepare()
html_body = render_to_string('monthly_usage_report_for_mail.html', report.get_result_for_email())
mail = EmailMessage(
Expand Down
2 changes: 1 addition & 1 deletion core/settings.py
Expand Up @@ -358,7 +358,7 @@
},
'first-of-every-month': {
'task': 'core.common.tasks.monthly_usage_report',
'schedule': crontab(0, 0, day_of_month='1'),
'schedule': crontab(1, 0, day_of_month='1'),
},
}
CELERYBEAT_HEALTHCHECK_KEY = 'celery_beat_healthcheck'
Expand Down

0 comments on commit d91217b

Please sign in to comment.