From 38a21e4568efa24ab8a71862f7bde8ccaf36e9cd Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Sat, 11 Mar 2023 19:00:50 +0700 Subject: [PATCH] fix stat --- db/db.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/db/db.go b/db/db.go index 075c2b0..fa3a435 100644 --- a/db/db.go +++ b/db/db.go @@ -154,8 +154,17 @@ func GetStat(chatID int64) (map[string]int, error) { return nil, err } + loc, _ := time.LoadLocation("Asia/Novosibirsk") + t := time.Now().In(loc).Add(-24 * time.Hour) + collection := client.Database(cfg.DBName).Collection(cfg.WorkoutsCollectionName) - cursor, err := collection.Find(ctx, bson.M{"chat_id": chatID}) + cursor, err := collection.Find( + ctx, + bson.M{ + "chat_id": chatID, + "created_at": bson.M{"$gt": t}, + }, + ) if err != nil { return nil, err }