mirror of
https://github.com/acaloiaro/garbagespeak.com
synced 2026-07-21 02:09:48 +00:00
Make garbage_id uplevels non-unique
This commit is contained in:
parent
532b1104dc
commit
620a14f6eb
3 changed files with 9 additions and 2 deletions
|
|
@ -0,0 +1,3 @@
|
|||
DROP INDEX IF EXISTS garbage_id_idx;
|
||||
CREATE INDEX IF NOT EXISTS uplevel_garbage_id_idx ON public.uplevels USING btree (garbage_id);
|
||||
|
||||
|
|
@ -253,15 +253,19 @@ func addUplevelHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
ctx := context.Background()
|
||||
db.QueryRow(ctx,
|
||||
_, err := db.Exec(ctx,
|
||||
"INSERT INTO uplevels(garbage_id, user_id) VALUES ($1, $2)",
|
||||
garbageID,
|
||||
userID)
|
||||
if err != nil {
|
||||
ise(err, w)
|
||||
return
|
||||
}
|
||||
|
||||
garbageUUID, _ := uuid.FromString(garbageID)
|
||||
garbage := Garbage{ID: garbageUUID}
|
||||
tmpl := template.Must(template.ParseFS(partialsFS, "partials/garbage/uplevel_button.tmpl"))
|
||||
err := tmpl.ExecuteTemplate(w, "uplevel_button.tmpl", map[string]any{
|
||||
err = tmpl.ExecuteTemplate(w, "uplevel_button.tmpl", map[string]any{
|
||||
"Garbage": garbage,
|
||||
"ApiBaseUrl": apiURL(),
|
||||
"UserID": userID,
|
||||
|
|
|
|||
Loading…
Reference in a new issue