CivicDataLab / CivicDataLab/IDS-DRR-Frontend
perf: Drop district/subdistrict dropdown queries, derive both from the existing map-data features
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 1
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 1
Description
The analytics map view fires four queries that overlap:
districtMapData: GeoJSON, whose features include each district's code and namerevCircleMapData: GeoJSON, whose features include each revcircle's code, name, and parent district's district-codegetDistrictRevCircle({ type: "district", code }):[{ district: name, code }, …], populates the district dropdowngetDistrictRevCircle({ type: <subdistrict-type>, code }):{ <districtName>: [{ <typeSlug>: name, code, district_code }, …] }, populates the revenue-circle dropdown (grouped by district name)
The two getDistrictRevCircle calls run the same layer_geography joins as the map queries, doubling query time on cold cache.
Proposed change: Derive dropdowns from map features, and remove getDistrictRevCircle (which also has an India-specific name).
Affects:
app/[locale]/[state]/analytics/components/analytics-layout.tsx: removedistrictGeographiesDataandrevenueGeographiesDatauseQuery calls and their consumers. Replace the consumers with:- District dropdown: read code and name from
districtMapData.features[].properties. - Subdistrict dropdown: read code, name, and district-code from
revCircleMapData.features[].properties, then group by district name using a district-code to name lookup built fromdistrictMapData.features(already loaded).
- District dropdown: read code and name from
app/[locale]/[state]/analytics/components/analytics-mobile-layout.tsx: same ideaapp/[locale]/[state]/analytics/components/filter-component.tsx: same ideaconfig/graphql/analaytics-queries.ts: remove thegetDistrictRevCirclequery definition.tests/analytics-layout.test.tsx,tests/filter-component.test.tsx,tests/analytics-mobile-layout.test.tsx: replacegetDistrictRevCirclefixtures with equivalentdistrictMapDataorrevCircleMapDatafeature fixtures.
Backend:
layer/schema.py: remove get_district_rev_circle and its Query.get_district_rev_circle field.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the three analytics layout/filter components and inspect the existing districtMapData and revCircleMapData feature properties. Run tests/analytics-layout.test.tsx, tests/filter-component.test.tsx, and tests/analytics-mobile-layout.test.tsx while replacing the listed fixtures, then check config/graphql/analaytics-queries.ts and layer/schema.py. Done means the dropdowns use map features, getDistrictRevCircle is removed, and the affected tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, python, typescript
- Domain
- backend, frontend, performance, testing-qa
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100