5.10.2: Исправлен сброс прогрессии в null
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:
@@ -434,9 +434,10 @@ type PostponeTaskRequest struct {
|
||||
// ============================================
|
||||
|
||||
type SaveDraftRequest struct {
|
||||
ProgressionValue *float64 `json:"progression_value,omitempty"`
|
||||
ChildrenTaskIDs *[]int `json:"children_task_ids,omitempty"` // только checked подзадачи, nil = не менять
|
||||
AutoComplete *bool `json:"auto_complete,omitempty"` // nil = не менять
|
||||
ProgressionValue *float64 `json:"progression_value,omitempty"`
|
||||
ClearProgressionValue *bool `json:"clear_progression_value,omitempty"` // true = сбросить прогрессию в null
|
||||
ChildrenTaskIDs *[]int `json:"children_task_ids,omitempty"` // только checked подзадачи, nil = не менять
|
||||
AutoComplete *bool `json:"auto_complete,omitempty"` // nil = не менять
|
||||
}
|
||||
|
||||
type TaskDraft struct {
|
||||
@@ -9406,6 +9407,7 @@ func (a *App) saveTaskDraftHandler(w http.ResponseWriter, r *http.Request) {
|
||||
err = tx.QueryRow("SELECT id FROM task_drafts WHERE task_id = $1", taskID).Scan(&draftID)
|
||||
|
||||
var progressionValue sql.NullFloat64
|
||||
clearProgression := req.ClearProgressionValue != nil && *req.ClearProgressionValue
|
||||
if req.ProgressionValue != nil {
|
||||
progressionValue = sql.NullFloat64{Float64: *req.ProgressionValue, Valid: true}
|
||||
}
|
||||
@@ -9434,8 +9436,23 @@ func (a *App) saveTaskDraftHandler(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
// Обновляем существующий драфт
|
||||
// Обновляем только те поля, которые переданы
|
||||
if req.ProgressionValue != nil || req.AutoComplete != nil {
|
||||
if req.AutoComplete != nil {
|
||||
if req.ProgressionValue != nil || req.AutoComplete != nil || clearProgression {
|
||||
if clearProgression {
|
||||
// Сбрасываем прогрессию в null
|
||||
if req.AutoComplete != nil {
|
||||
_, err = tx.Exec(`
|
||||
UPDATE task_drafts
|
||||
SET progression_value = NULL, auto_complete = $1, updated_at = NOW()
|
||||
WHERE id = $2
|
||||
`, *req.AutoComplete, draftID)
|
||||
} else {
|
||||
_, err = tx.Exec(`
|
||||
UPDATE task_drafts
|
||||
SET progression_value = NULL, updated_at = NOW()
|
||||
WHERE id = $1
|
||||
`, draftID)
|
||||
}
|
||||
} else if req.AutoComplete != nil {
|
||||
// Обновляем оба поля
|
||||
_, err = tx.Exec(`
|
||||
UPDATE task_drafts
|
||||
@@ -10055,6 +10072,7 @@ func (a *App) completeTaskAtEndOfDayHandler(w http.ResponseWriter, r *http.Reque
|
||||
err = tx.QueryRow("SELECT id FROM task_drafts WHERE task_id = $1", taskID).Scan(&draftID)
|
||||
|
||||
var progressionValue sql.NullFloat64
|
||||
clearProgression := req.ClearProgressionValue != nil && *req.ClearProgressionValue
|
||||
if req.ProgressionValue != nil {
|
||||
progressionValue = sql.NullFloat64{Float64: *req.ProgressionValue, Valid: true}
|
||||
}
|
||||
@@ -10078,11 +10096,19 @@ func (a *App) completeTaskAtEndOfDayHandler(w http.ResponseWriter, r *http.Reque
|
||||
return
|
||||
} else {
|
||||
// Обновляем существующий драфт с auto_complete = true
|
||||
_, err = tx.Exec(`
|
||||
UPDATE task_drafts
|
||||
SET progression_value = $1, auto_complete = $2, updated_at = NOW()
|
||||
WHERE id = $3
|
||||
`, progressionValue, *req.AutoComplete, draftID)
|
||||
if clearProgression {
|
||||
_, err = tx.Exec(`
|
||||
UPDATE task_drafts
|
||||
SET progression_value = NULL, auto_complete = $1, updated_at = NOW()
|
||||
WHERE id = $2
|
||||
`, *req.AutoComplete, draftID)
|
||||
} else {
|
||||
_, err = tx.Exec(`
|
||||
UPDATE task_drafts
|
||||
SET progression_value = $1, auto_complete = $2, updated_at = NOW()
|
||||
WHERE id = $3
|
||||
`, progressionValue, *req.AutoComplete, draftID)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Error updating draft: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user