Mercurial > gemma
changeset 1495:d26e3e1fcff1
The global import queue already knows which kinds of imports it supports.
So there is no need to have another table to track these as a list.
This is only a thing which can async potentially. So this list is removed.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 04 Dec 2018 18:20:31 +0100 |
parents | 04967d6565fa |
children | 3bf1f0de0763 |
files | pkg/controllers/importqueue.go pkg/imports/kinds.go pkg/imports/queue.go |
diffstat | 3 files changed, 18 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/controllers/importqueue.go Tue Dec 04 17:56:28 2018 +0100 +++ b/pkg/controllers/importqueue.go Tue Dec 04 18:20:31 2018 +0100 @@ -113,7 +113,7 @@ } if ks := req.FormValue("kinds"); ks != "" { - kinds = toTextArray(ks, imports.ImportKindNames) + kinds = toTextArray(ks, imports.ImportKindNames()) } stmt.WriteString(selectImportsSQL)
--- a/pkg/imports/kinds.go Tue Dec 04 17:56:28 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -package imports - -// This is Free Software under GNU Affero General Public License v >= 3.0 -// without warranty, see README.md and license for details. -// -// SPDX-License-Identifier: AGPL-3.0-or-later -// License-Filename: LICENSES/AGPL-3.0.txt -// -// Copyright (C) 2018 by via donau -// – Österreichische Wasserstraßen-Gesellschaft mbH -// Software engineering by Intevation GmbH -// -// Author(s): -// * Sascha L. Teichmann <sascha.teichmann@intevation.de> - -var ImportKindNames = []string{ - string(SRJobKind), -}
--- a/pkg/imports/queue.go Tue Dec 04 17:56:28 2018 +0100 +++ b/pkg/imports/queue.go Tue Dec 04 18:20:31 2018 +0100 @@ -153,11 +153,28 @@ return iqueue.jobCreator(kind) } +func ImportKindNames() []string { + return iqueue.importKindNames() +} + func RegisterJobCreator(kind JobKind, jc JobCreator) { log.Printf("info: register import job creator for kind '%s'\n", kind) iqueue.registerJobCreator(kind, jc) } +func (q *importQueue) importKindNames() []string { + q.creatorsMu.Lock() + defer q.creatorsMu.Unlock() + names := make([]string, len(q.creators)) + var i int + for kind := range q.creators { + names[i] = string(kind) + i++ + } + // XXX: Consider using sort.Strings to make output deterministic. + return names +} + func (q *importQueue) jobCreator(kind JobKind) JobCreator { q.creatorsMu.Lock() defer q.creatorsMu.Unlock()