aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrtz12 <koenig@fagott.pw>2016-11-15 20:08:22 (UTC)
committerrtz12 <koenig@fagott.pw>2016-11-15 20:08:22 (UTC)
commit1d8f9871455ac4e7a124b82a24a31ed18ed961aa (patch)
treedb1b4803603a12f0b884ded57e1fcba6a393a25f
parentf4a485fe8227b98c417f1ecb52251fb2a9638911 (diff)
Alles in einem, weil wegen Race-Conditions
-rw-r--r--modules/lists/lists.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/modules/lists/lists.go b/modules/lists/lists.go
index 05baf4a..ada4c4b 100644
--- a/modules/lists/lists.go
+++ b/modules/lists/lists.go
@@ -537,13 +537,9 @@ func (m *Module) addGrilToList(w http.ResponseWriter, r *http.Request, p httprou
537 return 537 return
538 } 538 }
539 539
540 rank := 0
541 if len(list.Grils) > 0 {
542 rank = list.Grils[len(list.Grils)-1].Order + 1
543 }
544
545 // rein in die DB damit 540 // rein in die DB damit
546 _, err = m.g.DB.Exec(`INSERT INTO grilist.lists_grils(list_id, gril_id, "order") VALUES($1, $2, $3)`, listID, grilID, rank) 541 _, err = m.g.DB.Exec(`INSERT INTO grilist.lists_grils(list_id, gril_id, "order")
542 VALUES($1, $2, (SELECT count(gril_id) FROM grilist.lists_grils WHERE list_id = $1));`, listID, grilID)
547 if err != nil { 543 if err != nil {
548 log.Println("error inserting gril into list:", err) 544 log.Println("error inserting gril into list:", err)
549 http.Error(w, "could not insert gril", 500) 545 http.Error(w, "could not insert gril", 500)