Mercurial > gemma
comparison pkg/controllers/importqueue.go @ 4196:948e312e87bc
Add flag and filter for imports having errors
Items in the list of imports gain a boolean attribute 'errors' set to
true, if the logs of an import contain any errors.
Using the parameter 'errors=true' in the request to get the list of
imports leads to only entries with errors being returned.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 14 Aug 2019 16:55:46 +0200 |
parents | ad13c581de7c |
children | 1458c9b0fdaa |
comparison
equal
deleted
inserted
replaced
4195:ad13c581de7c | 4196:948e312e87bc |
---|---|
46 kind, | 46 kind, |
47 username, | 47 username, |
48 signer, | 48 signer, |
49 summary IS NOT NULL AS has_summary, | 49 summary IS NOT NULL AS has_summary, |
50 EXISTS(SELECT 1 FROM import.import_logs | 50 EXISTS(SELECT 1 FROM import.import_logs |
51 WHERE kind = 'error'::log_type and import_id = imports.id) AS has_errors, | |
52 EXISTS(SELECT 1 FROM import.import_logs | |
51 WHERE kind = 'warn'::log_type and import_id = imports.id) AS has_warnings | 53 WHERE kind = 'warn'::log_type and import_id = imports.id) AS has_warnings |
52 FROM import.imports | 54 FROM import.imports |
53 WHERE | 55 WHERE |
54 ` | 56 ` |
55 selectEnqueuedSQL = ` | 57 selectEnqueuedSQL = ` |
151 | 153 |
152 switch warn := strings.ToLower(req.FormValue("warnings")); warn { | 154 switch warn := strings.ToLower(req.FormValue("warnings")); warn { |
153 case "1", "t", "true": | 155 case "1", "t", "true": |
154 cond(` EXISTS(SELECT 1 FROM import.import_logs | 156 cond(` EXISTS(SELECT 1 FROM import.import_logs |
155 WHERE kind = 'warn'::log_type and import_id = imports.id)`) | 157 WHERE kind = 'warn'::log_type and import_id = imports.id)`) |
158 } | |
159 | |
160 switch errors := strings.ToLower(req.FormValue("errors")); errors { | |
161 case "1", "t", "true": | |
162 cond(` EXISTS(SELECT 1 FROM import.import_logs | |
163 WHERE kind = 'error'::log_type and import_id = imports.id)`) | |
156 } | 164 } |
157 | 165 |
158 fl := &filledStmt{} | 166 fl := &filledStmt{} |
159 fa := &filledStmt{} | 167 fa := &filledStmt{} |
160 fb := &filledStmt{} | 168 fb := &filledStmt{} |
271 &enqueued, | 279 &enqueued, |
272 &it.Kind, | 280 &it.Kind, |
273 &it.User, | 281 &it.User, |
274 &signer, | 282 &signer, |
275 &it.Summary, | 283 &it.Summary, |
284 &it.Errors, | |
276 &it.Warnings, | 285 &it.Warnings, |
277 ); err != nil { | 286 ); err != nil { |
278 return | 287 return |
279 } | 288 } |
280 if signer.Valid { | 289 if signer.Valid { |