-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into 215787_drop_cash_a…
…ssist
- Loading branch information
Showing
50 changed files
with
1,541 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
src/frontend/src/containers/pages/dashboard/NewDashboardPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useBaseUrl } from '@hooks/useBaseUrl'; | ||
import { FC } from 'react'; | ||
|
||
export const NewDashboardPage: FC = () => { | ||
const { businessArea } = useBaseUrl(); | ||
const dashboardUrl = `${window.location.origin}/api/rest/dashboard/${businessArea}/`; | ||
return ( | ||
<div style={{ height: '100vh', width: '100%' }}> | ||
<iframe | ||
src={dashboardUrl} | ||
style={{ | ||
width: '100%', | ||
height: '100vh', | ||
border: 'none', | ||
}} | ||
title="Dashboard" | ||
/> | ||
</div> | ||
); | ||
}; |
4 changes: 2 additions & 2 deletions
4
src/frontend/src/containers/routers/AllProgramsRoutesSwitch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class DashboardConfig(AppConfig): | ||
name = "hct_mis_api.apps.dashboard" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import logging | ||
from typing import Any | ||
|
||
from hct_mis_api.apps.core.celery import app | ||
from hct_mis_api.apps.core.models import BusinessArea | ||
from hct_mis_api.apps.dashboard.services import DashboardDataCache | ||
from hct_mis_api.apps.utils.logs import log_start_and_end | ||
from hct_mis_api.apps.utils.sentry import sentry_tags, set_sentry_business_area_tag | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
CACHE_TIMEOUT = 60 * 60 * 24 # 24 hours | ||
|
||
|
||
@app.task(bind=True, default_retry_delay=60, max_retries=3) | ||
@log_start_and_end | ||
@sentry_tags | ||
def update_dashboard_figures(self: Any) -> None: | ||
""" | ||
Celery task that runs every 24 hours to refresh dashboard data for all business areas | ||
with households. | ||
""" | ||
business_areas_with_households = BusinessArea.objects.using("read_only").filter(active=True) | ||
|
||
for business_area in business_areas_with_households: | ||
try: | ||
set_sentry_business_area_tag(business_area.slug) | ||
DashboardDataCache.refresh_data(business_area.slug) | ||
|
||
except Exception as e: | ||
logger.error(f"Failed to refresh dashboard data for {business_area.slug}: {e}") | ||
raise self.retry(exc=e) | ||
|
||
|
||
@app.task(bind=True, default_retry_delay=60, max_retries=3) | ||
@log_start_and_end | ||
@sentry_tags | ||
def generate_dash_report_task(self: Any, business_area_slug: str) -> None: | ||
""" | ||
Celery task to refresh dashboard data for a specific business area. | ||
""" | ||
try: | ||
business_area = BusinessArea.objects.get(slug=business_area_slug) | ||
set_sentry_business_area_tag(business_area.slug) | ||
DashboardDataCache.refresh_data(business_area.slug) | ||
|
||
except BusinessArea.DoesNotExist: | ||
logger.error(f"Business area with slug {business_area_slug} not found.") | ||
except Exception as e: | ||
raise self.retry(exc=e, countdown=60) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from rest_framework import serializers | ||
|
||
|
||
class DashboardHouseholdSerializer(serializers.Serializer): | ||
business_area_name = serializers.CharField() | ||
total_delivered_quantity_usd = serializers.DecimalField(max_digits=12, decimal_places=2) | ||
total_delivered_quantity = serializers.DecimalField(max_digits=12, decimal_places=2) | ||
payments = serializers.IntegerField() | ||
individuals = serializers.IntegerField() | ||
households = serializers.IntegerField() | ||
children_counts = serializers.IntegerField() | ||
month = serializers.CharField() | ||
year = serializers.IntegerField() | ||
program = serializers.CharField() | ||
sector = serializers.CharField() | ||
status = serializers.CharField() | ||
admin1 = serializers.CharField() | ||
fsp = serializers.CharField() | ||
delivery_types = serializers.CharField() | ||
pwd_counts = serializers.IntegerField() |
Oops, something went wrong.