Skip to content

feat(per-dashboard): trim the dashboard data and describe it in the schema - #2894

Merged
arunissun merged 3 commits into
developfrom
feature/per-dashboard-trim-payload
Nov 13, 2026
Merged

arunissun merged 3 commits into
developfrom
feature/per-dashboard-trim-payload

Conversation

@arunissun

@arunissun arunissun commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

per-map-data was about 9.9 MB uncompressed with 4–6 s before the first byte, and the dashboard used about 6% of it. Only the PER dashboard reads these two endpoints, and the dashboard on develop does not use them yet.

Related: IFRCGo/go-api-artifacts#6 (schema)

per-map-data

  • remove results (the dashboard works out the latest process per country itself), processes[].components, the four *_considerations_from_assessment fields and the duplicate assessment_date, lat and lon
  • stop loading assessments and component responses, which only those fields needed
  • add areaNum to prioritized_components
  • skip the parent component through is_parent instead of the hardcoded component id 14

per-dashboard-data

  • add area_num, component_letter and is_parent to the component entries, so the dashboard can use the shared PER area colours and show each component 14 sub-component as its own row ("14 A: First Aid")
  • sort components by area number, component number and letter

Both endpoints

  • remove the translated region_name, type_of_assessment_name and phase_display (the dashboard uses the ids and the global enums)
  • gzip the responses with gzip_page;
  • cache the data per language: country, component and rating names are translated, and the shared cache key served the first language's names to everyone
  • cache the data on the live API too: since refactor(per): consolidate PER dashboard data endpoints #2821 the cache only worked when DJANGO_READ_ONLY was true, so the live API rebuilt the data on every request (per-dashboard-data takes about 17 s on production data). The data is now cached for 1 hour whatever DJANGO_READ_ONLY is set to, so a PER update can take up to an hour to show on the dashboard
  • describe both responses in the OpenAPI schema so the web app can use generated types

Tests

  • updated the map and dashboard data tests for the new shape
  • added tests for the removed fields, the parent component, the component letters, gzip and the per-language cache
  • the cache tests run with DJANGO_READ_ONLY=False, as on the live API

Checked locally (read-only, through the SSH tunnel)

Production data:

  • per-map-data: 176 processes from 116 countries, 506 KB of JSON, 40 KB sent with gzip
  • per-dashboard-data: 51 components, 2,513 KB of JSON, 278 KB sent with gzip; 16.6 s before the first byte without the cache, immediate from the cache
  • French responses carry French country names (102 of 176 differ from English), so the per-language cache works
  • area_id equals area_num for all 51 components; component 14 comes as the parent plus sub-components 14 A to 14 N, and no parent component appears in prioritized_components
  • the web app (PER dashboard go-web-app#2555) was checked in the browser against this API

…chema

- remove results, processes[].components, the four *_considerations_from_assessment fields and the duplicate assessment_date, lat and lon from per-map-data, and stop loading the assessments they needed
- remove the translated region_name, type_of_assessment_name and phase_display from per-map-data and per-dashboard-data
- add areaNum to prioritized_components, and area_num, component_letter and is_parent to the per-dashboard-data components
- skip the parent component through is_parent instead of the hardcoded component id 14
- gzip both responses and cache them per language
- describe both responses in the OpenAPI schema and update the assets submodule
- cache per-map-data and per-dashboard-data whatever DJANGO_READ_ONLY is set to; the cache only worked in read-only mode, so the live API rebuilt the data on every request (about 17 s for per-dashboard-data on production data)
- keep the cached data for 1 hour instead of 60 s
- run the cache tests with DJANGO_READ_ONLY=False, as on the live API
- take in #2893 (potential funding amounts)
- point assets at the schema regenerated from this merge, which contains both the potential funding and the PER dashboard changes
arunissun added a commit to IFRCGo/go-api-artifacts that referenced this pull request Nov 13, 2026
- generated with spectacular from go-api develop merged into IFRCGo/go-api#2894
- describe the per-map-data and per-dashboard-data responses
- add the PerMapData, PerMapDataProcess, PerDashboardPrioritizedComponent, PerDashboardData, PerDashboardComponent, PerDashboardComponentAssessment and PerDashboardCountryAssessment components
@arunissun
arunissun merged commit 04f363f into develop Nov 13, 2026
6 checks passed
@arunissun
arunissun deleted the feature/per-dashboard-trim-payload branch November 13, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants