Browse Source

try fix again again.

master
Gisle Aune 3 years ago
parent
commit
6b1f34db79
  1. 9
      database/postgres/posts.go
  2. 12
      services/logs.go

9
database/postgres/posts.go

@ -4,6 +4,7 @@ import (
"context" "context"
"database/sql" "database/sql"
"errors" "errors"
"fmt"
"git.aiterp.net/rpdata/api/database/postgres/psqlcore" "git.aiterp.net/rpdata/api/database/postgres/psqlcore"
"git.aiterp.net/rpdata/api/internal/generate" "git.aiterp.net/rpdata/api/internal/generate"
"git.aiterp.net/rpdata/api/models" "git.aiterp.net/rpdata/api/models"
@ -255,7 +256,7 @@ func (r *postRepository) Delete(ctx context.Context, post models.Post) error {
err = q.MovePost(ctx, psqlcore.MovePostParams{ID: post.ID, Position: -1}) err = q.MovePost(ctx, psqlcore.MovePostParams{ID: post.ID, Position: -1})
if err != nil { if err != nil {
return err
return fmt.Errorf("pre-delete move failed: %s", err)
} }
err = q.ShiftPostsAfter(ctx, psqlcore.ShiftPostsAfterParams{ err = q.ShiftPostsAfter(ctx, psqlcore.ShiftPostsAfterParams{
@ -264,17 +265,17 @@ func (r *postRepository) Delete(ctx context.Context, post models.Post) error {
FromPosition: int32(post.Position + 1), FromPosition: int32(post.Position + 1),
}) })
if err != nil { if err != nil {
return err
return fmt.Errorf("shift failed: %s", err)
} }
err = q.DeletePost(ctx, post.ID) err = q.DeletePost(ctx, post.ID)
if err != nil { if err != nil {
return err
return fmt.Errorf("delete failed: %s", err)
} }
err = tx.Commit() err = tx.Commit()
if err != nil { if err != nil {
return err
return fmt.Errorf("tx commit failed: %s", err)
} }
_ = psqlcore.New(r.db).GenerateLogTSVector(ctx, post.LogID) _ = psqlcore.New(r.db).GenerateLogTSVector(ctx, post.LogID)

12
services/logs.go

@ -486,17 +486,17 @@ func (s *LogService) EditPost(ctx context.Context, id string, update models.Post
ctx = s.authService.SpinOffContext(ctx) ctx = s.authService.SpinOffContext(ctx)
go func() { go func() {
l, err := s.logs.Find(context.Background(), post.LogID)
ctx, cancel := context.WithTimeout(ctx, time.Minute*10)
defer cancel()
l, err := s.logs.Find(ctx, post.LogID)
if err != nil { if err != nil {
return return
} }
timeout, cancel := context.WithTimeout(context.Background(), time.Minute*10)
defer cancel()
s.changeService.Submit(timeout, models.ChangeModelPost, "edit", true, changekeys.Many(l, post), post)
s.changeService.Submit(ctx, models.ChangeModelPost, "edit", true, changekeys.Many(l, post), post)
_, err = s.refreshLogCharacters(timeout, *l, nil, false)
_, err = s.refreshLogCharacters(ctx, *l, nil, false)
if err != nil { if err != nil {
log.Printf("Failed to update characters in log %s: %s", l.ID, err) log.Printf("Failed to update characters in log %s: %s", l.ID, err)
} }

Loading…
Cancel
Save