Mercurial > gemma
changeset 2628:53807c3a2de7
Merged.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 13 Mar 2019 16:27:09 +0100 |
parents | 3a242e6aa56d (diff) 50cc5bffd787 (current diff) |
children | 85927d27c84e |
files | |
diffstat | 2 files changed, 30 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/controllers/importqueue.go Wed Mar 13 16:26:14 2019 +0100 +++ b/pkg/controllers/importqueue.go Wed Mar 13 16:27:09 2019 +0100 @@ -31,9 +31,16 @@ ) const ( + warningSQLPrefix = ` +` selectImportsSQL = ` +WITH warned AS ( + SELECT distinct(import_id) AS id + FROM import.import_logs + WHERE kind = 'warn'::log_type +) SELECT - id, + imports.id AS id, state::varchar, enqueued, kind, @@ -41,12 +48,16 @@ signer, summary, EXISTS ( - SELECT true FROM import.import_logs - WHERE kind = 'warn'::log_type AND - import_id = import.imports.id + SELECT true FROM warned + WHERE warned.id = imports.id ) AS has_warnings +` + withoutWarningsSQL = ` FROM import.imports ` + withWarningsSQL = ` +FROM import.imports JOIN warned ON imports.id = warned.id +` selectHasImportSQL = ` SELECT true FROM import.imports WHERE id = $1` @@ -133,6 +144,13 @@ args = append(args, v) } + var warnings bool + + switch warn := strings.ToLower(req.FormValue("warnings")); warn { + case "1", "t", "true": + warnings = true + } + if st := req.FormValue("states"); st != "" { states = toTextArray(st, imports.ImportStateNames) } @@ -146,6 +164,12 @@ } stmt.WriteString(selectImportsSQL) + if warnings { + stmt.WriteString(withWarningsSQL) + } else { + stmt.WriteString(withoutWarningsSQL) + } + if states != nil || kinds != nil || ids != nil { stmt.WriteString(" WHERE ") }