app.memos.management.commands.generate_dashboard_data

 1from django.core.management.base import BaseCommand
 2from app.memos.cron_job import precompute_all_hospitals_dashboard_data  # Adjust import as needed
 3
 4class Command(BaseCommand):
 5    """
 6    Django management command to generate and store precomputed dashboard data for all hospitals.
 7
 8    Usage:
 9        python manage.py generate_dashboard_data
10
11    - Calls `precompute_all_hospitals_dashboard_data` to process and save dashboard data.
12    - Stores results in the media/dashboard folder.
13    - Outputs success or error messages to the console.
14    """
15    help = 'Generates precomputed dashboard data and stores it in the media/dashboard folder.'
16
17    def handle(self, *args, **kwargs):
18        try:
19            result = precompute_all_hospitals_dashboard_data()
20            self.stdout.write(self.style.SUCCESS(f"✔ Dashboard data generated: {result}"))
21        except Exception as e:
22            self.stderr.write(self.style.ERROR(f"✖ Error: {e}"))
class Command(django.core.management.base.BaseCommand):
 5class Command(BaseCommand):
 6    """
 7    Django management command to generate and store precomputed dashboard data for all hospitals.
 8
 9    Usage:
10        python manage.py generate_dashboard_data
11
12    - Calls `precompute_all_hospitals_dashboard_data` to process and save dashboard data.
13    - Stores results in the media/dashboard folder.
14    - Outputs success or error messages to the console.
15    """
16    help = 'Generates precomputed dashboard data and stores it in the media/dashboard folder.'
17
18    def handle(self, *args, **kwargs):
19        try:
20            result = precompute_all_hospitals_dashboard_data()
21            self.stdout.write(self.style.SUCCESS(f"✔ Dashboard data generated: {result}"))
22        except Exception as e:
23            self.stderr.write(self.style.ERROR(f"✖ Error: {e}"))

Django management command to generate and store precomputed dashboard data for all hospitals.

Usage: python manage.py generate_dashboard_data

  • Calls precompute_all_hospitals_dashboard_data to process and save dashboard data.
  • Stores results in the media/dashboard folder.
  • Outputs success or error messages to the console.
help = 'Generates precomputed dashboard data and stores it in the media/dashboard folder.'
def handle(self, *args, **kwargs):
18    def handle(self, *args, **kwargs):
19        try:
20            result = precompute_all_hospitals_dashboard_data()
21            self.stdout.write(self.style.SUCCESS(f"✔ Dashboard data generated: {result}"))
22        except Exception as e:
23            self.stderr.write(self.style.ERROR(f"✖ Error: {e}"))

The actual logic of the command. Subclasses must implement this method.