Recalculate yesterday's and today's stats

This commit is contained in:
Pijus Kamandulis
2025-06-24 09:41:24 +03:00
parent b89a1a2a7e
commit 844f7fa08b
4 changed files with 57 additions and 0 deletions

View File

@@ -322,3 +322,15 @@ func ClearDailyStats(db *clover.DB) error {
}
return nil
}
func DeleteDailyStatsForDay(db *clover.DB, date time.Time) error {
dateStr := date.Format(time.DateOnly)
// Delete the document for the specific date
if err := db.Delete(c.NewQuery(DailyStatsCollectionName).
Where(c.Field("Date").Eq(dateStr))); err != nil {
return fmt.Errorf("failed to delete daily stats for %s: %v", dateStr, err)
}
return nil
}