Add reply count to catalog previews. Stage ip count

This commit is contained in:
Dominic Ferrando
2025-04-20 20:24:16 -04:00
parent e3fad65690
commit 1148648aa4
3 changed files with 25 additions and 13 deletions
+8 -7
View File
@@ -226,14 +226,13 @@ func main() {
previews := make([]views.CatalogThreadPreview, 0, len(threads))
for _, thread := range threads {
op, err := database.GetOriginalPost(db, thread.Id)
posts, err := database.GetPosts(db, thread.Id)
if err != nil {
http.Error(w, "Failed to get posts", http.StatusBadRequest)
log.Printf("GetOriginalPost: %v", err)
return
}
log.Printf("OP: %+v", op)
op := posts[0]
if op.MediaPath == "" {
http.Error(w, "Malformed thread", http.StatusInternalServerError)
@@ -242,10 +241,12 @@ func main() {
}
previews = append(previews, views.CatalogThreadPreview{
Subject: thread.Subject,
Body: op.Body,
ThreadURL: fmt.Sprintf("/%s/threads/%d", slug, thread.Id),
MediaPath: op.MediaPath,
Subject: thread.Subject,
Body: op.Body,
ThreadURL: fmt.Sprintf("/%s/threads/%d", slug, thread.Id),
MediaPath: op.MediaPath,
ReplyCount: len(posts),
IpCount: 0, // TODO
})
}