# HG changeset patch # User Sascha L. Teichmann # Date 1552490829 -3600 # Node ID 53807c3a2de71a8e5faf0f645351c21348ea12f2 # Parent 3a242e6aa56dc89101012f6d4db9d6fcded1ba65# Parent 50cc5bffd7874a72c723428370bbfd0a9565a90a Merged. diff -r 50cc5bffd787 -r 53807c3a2de7 pkg/controllers/importqueue.go --- 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 ") } diff -r 50cc5bffd787 -r 53807c3a2de7 schema/gemma.sql --- a/schema/gemma.sql Wed Mar 13 16:26:14 2019 +0100 +++ b/schema/gemma.sql Wed Mar 13 16:27:09 2019 +0100 @@ -723,6 +723,8 @@ msg TEXT NOT NULL ) + CREATE INDEX kind_idx ON import_logs(kind) + CREATE TABLE track_imports ( import_id int NOT NULL REFERENCES imports(id) ON DELETE CASCADE,