From b57b0bc901bcd33b38d958175fed518a3016e58f Mon Sep 17 00:00:00 2001 From: poignatov Date: Fri, 9 Jan 2026 13:35:46 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D1=83=20=D0=B2=D1=8B?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20next?= =?UTF-8?q?=5Fshow=5Fat:=20=D0=B4=D0=BB=D1=8F=20repetition=5Fperiod=20-=20?= =?UTF-8?q?=D1=81=D0=B5=D0=B3=D0=BE=D0=B4=D0=BD=D1=8F=D1=88=D0=BD=D1=8F?= =?UTF-8?q?=D1=8F=20=D0=B4=D0=B0=D1=82=D0=B0,=20=D0=B4=D0=BB=D1=8F=20repet?= =?UTF-8?q?ition=5Fdate=20-=20=D1=81=D0=BB=D0=B5=D0=B4=D1=83=D1=8E=D1=89?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BF=D0=BE=D0=B4=D1=85=D0=BE=D0=B4=D1=8F=D1=89?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=B4=D0=B0=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION | 2 +- play-life-backend/main.go | 60 +++++++++++---------------------------- 2 files changed, 17 insertions(+), 45 deletions(-) diff --git a/VERSION b/VERSION index 1545d96..d5c0c99 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.5.0 +3.5.1 diff --git a/play-life-backend/main.go b/play-life-backend/main.go index 933e8a8..d8550e5 100644 --- a/play-life-backend/main.go +++ b/play-life-backend/main.go @@ -6876,28 +6876,14 @@ func (a *App) createTaskHandler(w http.ResponseWriter, r *http.Request) { var insertSQL string var insertArgs []interface{} if repetitionPeriod.Valid { - // Вычисляем next_show_at для задачи с repetition_period - periodStr := strings.TrimSpace(repetitionPeriod.String) - isZeroPeriod := strings.HasPrefix(periodStr, "0 ") || periodStr == "0" - var nextShowAt *time.Time - if !isZeroPeriod { - nextShowAt = calculateNextShowAtFromRepetitionPeriod(repetitionPeriod.String, time.Now()) - } - if nextShowAt != nil { - insertSQL = ` - INSERT INTO tasks (user_id, name, reward_message, progression_base, repetition_period, repetition_date, next_show_at, completed, deleted) - VALUES ($1, $2, $3, $4, $5::INTERVAL, NULL, $6, 0, FALSE) - RETURNING id - ` - insertArgs = []interface{}{userID, strings.TrimSpace(req.Name), rewardMessage, progressionBase, repetitionPeriodValue, nextShowAt} - } else { - insertSQL = ` - INSERT INTO tasks (user_id, name, reward_message, progression_base, repetition_period, repetition_date, completed, deleted) - VALUES ($1, $2, $3, $4, $5::INTERVAL, NULL, 0, FALSE) - RETURNING id - ` - insertArgs = []interface{}{userID, strings.TrimSpace(req.Name), rewardMessage, progressionBase, repetitionPeriodValue} - } + // Для repetition_period выставляем сегодняшнюю дату + now := time.Now() + insertSQL = ` + INSERT INTO tasks (user_id, name, reward_message, progression_base, repetition_period, repetition_date, next_show_at, completed, deleted) + VALUES ($1, $2, $3, $4, $5::INTERVAL, NULL, $6, 0, FALSE) + RETURNING id + ` + insertArgs = []interface{}{userID, strings.TrimSpace(req.Name), rewardMessage, progressionBase, repetitionPeriodValue, now} } else if repetitionDate.Valid { // Вычисляем next_show_at для задачи с repetition_date nextShowAt := calculateNextShowAtFromRepetitionDate(repetitionDate.String, time.Now()) @@ -7149,28 +7135,14 @@ func (a *App) updateTaskHandler(w http.ResponseWriter, r *http.Request) { var updateSQL string var updateArgs []interface{} if repetitionPeriod.Valid { - // Вычисляем next_show_at для задачи с repetition_period - periodStr := strings.TrimSpace(repetitionPeriod.String) - isZeroPeriod := strings.HasPrefix(periodStr, "0 ") || periodStr == "0" - var nextShowAt *time.Time - if !isZeroPeriod { - nextShowAt = calculateNextShowAtFromRepetitionPeriod(repetitionPeriod.String, time.Now()) - } - if nextShowAt != nil { - updateSQL = ` - UPDATE tasks - SET name = $1, reward_message = $2, progression_base = $3, repetition_period = $4::INTERVAL, repetition_date = NULL, next_show_at = $5 - WHERE id = $6 - ` - updateArgs = []interface{}{strings.TrimSpace(req.Name), rewardMessage, progressionBase, repetitionPeriod.String, nextShowAt, taskID} - } else { - updateSQL = ` - UPDATE tasks - SET name = $1, reward_message = $2, progression_base = $3, repetition_period = $4::INTERVAL, repetition_date = NULL, next_show_at = NULL - WHERE id = $5 - ` - updateArgs = []interface{}{strings.TrimSpace(req.Name), rewardMessage, progressionBase, repetitionPeriod.String, taskID} - } + // Для repetition_period выставляем сегодняшнюю дату + now := time.Now() + updateSQL = ` + UPDATE tasks + SET name = $1, reward_message = $2, progression_base = $3, repetition_period = $4::INTERVAL, repetition_date = NULL, next_show_at = $5 + WHERE id = $6 + ` + updateArgs = []interface{}{strings.TrimSpace(req.Name), rewardMessage, progressionBase, repetitionPeriod.String, now, taskID} } else if repetitionDate.Valid { // Вычисляем next_show_at для задачи с repetition_date nextShowAt := calculateNextShowAtFromRepetitionDate(repetitionDate.String, time.Now())