Compare commits

..
4 Commits
Author SHA1 Message Date
gisle 67d6161c3b fix characters not updating on edit post and (hopefully) the bug preventing post deletions sometimes.
continuous-integration/drone/push Build is passing
2021-07-26 20:15:51 +02:00
gisle a606b79736 fix prev logs showing current log.
continuous-integration/drone/push Build is passing
2021-04-11 02:14:01 +02:00
gisle 87559997a9 fix comments create/update not applying character name.
continuous-integration/drone/push Build is passing
2021-04-11 01:49:08 +02:00
gisle b641f7d516 fix ts query getting mad at you for quoting a single word. 2021-04-02 20:25:32 +02:00
7 changed files with 32 additions and 13 deletions
+3 -2
View File
@@ -53,7 +53,7 @@ func (r *commentRepository) Insert(ctx context.Context, comment models.Comment)
CharacterID: comment.CharacterID,
Subject: comment.Subject,
Author: comment.Author,
CharacterName: comment.CharacterID,
CharacterName: comment.CharacterName,
Source: comment.Source,
CreatedDate: comment.CreatedDate.UTC(),
FictionalDate: comment.FictionalDate.UTC(),
@@ -73,7 +73,8 @@ func (r *commentRepository) Update(ctx context.Context, comment models.Comment,
Subject: comment.Subject,
Source: comment.Source,
FictionalDate: comment.FictionalDate.UTC(),
CharacterName: comment.ChapterID,
EditedDate: comment.EditedDate.UTC(),
CharacterName: comment.CharacterName,
CharacterID: comment.CharacterID,
ID: comment.ID,
})
+7 -2
View File
@@ -267,9 +267,14 @@ func (r *postRepository) Delete(ctx context.Context, post models.Post) error {
return err
}
_ = q.GenerateLogTSVector(ctx, post.LogID)
err = tx.Commit()
if err != nil {
return err
}
return tx.Commit()
_ = psqlcore.New(r.db).GenerateLogTSVector(ctx, post.LogID)
return nil
}
func (r *postRepository) post(post psqlcore.SelectPostRow) *models.Post {
+1
View File
@@ -14,6 +14,7 @@ UPDATE story_comment
SET subject = @subject,
source = @source,
fictional_date = @fictional_date,
edited_date = @edited_date,
character_name = @character_name,
character_id = @character_id
WHERE id = @id;
+5 -6
View File
@@ -16,16 +16,15 @@ func TSQueryFromSearch(search string) string {
clearQuotes := false
startQuotes := false
if strings.HasPrefix(token, "\"") {
if len(token) > 1 {
token = token[1:]
}
if strings.HasPrefix(token, "\"") && len(token) > 1 {
startQuotes = true
}
if strings.HasSuffix(token, "\"") {
token = token[:len(token)-1]
if !startQuotes {
clearQuotes = true
}
startQuotes = false
clearQuotes = true
}
token := strings.Trim(token, ",.;:()\"")
+1
View File
@@ -13,6 +13,7 @@ func TestTSQueryFromSearch(t *testing.T) {
{`"asari matron" blue`, `(asari<->matron) & blue`},
{`"christmas present" "wrapping paper"`, `(christmas<->present) & (wrapping<->paper)`},
{`stuff`, `stuff`},
{`"stuff"`, `stuff`},
{`"her slowly, rubbing the back of his head awkwardly. "`, `(her<->slowly<->rubbing<->the<->back<->of<->his<->head<->awkwardly)`},
}
+1
View File
@@ -32,6 +32,7 @@ func (comment *Comment) ApplyUpdate(update CommentUpdate) {
if update.FictionalDate != nil {
comment.FictionalDate = *update.FictionalDate
}
comment.EditedDate = time.Now()
}
// IsChangeObject is an interface implementation to identify it as a valid
+14 -3
View File
@@ -490,12 +490,15 @@ func (s *LogService) EditPost(ctx context.Context, id string, update models.Post
return
}
_, err = s.refreshLogCharacters(ctx, *l, nil, false)
timeout, cancel := context.WithTimeout(context.Background(), time.Minute*10)
defer cancel()
s.changeService.Submit(timeout, models.ChangeModelPost, "edit", true, changekeys.Many(l, post), post)
_, err = s.refreshLogCharacters(timeout, *l, nil, false)
if err != nil {
log.Printf("Failed to update characters in log %s: %s", l.ID, err)
}
s.changeService.Submit(ctx, models.ChangeModelPost, "edit", true, changekeys.Many(l, post), post)
}()
return post, nil
@@ -857,6 +860,10 @@ func (s *LogService) NextLogs(ctx context.Context, log *models.Log) ([]*models.L
return logs[i].Date.Before(logs[j].Date)
})
if len(logs) >= 1 && logs[0].ID == log.ID {
logs = logs[1:]
}
return s.findSuggestions(ctx, log, logs)
}
@@ -868,6 +875,10 @@ func (s *LogService) PrevLogs(ctx context.Context, log *models.Log) ([]*models.L
return nil, err
}
if len(logs) >= 1 && logs[0].ID == log.ID {
logs = logs[1:]
}
return s.findSuggestions(ctx, log, logs)
}