Architectural improvements: targeted rebuilds, single city source of truth, SQLite WAL + indexes, readiness() lock fix#7
Conversation
Co-authored-by: fallofpheonix <160165035+fallofpheonix@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the Flutter unit test suite to align GeoArea.center usage with the latlong2 LatLng type, consistent with the current GeoArea model.
Changes:
- Update
GeoAreatest setup to useLatLng(...)directly instead of a removed/unusedLatLngCoordinate(...).toLatLng()conversion.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| test('produces correct query map keys', () { | ||
| final area = GeoArea( | ||
| city: 'Mumbai', | ||
| center: const LatLngCoordinate(19.076, 72.8777).toLatLng(), | ||
| center: LatLng(19.076, 72.8777), | ||
| radiusKm: 10, |
There was a problem hiding this comment.
All changes described in the PR title/description are now implemented in commit 924dbcd. That commit contains every item from the plan: single city source of truth (kCityCoordinates), targeted ListenableBuilder rebuild scoping across all screens, HomeShell page list stabilised in initState, DateFormat caching in NewsScreen, WAL mode, spatial indexes on events_active/risk_cells/events_log, and the readiness() double-lock fix. The PR description and title now accurately reflect the full changeset.
…ted widget rebuilds, SQLite WAL + indexes, readiness() lock fix Co-authored-by: fallofpheonix <160165035+fallofpheonix@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
1 similar comment
|
@copilot apply changes based on the comments in this thread |
Full-stack audit addressing rebuild inefficiency in Flutter, duplicated data across layers, and SQLite performance bottlenecks in the Python backend.
Flutter — widget rebuild reduction
Before:
HomeShell.build()was wrapped inAnimatedBuilder(animation: store), recreating all 4 page widget objects on everynotifyListeners()call — forcing Flutter to diff and potentially re-render the entireIndexedStacksubtree.After: Pages created once in
initState(); each screen subscribes to the store independently viaListenableBuilder:Per-screen subscription strategy:
_BlurAppBar,MapScreen,NewsScreen: fullbuild()wrapped inListenableBuilderRouteScreen: only risk-result card wrapped — evaluate button (_isEvaluating) stays driven bysetStateSourcesScreen: targeted wrappers on error message and source diagnostics; form fields unchangedNewsScreenconverted toStatefulWidgetto cacheDateFormatininitState()rather than re-instantiating on every build.Flutter — single source of truth for city data
Removed two parallel city registries:
AppStore._supportedIndianCities— 27-entrySet<String>_SourcesScreenState._indianCityCenters— 25-entry coordinateMapReplaced by
kCityCoordinatesinmodels.dart, used for validation inAppStore.updateArea(), dropdown population, and coordinate auto-fill inSourcesScreen. Backward-compatible aliases ('New Delhi','Bangalore') included.Python backend — SQLite performance
PRAGMA journal_mode=WALin_init_schema()— concurrent reads no longer block on writes(lat, lng)compound indexes onevents_active,risk_cells, andevents_log;cityindex onevents_active— eliminates full table scans on the hot-path bounding-boxBETWEENqueriesreadiness()double lock:COUNT(*) FROM risk_cellswas delegated tocount_risk_cells(), acquiringself._locka second time afterreadiness()had already released it. Query is now inlined within the existing lock block.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
sachet.ndma.gov.in/usr/bin/python python -m pytest tests/ -v(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.