Skip to content

Conversation

@vide
Copy link
Owner

@vide vide commented Jan 20, 2026

Summary

  • Add "Countries Visited" record to Stats for Nerds under Drives category showing count of unique countries
  • Tapping the record opens a dedicated screen listing all countries with flag emoji, name, first/last visit dates, and drive count
  • Country data extracted during drive sync via Nominatim reverse geocoding of first position

Changes

Data layer:

  • Add startCountryCode and startCountryName fields to DriveDetailAggregate
  • Bump SchemaVersion to 3 to trigger reprocessing of existing drives
  • Add database migration V3→V4 for new columns
  • Enhance GeocodingRepository with reverseGeocodeWithCountry()
  • Add country aggregation queries to AggregateDao

UI:

  • Create CountriesVisitedScreen with sorting options (by first visit, alphabetically, by drive count)
  • Create CountriesVisitedViewModel for screen state management
  • Add record card to StatsScreen with navigation
  • Add localized strings for all 4 locales (EN, IT, ES, CA)

Test plan

  • Trigger full sync (or wait for automatic reprocessing due to schema bump)
  • Verify "Countries Visited" appears in Stats for Nerds → Drives section
  • Tap the record → verify country list shows with flags
  • Test year filter works correctly
  • Test all three sorting options
  • Test empty state (car with no country data)

🤖 Generated with Claude Code

vide and others added 9 commits January 20, 2026 20:43
Add a new "Countries Visited" record in the Drives category that shows
the count of unique countries visited. Tapping the record opens a
dedicated screen listing all countries with:
- Flag emoji (derived from ISO 3166-1 alpha-2 country code)
- Country name
- First and last visit dates
- Drive count per country

Data layer changes:
- Add startCountryCode and startCountryName fields to DriveDetailAggregate
- Bump SchemaVersion to 3 to trigger reprocessing of drive details
- Add database migration V3→V4 for new country columns
- Enhance GeocodingRepository with reverseGeocodeWithCountry()
- Extract country during drive detail sync via Nominatim API
- Add country queries to AggregateDao
- Add CountryRecord model and countriesVisitedCount to DeepStats
- Add country stats methods to StatsRepository

UI changes:
- Create CountriesVisitedScreen with sorting options (by first visit,
  alphabetically, by drive count)
- Create CountriesVisitedViewModel for screen state
- Add record card to StatsScreen with navigation callback
- Add navigation route for CountriesVisited screen
- Add localized strings for all 4 locales (EN, IT, ES, CA)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Show "Offline since X" tooltip and duration below status icons when
car is in offline state, similar to asleep/suspended states.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Reduce throttle delay from 100ms to 10ms between batches
- Process drives/charges in parallel batches of 10 concurrent requests
- Country geocoding also runs concurrently within each batch
- Batch database writes (upsertDriveAggregates, upsertChargeAggregates)
- Single-pass aggregate computation instead of multiple iterations
- Update progress once per batch instead of per item

Expected improvement: 10-20x faster sync (30+ min → 2-3 min)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add updateDriveDetailProgressBatch and updateChargeDetailProgressBatch
  methods to SyncStateDao and SyncManager
- Update SyncRepository to use batch progress updates with correct count
- Fixes progress bar not updating correctly during parallel batch sync

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The progress bar was not updating because the UI was reading progress
from slow DB aggregate count queries (deepSyncProgress) instead of
the real-time SyncProgress.percentage from StateFlow.

Now uses StateFlow percentage during active sync, falling back to
DB counts when sync is complete.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pass isSyncing to StatsContent so progress bar shows even when
percentage is 0% (sync just started).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Reverting commits a6af175, 5b8cf29, 5865072 to rethink the approach.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of relying on StateFlow -> collector -> DB query chain,
use Room's reactive Flow queries that automatically emit when
tables change.

- Add observeCount() Flow queries to DriveSummaryDao, ChargeSummaryDao
- Add observeDriveAggregateCount/observeChargeAggregateCount to AggregateDao
- Add observeDeepSyncProgress() in StatsRepository using combine()
- ViewModel observes this Flow directly for real-time progress updates

This bypasses the complex StateFlow propagation and uses Room's
native change detection for reliable UI updates.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Nominatim API has ~1 req/sec rate limit which makes sync very slow.
Disabled for now until we implement a background/incremental approach.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
vide added a commit that referenced this pull request Jan 21, 2026
Adds a new 'Countries Visited' record to Stats for Nerds showing unique
countries visited. Tapping opens a detail screen with:
- Country flag, name, first/last visit dates
- Drive count, total distance, energy charged, charge count
- Sorting by first visit, alphabetically, or by drive count

Also includes:
- Background geocoding with Nominatim rate limiting (1 req/sec)
- Grid-based cache (~1km resolution) for efficient deduplication
- Progress tracking with sync recovery
- Localization in English, Italian, Spanish, and Catalan
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