fix: compute work hours from events at runtime; add Achievements button to RPG view

This commit is contained in:
2026-06-25 02:08:33 +03:30
parent 85587d563d
commit 4fcb694418
3 changed files with 104 additions and 9 deletions

View File

@@ -73,7 +73,8 @@ func (h *Handler) clockOut(chatID int64) (string, error) {
streak, _ := h.updateStreak(user.ID, today, true)
xp, leveledUp, newLevel, _ := h.computeAndAwardXP(user.ID, sessionWork, streak, today)
stats, _ := h.DB.GetOrCreateRPGStats(user.ID)
unlocked := h.checkAchievements(user.ID, stats, sessionWork, today, isWeekend)
totalHours := float64(h.totalWorkSeconds(user.ID, loc)) / secondsPerHour
unlocked := h.checkAchievements(user.ID, stats, sessionWork, today, isWeekend, totalHours)
text += fmt.Sprintf("\n\n+%d XP (Lv.%d)", xp, newLevel)
if leveledUp {