Mercurial > gemma
changeset 2665:fea12fc850d2 import-overview-rework
Simplified warnings filtering.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 14 Mar 2019 15:44:02 +0100 |
parents | 1a8123b8f75f |
children | 0d2650dd8f62 |
files | pkg/controllers/importqueue.go |
diffstat | 1 files changed, 10 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/controllers/importqueue.go Thu Mar 14 12:45:34 2019 +0100 +++ b/pkg/controllers/importqueue.go Thu Mar 14 15:44:02 2019 +0100 @@ -49,18 +49,9 @@ username, signer, summary IS NOT NULL AS has_summary, - EXISTS ( - SELECT true FROM warned - WHERE warned.id = imports.id - ) AS has_warnings -` - withoutWarningsSQL = ` + imports.id IN (SELECT id FROM warned) AS has_warnings FROM import.imports ` - withWarningsSQL = ` -FROM import.imports JOIN warned ON imports.id = warned.id -` - selectImportSummaySQL = ` SELECT summary FROM import.imports WHERE id = $1` @@ -150,25 +141,18 @@ hasCond bool ) - arg := func(format string, v interface{}) { + arg := func(format string, v ...interface{}) { fmt.Fprintf(&stmt, format, len(args)+1) - args = append(args, v) + args = append(args, v...) } - cond := func(format string, v interface{}) { + cond := func(format string, v ...interface{}) { if hasCond { stmt.WriteString(" AND ") } else { hasCond = true } - arg(format, v) - } - - var warnings bool - - switch warn := strings.ToLower(req.FormValue("warnings")); warn { - case "1", "t", "true": - warnings = true + arg(format, v...) } if st := req.FormValue("states"); st != "" { @@ -184,11 +168,6 @@ } stmt.WriteString(selectImportsSQL) - if warnings { - stmt.WriteString(withWarningsSQL) - } else { - stmt.WriteString(withoutWarningsSQL) - } stmt.WriteString(" WHERE ") @@ -220,6 +199,11 @@ cond(" enqueued <= $%d ", toTime) } + switch warn := strings.ToLower(req.FormValue("warnings")); warn { + case "1", "t", "true": + cond(" id IN (SELECT id FROM warned) ") + } + if !hasCond { stmt.WriteString(" TRUE ") }