diff --git a/cmd/valera/main.go b/cmd/valera/main.go index 6a97bf7..451c0ae 100644 --- a/cmd/valera/main.go +++ b/cmd/valera/main.go @@ -28,7 +28,7 @@ var ( ) const ( - version = "v1.6.1" + version = "v1.6.2" ) type Opts struct { @@ -132,7 +132,7 @@ func run() { return } for _, chatID := range chats { - if err := sendStatToChat(bot, dataBase, chatID, "Напоминаю:\n- Cегодня больше не жрем!\n\n", true); err != nil { + if err := sendStatToChat(bot, dataBase, chatID, "Напоминаю:\n- Cегодня больше не жрем!\n\n"); err != nil { fmt.Println(err) w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusInternalServerError) @@ -266,7 +266,7 @@ func run() { case commands.Go: sendGoToChat(bot, dataBase, chatID) case commands.Stat: - if err := sendStatToChat(bot, dataBase, chatID, "", false); err != nil { + if err := sendStatToChat(bot, dataBase, chatID, ""); err != nil { fmt.Println(err) continue } @@ -312,8 +312,8 @@ func sendGoToChat(bot *tgbot.BotAPI, dataBase *db.DB, chatID int64) { } } -func sendStatToChat(bot *tgbot.BotAPI, dataBase *db.DB, chatID int64, prefix string, cron bool) error { - stat, err := dataBase.GetStat(chatID, cron) +func sendStatToChat(bot *tgbot.BotAPI, dataBase *db.DB, chatID int64, prefix string) error { + stat, err := dataBase.GetStat(chatID) if err != nil { return err } diff --git a/internal/db/db.go b/internal/db/db.go index 925b75b..bc1cbda 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -126,7 +126,7 @@ func (db *DB) SetPause(chatID int64, duration time.Duration) error { return err } -func (db *DB) GetStat(chatID int64, cron bool) (map[string]int, error) { +func (db *DB) GetStat(chatID int64) (map[string]int, error) { ctx := context.Background() if err := db.AddChat(chatID); err != nil { @@ -135,12 +135,7 @@ func (db *DB) GetStat(chatID int64, cron bool) (map[string]int, error) { loc, _ := time.LoadLocation("Asia/Novosibirsk") t := time.Now().In(loc) - if cron { - t = t.Add(-24 * time.Hour) - } - if !cron { - t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, loc) - } + t = time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, loc) res := map[string]int{}