diff pkg/controllers/imports.go @ 979:7934b5c1a910

Finally enqueue sounding result import job to import jobs. Sends back the id of the job.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 19 Oct 2018 12:14:53 +0200
parents 544a5cfe07cd
children 3c9ea8ab856a
line wrap: on
line diff
--- a/pkg/controllers/imports.go	Thu Oct 18 18:37:19 2018 +0200
+++ b/pkg/controllers/imports.go	Fri Oct 19 12:14:53 2018 +0200
@@ -9,7 +9,9 @@
 	"os"
 	"path/filepath"
 
+	"gemma.intevation.de/gemma/pkg/auth"
 	"gemma.intevation.de/gemma/pkg/config"
+	"gemma.intevation.de/gemma/pkg/imports"
 )
 
 const (
@@ -62,7 +64,20 @@
 		return
 	}
 
-	// TODO: Enqueue job.
+	session, _ := auth.GetSession(req)
+
+	sr := &imports.SoundingResult{
+		Who: session.User,
+		Dir: dir,
+	}
 
-	_ = dir
+	jobID := imports.AddJob(sr)
+	log.Printf("Added job %d\n", jobID)
+
+	result := struct {
+		ID int64 `json:"id"`
+	}{
+		ID: jobID,
+	}
+	SendJSON(rw, http.StatusCreated, &result)
 }