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