From a76d1d40cb34a5943dc829a21646d4fc1a2b43a3 Mon Sep 17 00:00:00 2001 From: poignatov Date: Fri, 6 Feb 2026 14:48:39 +0300 Subject: [PATCH] =?UTF-8?q?4.23.1:=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20=D1=81=D0=B1=D1=80=D0=BE=D1=81=20=D0=B4?= =?UTF-8?q?=D0=BD=D0=B5=D0=B2=D0=BD=D1=8B=D1=85=20=D0=B1=D0=B0=D0=BB=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B2=200:00?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION | 2 +- play-life-backend/main.go | 38 ++++++++++++++++++++++++++++++++++---- play-life-web/package.json | 2 +- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index 58fe352..0ef2c60 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.23.0 +4.23.1 diff --git a/play-life-backend/main.go b/play-life-backend/main.go index 2bd8ffb..068eb0e 100644 --- a/play-life-backend/main.go +++ b/play-life-backend/main.go @@ -3068,6 +3068,20 @@ func (a *App) getCurrentWeekScores(userID int) (map[int]float64, error) { // getTodayScores получает сумму score всех нод, созданных сегодня для конкретного пользователя // Возвращает map[project_id]today_score для сегодняшнего дня func (a *App) getTodayScores(userID int) (map[int]float64, error) { + // Получаем часовой пояс из переменной окружения (по умолчанию UTC) + timezoneStr := getEnv("TIMEZONE", "UTC") + loc, err := time.LoadLocation(timezoneStr) + if err != nil { + log.Printf("Warning: Invalid timezone '%s': %v. Using UTC instead.", timezoneStr, err) + loc = time.UTC + timezoneStr = "UTC" + } + + // Вычисляем текущую дату в нужном часовом поясе + now := time.Now().In(loc) + todayStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, loc) + todayEnd := todayStart.Add(24 * time.Hour) + query := ` SELECT n.project_id, @@ -3078,11 +3092,12 @@ func (a *App) getTodayScores(userID int) (map[int]float64, error) { p.deleted = FALSE AND p.user_id = $1 AND n.user_id = $1 - AND DATE(n.created_date) = CURRENT_DATE + AND n.created_date >= $2 + AND n.created_date < $3 GROUP BY n.project_id ` - rows, err := a.DB.Query(query, userID) + rows, err := a.DB.Query(query, userID, todayStart, todayEnd) if err != nil { log.Printf("Error querying today scores: %v", err) return nil, fmt.Errorf("error querying today scores: %w", err) @@ -3106,6 +3121,20 @@ func (a *App) getTodayScores(userID int) (map[int]float64, error) { // getTodayScoresAllUsers получает сумму score всех нод, созданных сегодня для всех пользователей // Возвращает map[project_id]today_score для сегодняшнего дня func (a *App) getTodayScoresAllUsers() (map[int]float64, error) { + // Получаем часовой пояс из переменной окружения (по умолчанию UTC) + timezoneStr := getEnv("TIMEZONE", "UTC") + loc, err := time.LoadLocation(timezoneStr) + if err != nil { + log.Printf("Warning: Invalid timezone '%s': %v. Using UTC instead.", timezoneStr, err) + loc = time.UTC + timezoneStr = "UTC" + } + + // Вычисляем текущую дату в нужном часовом поясе + now := time.Now().In(loc) + todayStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, loc) + todayEnd := todayStart.Add(24 * time.Hour) + query := ` SELECT n.project_id, @@ -3114,11 +3143,12 @@ func (a *App) getTodayScoresAllUsers() (map[int]float64, error) { JOIN projects p ON n.project_id = p.id WHERE p.deleted = FALSE - AND DATE(n.created_date) = CURRENT_DATE + AND n.created_date >= $1 + AND n.created_date < $2 GROUP BY n.project_id ` - rows, err := a.DB.Query(query) + rows, err := a.DB.Query(query, todayStart, todayEnd) if err != nil { log.Printf("Error querying today scores for all users: %v", err) return nil, fmt.Errorf("error querying today scores for all users: %w", err) diff --git a/play-life-web/package.json b/play-life-web/package.json index 69a75c9..38ebd7e 100644 --- a/play-life-web/package.json +++ b/play-life-web/package.json @@ -1,6 +1,6 @@ { "name": "play-life-web", - "version": "4.23.0", + "version": "4.23.1", "type": "module", "scripts": { "dev": "vite",