exclude empty dates in date list

This commit is contained in:
Erik Winter 2025-01-05 09:44:26 +01:00
parent a9d5da283d
commit 05ad2aa0f0
2 changed files with 6 additions and 0 deletions

BIN
dist/plan vendored

Binary file not shown.

View File

@ -69,21 +69,27 @@ func (t *SqliteTask) FindMany(params storage.TaskListParams) ([]item.Task, error
args := []interface{}{} args := []interface{}{}
where := make([]string, 0) where := make([]string, 0)
var dateNonEmpty bool
if params.HasRecurrer { if params.HasRecurrer {
where[0] = `recurrer != ''` where[0] = `recurrer != ''`
} }
if !params.From.IsZero() { if !params.From.IsZero() {
where = append(where, `date >= ?`) where = append(where, `date >= ?`)
args = append(args, params.From.String()) args = append(args, params.From.String())
dateNonEmpty = true
} }
if !params.To.IsZero() { if !params.To.IsZero() {
where = append(where, `date <= ?`) where = append(where, `date <= ?`)
args = append(args, params.To.String()) args = append(args, params.To.String())
dateNonEmpty = true
} }
if params.Project != "" { if params.Project != "" {
where = append(where, `project = ?`) where = append(where, `project = ?`)
args = append(args, params.Project) args = append(args, params.Project)
} }
if dateNonEmpty {
where = append(where, `date != ""`)
}
if len(where) > 0 { if len(where) > 0 {
query += ` WHERE ` + where[0] query += ` WHERE ` + where[0]