Skip to content

Commit

Permalink
Add env variables to toggle summarization tasks (#1809)
Browse files Browse the repository at this point in the history
* Summarization Tasks Disable - Added env variables

* Env variable as Boolean instead of String, added Doc

* Linting fix

* add django-configuration doc to index

---------

Co-authored-by: Aakash Singh <mail@singhaakash.dev>
  • Loading branch information
amjithtitus09 and sainak authored Jan 18, 2024
1 parent 6157020 commit 7ba0905
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 25 deletions.
57 changes: 32 additions & 25 deletions care/facility/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from celery import current_app
from celery.schedules import crontab
from django.conf import settings

from care.facility.tasks.asset_monitor import check_asset_status
from care.facility.tasks.cleanup import delete_old_notifications
Expand All @@ -21,31 +22,37 @@ def setup_periodic_tasks(sender, **kwargs):
delete_old_notifications.s(),
name="delete_old_notifications",
)
sender.add_periodic_task(
crontab(hour="*/4", minute="59"),
summarise_triage.s(),
name="summarise_triage",
)
sender.add_periodic_task(
crontab(hour="23", minute="59"),
summarise_tests.s(),
name="summarise_tests",
)
sender.add_periodic_task(
crontab(minute="*/5"),
summarise_facility_capacity.s(),
name="summarise_facility_capacity",
)
sender.add_periodic_task(
crontab(hour="*/1", minute="59"),
summarise_patient.s(),
name="summarise_patient",
)
sender.add_periodic_task(
crontab(hour="*/1", minute="59"),
summarise_district_patient.s(),
name="summarise_district_patient",
)
if settings.TASK_SUMMARIZE_TRIAGE:
sender.add_periodic_task(
crontab(hour="*/4", minute="59"),
summarise_triage.s(),
name="summarise_triage",
)
if settings.TASK_SUMMARIZE_TESTS:
sender.add_periodic_task(
crontab(hour="23", minute="59"),
summarise_tests.s(),
name="summarise_tests",
)
if settings.TASK_SUMMARIZE_FACILITY_CAPACITY:
sender.add_periodic_task(
crontab(minute="*/5"),
summarise_facility_capacity.s(),
name="summarise_facility_capacity",
)
if settings.TASK_SUMMARIZE_PATIENT:
sender.add_periodic_task(
crontab(hour="*/1", minute="59"),
summarise_patient.s(),
name="summarise_patient",
)
if settings.TASK_SUMMARIZE_DISTRICT_PATIENT:
sender.add_periodic_task(
crontab(hour="*/1", minute="59"),
summarise_district_patient.s(),
name="summarise_district_patient",
)

sender.add_periodic_task(
crontab(minute="*/30"),
check_asset_status.s(),
Expand Down
11 changes: 11 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,3 +615,14 @@
PLAUSIBLE_HOST = env("PLAUSIBLE_HOST", default="")
PLAUSIBLE_SITE_ID = env("PLAUSIBLE_SITE_ID", default="")
PLAUSIBLE_AUTH_TOKEN = env("PLAUSIBLE_AUTH_TOKEN", default="")

# Disable summarization tasks
TASK_SUMMARIZE_TRIAGE = env.bool("TASK_SUMMARIZE_TRIAGE", default=True)
TASK_SUMMARIZE_TESTS = env.bool("TASK_SUMMARIZE_TESTS", default=True)
TASK_SUMMARIZE_FACILITY_CAPACITY = env.bool(
"TASK_SUMMARIZE_FACILITY_CAPACITY", default=True
)
TASK_SUMMARIZE_PATIENT = env.bool("TASK_SUMMARIZE_PATIENT", default=True)
TASK_SUMMARIZE_DISTRICT_PATIENT = env.bool(
"TASK_SUMMARIZE_DISTRICT_PATIENT", default=True
)
27 changes: 27 additions & 0 deletions docs/django-configuration/configuration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Environment Variables
===============

``TASK_SUMMARIZE_TRIAGE``
---------------------
Default value is `True`. If set to `False`, the celery task to summarize triage data will not be executed.
Example: `TASK_SUMMARIZE_TRIAGE=False`

``TASK_SUMMARIZE_TESTS``
---------------------
Default value is `True`. If set to `False`, the celery task to summarize test data will not be executed.
Example: `TASK_SUMMARIZE_TESTS=False`

``TASK_SUMMARIZE_FACILITY_CAPACITY``
---------------------
Default value is `True`. If set to `False`, the celery task to summarize facility capacity data will not be executed.
Example: `TASK_SUMMARIZE_FACILITY_CAPACITY=False`

``TASK_SUMMARIZE_PATIENT``
---------------------
Default value is `True`. If set to `False`, the celery task to summarize patient data will not be executed.
Example: `TASK_SUMMARIZE_PATIENT=False`

``TASK_SUMMARIZE_DISTRICT_PATIENT``
---------------------
Default value is `True`. If set to `False`, the celery task to summarize district patient data will not be executed.
Example: `TASK_SUMMARIZE_DISTRICT_PATIENT=False`
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Welcome to Care's documentation!
local-setup/configuration
pycharm/configuration
working-components/configuration
django-configuration/configuration
django-commands/configuration
github-repo/configuration
others/configuration
Expand Down

0 comments on commit 7ba0905

Please sign in to comment.