Skip to content

Commit

Permalink
Make daily notifier run at noon and notify about previous day's stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Flexicon committed Nov 26, 2023
1 parent e2f0589 commit 1c33718
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions daily_notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\.`
)
Expand All @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1c33718

Please sign in to comment.