diff pkg/imports/scheduled.go @ 1748:c11807dc6940

Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 10 Jan 2019 14:52:26 +0100
parents 09f51f2b3b0d
children 807569b08513
line wrap: on
line diff
--- a/pkg/imports/scheduled.go	Thu Jan 10 14:33:10 2019 +0100
+++ b/pkg/imports/scheduled.go	Thu Jan 10 14:52:26 2019 +0100
@@ -14,6 +14,8 @@
 package imports
 
 import (
+	"context"
+	"database/sql"
 	"errors"
 	"fmt"
 	"log"
@@ -85,9 +87,20 @@
 	}
 }
 
+// RunConfiguredImportContext runs an import configured from the database.
+func RunConfiguredImportContext(ctx context.Context, conn *sql.Conn, id int64) (int64, error) {
+	cfg, err := LoadIDConfigContext(ctx, conn, id)
+	return runConfiguredImport(id, cfg, err)
+}
+
 // RunConfiguredImport runs an import configured from the database.
 func RunConfiguredImport(id int64) (int64, error) {
 	cfg, err := loadIDConfig(id)
+	return runConfiguredImport(id, cfg, err)
+}
+
+func runConfiguredImport(id int64, cfg *IDConfig, err error) (int64, error) {
+
 	if err != nil {
 		return 0, err
 	}