Mercurial > gemma
comparison 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 |
comparison
equal
deleted
inserted
replaced
978:544a5cfe07cd | 979:7934b5c1a910 |
---|---|
7 "log" | 7 "log" |
8 "net/http" | 8 "net/http" |
9 "os" | 9 "os" |
10 "path/filepath" | 10 "path/filepath" |
11 | 11 |
12 "gemma.intevation.de/gemma/pkg/auth" | |
12 "gemma.intevation.de/gemma/pkg/config" | 13 "gemma.intevation.de/gemma/pkg/config" |
14 "gemma.intevation.de/gemma/pkg/imports" | |
13 ) | 15 ) |
14 | 16 |
15 const ( | 17 const ( |
16 maxSoundingResultSize = 25 * 1024 * 1024 | 18 maxSoundingResultSize = 25 * 1024 * 1024 |
17 soundingResultName = "soundingresult" | 19 soundingResultName = "soundingresult" |
60 log.Printf("error: %v\n", err) | 62 log.Printf("error: %v\n", err) |
61 http.Error(rw, "error: "+err.Error(), http.StatusInternalServerError) | 63 http.Error(rw, "error: "+err.Error(), http.StatusInternalServerError) |
62 return | 64 return |
63 } | 65 } |
64 | 66 |
65 // TODO: Enqueue job. | 67 session, _ := auth.GetSession(req) |
66 | 68 |
67 _ = dir | 69 sr := &imports.SoundingResult{ |
70 Who: session.User, | |
71 Dir: dir, | |
72 } | |
73 | |
74 jobID := imports.AddJob(sr) | |
75 log.Printf("Added job %d\n", jobID) | |
76 | |
77 result := struct { | |
78 ID int64 `json:"id"` | |
79 }{ | |
80 ID: jobID, | |
81 } | |
82 SendJSON(rw, http.StatusCreated, &result) | |
68 } | 83 } |