From 1c33718e5bcc17e013d0f7f0c5bff7edca7a16d0 Mon Sep 17 00:00:00 2001 From: Mike Repec Date: Sun, 26 Nov 2023 18:42:11 +0100 Subject: [PATCH] Make daily notifier run at noon and notify about previous day's stats --- daily_notification.go | 4 ++-- main.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/daily_notification.go b/daily_notification.go index cd16bfa..b2498e9 100644 --- a/daily_notification.go +++ b/daily_notification.go @@ -11,7 +11,7 @@ import ( const ( DailyNotificationTemplate = `đŸ“ĸ *LateNightCommits Daily Notifier* 📊 -Fetched a total of %d commits today\. +Fetched a total of %d commits yesterday\. ℹī¸ Check out the [stats page](https://latenightcommits.com/api/stats) for more\.` ) @@ -21,7 +21,7 @@ func runDailyNotification(db *gorm.DB, notifier Notifier) error { var sentToday int64 if err := db.Raw( - `SELECT COUNT(id) FROM commits WHERE created_at BETWEEN CURRENT_DATE AND (CURRENT_DATE + INTERVAL 1 DAY);`, + `SELECT COUNT(id) FROM commits WHERE created_at BETWEEN (CURRENT_DATE - INTERVAL 1 DAY) AND CURRENT_DATE;`, ).Scan(&sentToday).Error; err != nil { return errors.Wrap(err, "failed to retrieve daily fetched amount for notifier") } diff --git a/main.go b/main.go index 6e6a748..516b807 100644 --- a/main.go +++ b/main.go @@ -82,7 +82,7 @@ func ViperInit() error { viper.SetDefault("port", 80) viper.SetDefault("github.search_page_depth", 5) viper.SetDefault("fetch_worker.schedule", "*/10 * * * *") - viper.SetDefault("daily_notifier.schedule", "55 23 * * *") + viper.SetDefault("daily_notifier.schedule", "0 12 * * *") if err := viper.ReadInConfig(); err != nil { if _, ok := err.(viper.ConfigFileNotFoundError); ok {