Skip to content

Commit

Permalink
Added scheduled Admin Reports
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshhari committed Aug 23, 2021
1 parent fc5aaa5 commit f58aeb3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions care/facility/reports/admin_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from uuid import uuid4

import boto3
from celery.decorators import periodic_task
from celery.schedules import crontab
from django.conf import settings
from django.core.files.storage import default_storage
from django.core.mail import EmailMessage
Expand All @@ -18,6 +20,11 @@
from care.utils.whatsapp.send_media_message import generate_whatsapp_message


@periodic_task(run_every=crontab(minute="0", hour="8"))
def run_scheduled_district_reports():
AdminReports(AdminReportsMode.DISTRICT).generate_reports()


class InvalidModeException(Exception):
pass

Expand Down
6 changes: 5 additions & 1 deletion config/api_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
else:
router = SimpleRouter()


router.register("users", UserViewSet)
user_nested_rotuer = NestedSimpleRouter(router, r"users", lookup="users")
user_nested_rotuer.register("skill", UserSkillViewSet)
Expand Down Expand Up @@ -162,3 +161,8 @@
url(r"^", include(resource_nested_router.urls)),
url(r"^", include(shifting_nested_router.urls)),
]


## Importing Celery Tasks

import care.facility.reports.admin_reports

0 comments on commit f58aeb3

Please sign in to comment.