5.8.0: Окно переноса и логика next_show_at
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m22s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m22s
This commit is contained in:
@@ -7773,9 +7773,9 @@ func (a *App) getTasksHandler(w http.ResponseWriter, r *http.Request) {
|
||||
-- Для невыполненных: сортируем по completed DESC (больше завершений выше), затем по id ASC (раньше добавленные выше)
|
||||
CASE WHEN t.last_completed_at IS NULL OR t.last_completed_at::date < CURRENT_DATE THEN -t.completed ELSE 0 END,
|
||||
CASE WHEN t.last_completed_at IS NULL OR t.last_completed_at::date < CURRENT_DATE THEN t.id ELSE 0 END,
|
||||
-- Для выполненных: сортируем по next_show_at ASC (ранние в начале), NULL значения в начале через COALESCE
|
||||
-- Для выполненных: сортируем по next_show_at ASC (ранние в начале), NULL значения в конце через COALESCE
|
||||
CASE WHEN t.last_completed_at IS NOT NULL AND t.last_completed_at::date >= CURRENT_DATE
|
||||
THEN COALESCE(t.next_show_at, '1970-01-01'::timestamp with time zone)
|
||||
THEN COALESCE(t.next_show_at, '9999-12-31'::timestamp with time zone)
|
||||
ELSE '1970-01-01'::timestamp with time zone
|
||||
END
|
||||
`
|
||||
@@ -8566,12 +8566,21 @@ func (a *App) createTaskHandler(w http.ResponseWriter, r *http.Request) {
|
||||
insertArgs = []interface{}{userID, strings.TrimSpace(req.Name), rewardMessage, progressionBase, repetitionDate.String, wishlistIDValue, rewardPolicyValue, req.GroupName}
|
||||
}
|
||||
} else {
|
||||
// Получаем часовой пояс для задач без повторения
|
||||
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
|
||||
}
|
||||
now := time.Now().In(loc)
|
||||
|
||||
insertSQL = `
|
||||
INSERT INTO tasks (user_id, name, reward_message, progression_base, repetition_period, repetition_date, completed, deleted, wishlist_id, reward_policy, group_name)
|
||||
VALUES ($1, $2, $3, $4, NULL, NULL, 0, FALSE, $5, $6, $7)
|
||||
INSERT INTO tasks (user_id, name, reward_message, progression_base, repetition_period, repetition_date, next_show_at, completed, deleted, wishlist_id, reward_policy, group_name)
|
||||
VALUES ($1, $2, $3, $4, NULL, NULL, $5, 0, FALSE, $6, $7, $8)
|
||||
RETURNING id
|
||||
`
|
||||
insertArgs = []interface{}{userID, strings.TrimSpace(req.Name), rewardMessage, progressionBase, wishlistIDValue, rewardPolicyValue, req.GroupName}
|
||||
insertArgs = []interface{}{userID, strings.TrimSpace(req.Name), rewardMessage, progressionBase, now, wishlistIDValue, rewardPolicyValue, req.GroupName}
|
||||
}
|
||||
|
||||
err = tx.QueryRow(insertSQL, insertArgs...).Scan(&taskID)
|
||||
|
||||
Reference in New Issue
Block a user