From eeb21063146344ae0261a70d6205220e61da8f24 Mon Sep 17 00:00:00 2001 From: Kelly Wong Date: Wed, 20 Mar 2024 22:33:21 +0800 Subject: [PATCH] fixed GET published and draft stories --- model/stories.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/model/stories.go b/model/stories.go index bcade9e..aedb316 100644 --- a/model/stories.go +++ b/model/stories.go @@ -49,8 +49,8 @@ func GetAllStoriesInGroup(db *gorm.DB, groupID *uint) ([]Story, error) { func GetAllPublishedStories(db *gorm.DB, groupID *uint) ([]Story, error) { var stories []Story err := db. - // FIXME: Handle nil case properly - Where(Story{GroupID: groupID, Status: Published}). + Where("status = ?", int(Published)). + Where("group_id = ?", groupID). Preload(clause.Associations). // TODO: Abstract out the sorting logic Order("pin_order ASC NULLS LAST, title ASC, content ASC"). @@ -65,8 +65,8 @@ func GetAllPublishedStories(db *gorm.DB, groupID *uint) ([]Story, error) { func GetAllDraftStories(db *gorm.DB, groupID *uint) ([]Story, error) { var stories []Story err := db. - // FIXME: Handle nil case properly - Where(Story{GroupID: groupID, Status: Draft}). + Where("status = ?", int(Draft)). + Where("group_id = ?", groupID). Preload(clause.Associations). // TODO: Abstract out the sorting logic Order("pin_order ASC NULLS LAST, title ASC, content ASC").