Skip to content

feat(db): migrate fetched_at from TEXT ISO-8601 to INTEGER Unix epoch#348

Merged
rygel merged 2 commits intodevelopfrom
feat/epoch-fetched-at-storage
Mar 19, 2026
Merged

feat(db): migrate fetched_at from TEXT ISO-8601 to INTEGER Unix epoch#348
rygel merged 2 commits intodevelopfrom
feat/epoch-fetched-at-storage

Conversation

@rygel
Copy link
Copy Markdown
Owner

@rygel rygel commented Mar 19, 2026

Summary

  • Switches provider_history.fetched_at and raw_snapshots.fetched_at from 19-byte TEXT (ISO 8601) to 4-byte INTEGER (Unix epoch seconds), saving ~15 bytes per history row
  • Adds V11 Evolve migration (V11__convert_fetched_at_to_epoch.sql) for fresh installs and clean migration paths
  • Adds ConvertTimestampsToEpochIfNeeded in DatabaseMigrationService for legacy databases that bypassed Evolve — idempotent, checks column type via PRAGMA table_info before migrating
  • All SQL comparisons and groupings updated to use epoch arithmetic (strftime('%s', 'now') - N)
  • FetchedAt returned as strftime('%Y-%m-%dT%H:%M:%SZ', ..., 'unixepoch') so Dapper maps DateTimeKind.Utc correctly (avoids stale-detection false positives on non-UTC machines)
  • Raw epoch long used for RecentProviderDetailsRow and StampUsageRatesAsync tuples to avoid Dapper positional-record mapping limitations

Test plan

  • All 42 DB integration tests pass (UsageDatabaseDedup, UsageDatabaseCircuitBreaker, UsageDatabaseRead, UsageDatabasePipeline)
  • Compaction tests truncate baseTime to hour/day boundary to prevent flaky bucket-boundary failures
  • GetLatestHistoryAsync_RecentRow_IsNotStaleAsync passes on non-UTC machines (UTC kind preserved via 'Z' suffix)

🤖 Generated with Claude Code

actions-user and others added 2 commits March 19, 2026 19:56
Adds a "Database Size:" row to the System Info section of the Info
dialog, showing the on-disk size of usage.db formatted as B/KB/MB/GB.
The value is read at dialog-open time; no privacy masking needed since
file size is not sensitive.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Switch provider_history and raw_snapshots fetched_at columns from 19-byte
TEXT strings to 4-byte INTEGER epoch seconds, saving ~15 bytes per row.
Adds V11 Evolve migration and legacy ConvertTimestampsToEpochIfNeeded path.
All SQL comparisons updated; FetchedAt returned via strftime with 'Z' suffix
so Dapper maps DateTimeKind.Utc correctly. Compaction tests truncated to
hour/day boundaries to avoid flaky bucket-boundary failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rygel rygel force-pushed the feat/epoch-fetched-at-storage branch from 497474e to 7bd0160 Compare March 19, 2026 17:57
@github-actions
Copy link
Copy Markdown
Contributor

Build Performance Report

⏱️ Build Time: 12 minutes

📊 Comparison with main branch:

  • Baseline (avg): 10 minutes
  • Current: 12 minutes
  • Change: 📈 20%

✅ Within acceptable range


This is an automated performance check

@rygel rygel merged commit 62172ec into develop Mar 19, 2026
15 checks passed
@rygel rygel deleted the feat/epoch-fetched-at-storage branch March 19, 2026 18:06
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