-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New dashboard #4330
base: develop
Are you sure you want to change the base?
New dashboard #4330
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4330 +/- ##
============================================
- Coverage 77.59% 55.05% -22.55%
============================================
Files 944 950 +6
Lines 44624 44620 -4
============================================
- Hits 34628 24564 -10064
- Misses 9996 20056 +10060
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
… to allow i-frame.
@srugano regenerate lock |
@srugano regenerate pdm |
} | ||
|
||
const url = householdDataUrl; | ||
console.log(url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove console.log
).value(); | ||
|
||
const totalSuccessfulUSD = successfulPaymentsGroupUSD.sum; | ||
console.log(totalSuccessfulUSD); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove console.log
(p, v) => p - (v.children_count || 0), | ||
() => 0 | ||
).value(); | ||
console.log( successfulPaymentsCountUSD.sum, totalPaymentsCount, pendingPaymentsGroupUSD.count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove console log
assert "0" in pageCountryDashboard.getTotalNumberOfFeedback().text | ||
assert "USD 0.00" in pageCountryDashboard.getTotalAmountTransferred().text | ||
pageCountryDashboard.switch_to_dashboard_iframe() | ||
# assert pageCountryDashboard.get_total_amount_paid().text == "", "Expected total amount paid to be empty." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these tests commented out?
from typing import List, Optional | ||
|
||
from django.http import HttpRequest, HttpResponse | ||
from django.utils.deprecation import MiddlewareMixin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johniak, @MarekBiczysko Please check if this middleware is correct. I needed to overwrite the default django setting in order to display dashboard page in an iframe
pyproject.toml
Outdated
@@ -98,6 +98,7 @@ dev = [ | |||
"pytest<8.0.0,>=7.4.4", | |||
"pytest-django<5.0.0,>=4.5.2", | |||
"pytest-echo<2.0.0,>=1.7.1", | |||
"pytest-mock<4.0.0,>=3.6.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this library? Is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the way I was able to test tasks running in exceptions.
""" | ||
Test that generate_dash_report_task refreshes data for the given business area. | ||
""" | ||
mock_refresh_data = mocker.patch.object(DashboardDataCache, "refresh_data") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the wrong way to call patch.object. You are not patching an object here
mock_household_objects.using.return_value.filter.return_value = mock_households | ||
mock_serializer.return_value.data = {"id": 1, "name": "test"} | ||
|
||
with patch.object(DashboardDataCache, "store_data") as mock_store_data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be done with monkeypatch and it is more correct in this case
assert "0" in pageCountryDashboard.getTotalNumberOfGrievances().text | ||
assert "0" in pageCountryDashboard.getTotalNumberOfFeedback().text | ||
assert "USD 0.00" in pageCountryDashboard.getTotalAmountTransferred().text | ||
pageCountryDashboard.switch_to_dashboard_iframe() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are these commented out lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still updating the figures
@patch.object(DashboardDataCache, "refresh_data") | ||
@patch("hct_mis_api.apps.core.models.BusinessArea.objects") | ||
def test_update_dashboard_figures( | ||
mock_business_area_objects: MagicMock, mock_refresh_data: MagicMock, afghanistan: BusinessArea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are these fixtures ?
@classmethod | ||
def refresh_data(cls, business_area_slug: str) -> Dict[str, Any]: | ||
""" | ||
Generate and store updated data for a given business area. | ||
""" | ||
households = Household.objects.using("read_only").filter(business_area__slug=business_area_slug) | ||
serialized_data = DashboardHouseholdSerializer(households, many=True).data | ||
|
||
cls.store_data(business_area_slug, serialized_data) | ||
return serialized_data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly we cache ALL households/payments data for the whole BA and then do the statistics calculations in the browser. This is huge amount of data for some business areas, wouldn't be easier to precalculate statistics on server side and cache only the final results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested with 500000 payments over 3 years and it can handle. I have precalculated some totals
AB#219780