fix(signal): use UTC for date calculations in health aggregation
Some checks are pending
CI Benchmark - Fusion Loop Timing / Fusion Loop Timing Benchmark (push) Waiting to run
Some checks are pending
CI Benchmark - Fusion Loop Timing / Fusion Loop Timing Benchmark (push) Waiting to run
Fix timezone mismatch between local time formatting and SQLite's UTC-based date() function. AggregateDaily, GetWeeklyTrend, and GetAllWeeklyTrends now use .UTC() before formatting dates to match SQLite's date(timestamp, 'unixepoch'). Closes: bf-26eg Tests: TestHealthStore_DailyAggregation, TestHealthStore_GetAllWeeklyTrends now pass
This commit is contained in:
parent
c0ae81a6b0
commit
0e1c12ec27
1 changed files with 4 additions and 4 deletions
|
|
@ -288,8 +288,8 @@ func (s *HealthStore) AggregateDaily() error {
|
|||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
// Get yesterday's date
|
||||
yesterday := time.Now().Add(-24 * time.Hour).Format("2006-01-02")
|
||||
// Get yesterday's date (UTC to match SQLite's date() function)
|
||||
yesterday := time.Now().Add(-24 * time.Hour).UTC().Format("2006-01-02")
|
||||
|
||||
// Aggregate per-link stats for yesterday
|
||||
_, err := s.db.Exec(`
|
||||
|
|
@ -318,7 +318,7 @@ func (s *HealthStore) GetWeeklyTrend(linkID string) ([]DailyHealthSummary, error
|
|||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
weekAgo := time.Now().Add(-7 * 24 * time.Hour).Format("2006-01-02")
|
||||
weekAgo := time.Now().Add(-7 * 24 * time.Hour).UTC().Format("2006-01-02")
|
||||
|
||||
rows, err := s.db.Query(`
|
||||
SELECT link_id, date, avg_health, min_health, max_health, avg_snr, avg_phase_stability, avg_packet_rate, sample_count
|
||||
|
|
@ -354,7 +354,7 @@ func (s *HealthStore) GetAllWeeklyTrends() (map[string][]DailyHealthSummary, err
|
|||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
|
||||
weekAgo := time.Now().Add(-7 * 24 * time.Hour).Format("2006-01-02")
|
||||
weekAgo := time.Now().Add(-7 * 24 * time.Hour).UTC().Format("2006-01-02")
|
||||
|
||||
rows, err := s.db.Query(`
|
||||
SELECT link_id, date, avg_health, min_health, max_health, avg_snr, avg_phase_stability, avg_packet_rate, sample_count
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue