annotate pkg/controllers/statsupdates.go @ 5415:4ad68ab239b7 marking-single-beam

Factored creation of default class breaks in SR import to be reused with markings, too.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 07 Jul 2021 12:01:28 +0200
parents fc3a5345b0fd
children 5f47eeea988d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5386
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 // This is Free Software under GNU Affero General Public License v >= 3.0
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2 // without warranty, see README.md and license for details.
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 //
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 // SPDX-License-Identifier: AGPL-3.0-or-later
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 // License-Filename: LICENSES/AGPL-3.0.txt
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 //
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 // Copyright (C) 2021 by via donau
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 // Software engineering by Intevation GmbH
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 //
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 // Author(s):
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 package controllers
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import (
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 "database/sql"
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 "log"
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 "net/http"
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 mw "gemma.intevation.de/gemma/pkg/middleware"
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 "github.com/gorilla/mux"
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 )
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 const (
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 listStatsUpdatesSQL = `SELECT name FROM sys_admin.stats_updates ORDER BY name`
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 statsUpdatesScriptSQL = `SELECT script FROM sys_admin.stats_updates WHERE name = $1`
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 )
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 func listStatsUpdates(req *http.Request) (jr mw.JSONResult, err error) {
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 ctx := req.Context()
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 conn := mw.JSONConn(req)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 rows, err2 := conn.QueryContext(ctx, listStatsUpdatesSQL)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 if err2 != nil {
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 log.Printf("error: %v\n", err2)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 err = mw.JSONError{
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 Code: http.StatusInternalServerError,
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 Message: "Listing stats update failed.",
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 return
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 defer rows.Close()
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 names := []string{}
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 for rows.Next() {
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 var name string
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 if err2 := rows.Scan(&name); err2 != nil {
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 log.Printf("error: %v\n", err2)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 err = mw.JSONError{
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 Code: http.StatusInternalServerError,
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 Message: "Fetching stats update names failed.",
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 return
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 names = append(names, name)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 if err2 := rows.Err(); err2 != nil {
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 log.Printf("error: %v\n", err2)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 err = mw.JSONError{
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 Code: http.StatusInternalServerError,
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 Message: "Fetching stats update names failed.",
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 return
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 out := struct {
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 StatsUpdates []string `json:"stats-updates"`
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 }{
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 StatsUpdates: names,
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 jr = mw.JSONResult{Result: out}
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 return
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 func statsUpdates(req *http.Request) (jr mw.JSONResult, err error) {
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 name := mux.Vars(req)["name"]
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 ctx := req.Context()
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 conn := mw.JSONConn(req)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 var script string
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 err2 := conn.QueryRowContext(ctx, statsUpdatesScriptSQL, name).Scan(&script)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 switch {
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 case err2 == sql.ErrNoRows:
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89 err = mw.JSONError{
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 Code: http.StatusNotFound,
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 Message: "No such update script.",
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 return
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 case err2 != nil:
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 log.Printf("error: %v\n", err2)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 err = mw.JSONError{
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 Code: http.StatusInternalServerError,
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 Message: "Loading update script failed.",
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 return
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 if _, err2 := conn.ExecContext(ctx, script); err2 != nil {
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 log.Printf("error: %v\n", err2)
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 err = mw.JSONError{
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 Code: http.StatusInternalServerError,
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 Message: "Loading update script failed.",
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 return
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 }
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 jr = mw.JSONResult{Result: map[string]interface{}{}}
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 return
fc3a5345b0fd Added enpoint /api/data/stats-updates to list and trigger the stats update scripts. sys_admin only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114 }