Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67d6161c3b | ||
|
|
a606b79736 | ||
|
|
87559997a9 | ||
|
|
b641f7d516 |
@@ -53,7 +53,7 @@ func (r *commentRepository) Insert(ctx context.Context, comment models.Comment)
|
|||||||
CharacterID: comment.CharacterID,
|
CharacterID: comment.CharacterID,
|
||||||
Subject: comment.Subject,
|
Subject: comment.Subject,
|
||||||
Author: comment.Author,
|
Author: comment.Author,
|
||||||
CharacterName: comment.CharacterID,
|
CharacterName: comment.CharacterName,
|
||||||
Source: comment.Source,
|
Source: comment.Source,
|
||||||
CreatedDate: comment.CreatedDate.UTC(),
|
CreatedDate: comment.CreatedDate.UTC(),
|
||||||
FictionalDate: comment.FictionalDate.UTC(),
|
FictionalDate: comment.FictionalDate.UTC(),
|
||||||
@@ -73,7 +73,8 @@ func (r *commentRepository) Update(ctx context.Context, comment models.Comment,
|
|||||||
Subject: comment.Subject,
|
Subject: comment.Subject,
|
||||||
Source: comment.Source,
|
Source: comment.Source,
|
||||||
FictionalDate: comment.FictionalDate.UTC(),
|
FictionalDate: comment.FictionalDate.UTC(),
|
||||||
CharacterName: comment.ChapterID,
|
EditedDate: comment.EditedDate.UTC(),
|
||||||
|
CharacterName: comment.CharacterName,
|
||||||
CharacterID: comment.CharacterID,
|
CharacterID: comment.CharacterID,
|
||||||
ID: comment.ID,
|
ID: comment.ID,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -267,9 +267,14 @@ func (r *postRepository) Delete(ctx context.Context, post models.Post) error {
|
|||||||
return err
|
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 {
|
func (r *postRepository) post(post psqlcore.SelectPostRow) *models.Post {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ UPDATE story_comment
|
|||||||
SET subject = @subject,
|
SET subject = @subject,
|
||||||
source = @source,
|
source = @source,
|
||||||
fictional_date = @fictional_date,
|
fictional_date = @fictional_date,
|
||||||
|
edited_date = @edited_date,
|
||||||
character_name = @character_name,
|
character_name = @character_name,
|
||||||
character_id = @character_id
|
character_id = @character_id
|
||||||
WHERE id = @id;
|
WHERE id = @id;
|
||||||
|
|||||||
@@ -16,16 +16,15 @@ func TSQueryFromSearch(search string) string {
|
|||||||
clearQuotes := false
|
clearQuotes := false
|
||||||
startQuotes := false
|
startQuotes := false
|
||||||
|
|
||||||
if strings.HasPrefix(token, "\"") {
|
if strings.HasPrefix(token, "\"") && len(token) > 1 {
|
||||||
if len(token) > 1 {
|
|
||||||
token = token[1:]
|
|
||||||
}
|
|
||||||
startQuotes = true
|
startQuotes = true
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(token, "\"") {
|
if strings.HasSuffix(token, "\"") {
|
||||||
token = token[:len(token)-1]
|
if !startQuotes {
|
||||||
|
clearQuotes = true
|
||||||
|
}
|
||||||
|
|
||||||
startQuotes = false
|
startQuotes = false
|
||||||
clearQuotes = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
token := strings.Trim(token, ",.;:()\"")
|
token := strings.Trim(token, ",.;:()\"")
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ func TestTSQueryFromSearch(t *testing.T) {
|
|||||||
{`"asari matron" blue`, `(asari<->matron) & blue`},
|
{`"asari matron" blue`, `(asari<->matron) & blue`},
|
||||||
{`"christmas present" "wrapping paper"`, `(christmas<->present) & (wrapping<->paper)`},
|
{`"christmas present" "wrapping paper"`, `(christmas<->present) & (wrapping<->paper)`},
|
||||||
{`stuff`, `stuff`},
|
{`stuff`, `stuff`},
|
||||||
|
{`"stuff"`, `stuff`},
|
||||||
{`"her slowly, rubbing the back of his head awkwardly. "`, `(her<->slowly<->rubbing<->the<->back<->of<->his<->head<->awkwardly)`},
|
{`"her slowly, rubbing the back of his head awkwardly. "`, `(her<->slowly<->rubbing<->the<->back<->of<->his<->head<->awkwardly)`},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ func (comment *Comment) ApplyUpdate(update CommentUpdate) {
|
|||||||
if update.FictionalDate != nil {
|
if update.FictionalDate != nil {
|
||||||
comment.FictionalDate = *update.FictionalDate
|
comment.FictionalDate = *update.FictionalDate
|
||||||
}
|
}
|
||||||
|
comment.EditedDate = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsChangeObject is an interface implementation to identify it as a valid
|
// IsChangeObject is an interface implementation to identify it as a valid
|
||||||
|
|||||||
+14
-3
@@ -490,12 +490,15 @@ func (s *LogService) EditPost(ctx context.Context, id string, update models.Post
|
|||||||
return
|
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 {
|
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.changeService.Submit(ctx, models.ChangeModelPost, "edit", true, changekeys.Many(l, post), post)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return post, nil
|
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)
|
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)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(logs) >= 1 && logs[0].ID == log.ID {
|
||||||
|
logs = logs[1:]
|
||||||
|
}
|
||||||
|
|
||||||
return s.findSuggestions(ctx, log, logs)
|
return s.findSuggestions(ctx, log, logs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user