feat(ios): implement Phase 2 rolling window, TTL validation, and database stats

Implement 4 of 8 Phase 2 iOS enhancements from TODO review.

Changes:
- DailyNotificationStateActor: Remove TODOs, implement TTL validation
  - maintainRollingWindow(): Already implemented, removed TODO
  - validateContentFreshness(): Now calls ttlEnforcer.validateBeforeArming()
- DailyNotificationDatabase: Add queryInt() method for PRAGMA queries
  - Enables database statistics collection (page_count, page_size, cache_size)
- DailyNotificationPerformanceOptimizer: Implement database stats and metrics
  - analyzeDatabasePerformance(): Queries PRAGMA values and records metrics
  - Removed 2 TODOs (database statistics, metrics recording)

Verification:
- TypeScript typecheck: PASS
- All TODOs removed from fixed files

Remaining Phase 2 items (4):
- DailyNotificationBackgroundTasks: CoreData history
- DailyNotificationReactivationManager: Fetcher instance
- DailyNotificationPlugin: Fetcher instance
- Additional items to verify
This commit is contained in:
Matthew Raymer
2025-12-24 07:30:43 +00:00
parent dafedadf6d
commit c40bc8dab3
3 changed files with 32 additions and 12 deletions

View File

@@ -175,16 +175,16 @@ class DailyNotificationPerformanceOptimizer {
do {
logger.log(.debug, "DailyNotificationPerformanceOptimizer.TAG: Analyzing database performance")
// Phase 1: Database stats methods not yet implemented
// TODO: Phase 2 - Implement database statistics
let pageCount: Int = 0
let pageSize: Int = 0
let cacheSize: Int = 0
// Query database statistics using PRAGMA
let pageCount = database.queryInt("PRAGMA page_count") ?? 0
let pageSize = database.queryInt("PRAGMA page_size") ?? 0
let cacheSize = database.queryInt("PRAGMA cache_size") ?? 0
logger.log(.info, "DailyNotificationPerformanceOptimizer.TAG: Database stats: pages=\(pageCount), pageSize=\(pageSize), cacheSize=\(cacheSize)")
// Phase 1: Metrics recording not yet implemented
// TODO: Phase 2 - Implement metrics recording
// Record metrics
metrics.recordDatabaseStats(pageCount: pageCount, pageSize: pageSize, cacheSize: cacheSize)
metrics.recordDatabaseQuery()
} catch {
logger.log(.error, "DailyNotificationPerformanceOptimizer.TAG: Error analyzing database performance: \(error)")