From 87559997a9de6e78dc56c9e062d8f0b8fbf98913 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Sun, 11 Apr 2021 01:49:08 +0200 Subject: [PATCH] fix comments create/update not applying character name. --- database/postgres/comments.go | 5 +++-- database/postgres/queries/comments.sql | 1 + models/comment.go | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/database/postgres/comments.go b/database/postgres/comments.go index f76ab4a..dc77561 100644 --- a/database/postgres/comments.go +++ b/database/postgres/comments.go @@ -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, }) diff --git a/database/postgres/queries/comments.sql b/database/postgres/queries/comments.sql index 2d8048c..2b2c865 100644 --- a/database/postgres/queries/comments.sql +++ b/database/postgres/queries/comments.sql @@ -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; diff --git a/models/comment.go b/models/comment.go index 7ed3132..a7127f6 100644 --- a/models/comment.go +++ b/models/comment.go @@ -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