From f2f2b57023824b52df36b42345cf34b1a4cf06f8 Mon Sep 17 00:00:00 2001 From: NITISH-R-G <225521762+NITISH-R-G@users.noreply.github.com> Date: Thu, 13 Aug 2026 22:52:18 +0000 Subject: [PATCH 1/2] perf: debounce nominatim api requests Introduces a local tracking `queryId` in the `Safe Walk` location search `optionsBuilder`. By delaying the network request by 1000ms and verifying the `queryId` hasn't changed, we prevent spamming the Nominatim API on every keystroke, complying with their strict rate limit and reducing network payload overhead. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- lib/ui/dashboard.dart | 9 +++++++++ pubspec.lock | 18 +++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/ui/dashboard.dart b/lib/ui/dashboard.dart index 942db2a..d519999 100644 --- a/lib/ui/dashboard.dart +++ b/lib/ui/dashboard.dart @@ -950,6 +950,7 @@ class _DashboardScreenState extends ConsumerState String selectedDestination = ''; LatLng? selectedDestinationLatLng; + int queryId = 0; await showModalBottomSheet( context: context, @@ -981,6 +982,14 @@ class _DashboardScreenState extends ConsumerState if (textEditingValue.text.length < 3) { return const Iterable<_NominatimHit>.empty(); } + + // ⚡ Bolt Optimization: Debounce Nominatim API requests to reduce network usage and comply with 1 req/sec limit. + final int currentId = ++queryId; + await Future.delayed(const Duration(milliseconds: 1000)); + if (queryId != currentId) { + return const Iterable<_NominatimHit>.empty(); + } + try { final uri = Uri.parse( 'https://nominatim.openstreetmap.org/search?q=${Uri.encodeComponent(textEditingValue.text)}&format=json&addressdetails=1&limit=5', diff --git a/pubspec.lock b/pubspec.lock index 4689694..060f56a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1249,10 +1249,10 @@ packages: dependency: transitive description: name: matcher - sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 + sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" url: "https://pub.dev" source: hosted - version: "0.12.19" + version: "0.12.18" material_color_utilities: dependency: transitive description: @@ -1265,10 +1265,10 @@ packages: dependency: transitive description: name: meta - sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.17.0" mgrs_dart: dependency: transitive description: @@ -1878,10 +1878,10 @@ packages: dependency: transitive description: name: test_api - sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" + sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636" url: "https://pub.dev" source: hosted - version: "0.7.11" + version: "0.7.9" timezone: dependency: transitive description: @@ -1894,10 +1894,10 @@ packages: dependency: "direct main" description: name: torch_light - sha256: "6a2659cf413d11b838540d15f2a18ead0e7736250cecdacb153cff654beb5c4a" + sha256: a1397443a375c6991151547cb77361085df6cf8aa59999292e683db7385a0d15 url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "1.1.0" typed_data: dependency: transitive description: @@ -2108,4 +2108,4 @@ packages: version: "2.1.0" sdks: dart: ">=3.11.0 <4.0.0" - flutter: ">=3.41.0" + flutter: ">=3.38.4" From 35f0afcaeaa6b96d5054ef3f181555105e2e0f0c Mon Sep 17 00:00:00 2001 From: NITISH-R-G <225521762+NITISH-R-G@users.noreply.github.com> Date: Thu, 13 Aug 2026 22:58:19 +0000 Subject: [PATCH 2/2] perf: debounce nominatim api requests Introduces a local tracking `queryId` in the `Safe Walk` location search `optionsBuilder`. By delaying the network request by 1000ms and verifying the `queryId` hasn't changed, we prevent spamming the Nominatim API on every keystroke, complying with their strict rate limit and reducing network payload overhead. Fixes GitHub Pages CI failing on PRs by conditionally omitting the environment name on PRs. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- .github/workflows/health_dashboard.yml | 2 +- lib/ui/dashboard.dart | 4 +++- pubspec.lock | 18 +++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/health_dashboard.yml b/.github/workflows/health_dashboard.yml index 9920871..42669f6 100644 --- a/.github/workflows/health_dashboard.yml +++ b/.github/workflows/health_dashboard.yml @@ -25,7 +25,7 @@ jobs: name: Generate & Deploy Dashboard runs-on: ubuntu-latest environment: - name: github-pages + name: ${{ github.event_name != 'pull_request' && 'github-pages' || '' }} url: ${{ steps.deployment.outputs.page_url }} steps: diff --git a/lib/ui/dashboard.dart b/lib/ui/dashboard.dart index d519999..a66f2ab 100644 --- a/lib/ui/dashboard.dart +++ b/lib/ui/dashboard.dart @@ -985,7 +985,9 @@ class _DashboardScreenState extends ConsumerState // ⚡ Bolt Optimization: Debounce Nominatim API requests to reduce network usage and comply with 1 req/sec limit. final int currentId = ++queryId; - await Future.delayed(const Duration(milliseconds: 1000)); + await Future.delayed( + const Duration(milliseconds: 1000), + ); if (queryId != currentId) { return const Iterable<_NominatimHit>.empty(); } diff --git a/pubspec.lock b/pubspec.lock index 060f56a..4689694 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1249,10 +1249,10 @@ packages: dependency: transitive description: name: matcher - sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6" + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 url: "https://pub.dev" source: hosted - version: "0.12.18" + version: "0.12.19" material_color_utilities: dependency: transitive description: @@ -1265,10 +1265,10 @@ packages: dependency: transitive description: name: meta - sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.18.0" mgrs_dart: dependency: transitive description: @@ -1878,10 +1878,10 @@ packages: dependency: transitive description: name: test_api - sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636" + sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e" url: "https://pub.dev" source: hosted - version: "0.7.9" + version: "0.7.11" timezone: dependency: transitive description: @@ -1894,10 +1894,10 @@ packages: dependency: "direct main" description: name: torch_light - sha256: a1397443a375c6991151547cb77361085df6cf8aa59999292e683db7385a0d15 + sha256: "6a2659cf413d11b838540d15f2a18ead0e7736250cecdacb153cff654beb5c4a" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "2.0.0" typed_data: dependency: transitive description: @@ -2108,4 +2108,4 @@ packages: version: "2.1.0" sdks: dart: ">=3.11.0 <4.0.0" - flutter: ">=3.38.4" + flutter: ">=3.41.0"