CivicDataLab / CivicDataLab/IDS-DRR-Frontend

perf: Drop district/subdistrict dropdown queries, derive both from the existing map-data features

Open
#427 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

maintenance section.analytics
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 name
  • revCircleMapData: GeoJSON, whose features include each revcircle's code, name, and parent district's district-code
  • getDistrictRevCircle({ type: "district", code }): [{ district: name, code }, …], populates the district dropdown
  • getDistrictRevCircle({ 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: remove districtGeographiesData and revenueGeographiesData useQuery 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 from districtMapData.features (already loaded).
  • app/[locale]/[state]/analytics/components/analytics-mobile-layout.tsx: same idea
  • app/[locale]/[state]/analytics/components/filter-component.tsx: same idea
  • config/graphql/analaytics-queries.ts: remove the getDistrictRevCircle query definition.
  • tests/analytics-layout.test.tsx, tests/filter-component.test.tsx, tests/analytics-mobile-layout.test.tsx: replace getDistrictRevCircle fixtures with equivalent districtMapData or revCircleMapData feature fixtures.

Backend:

  • layer/schema.py: remove get_district_rev_circle and its Query.get_district_rev_circle field.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.