1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-02 19:16:23 -07:00

Finished moving all SQL out of building.go

This commit is contained in:
comraderat 2020-04-13 17:53:47 +02:00
parent c45e6f6350
commit f7f0927ba2
2 changed files with 17 additions and 14 deletions

View file

@ -150,28 +150,21 @@ func buildBoardPages(board *Board) (html string) {
var thread Thread
var postsInThread []Post
// Get the number of replies to this thread.
queryStr := "SELECT COUNT(*) FROM DBPREFIXposts WHERE thread_id = ? AND parentid = ? AND deleted_timestamp = ?"
if err = queryRowSQL(queryStr,
[]interface{}{board.ID, op.ID, nilTimestamp},
[]interface{}{&thread.NumReplies},
); err != nil {
var replyCount, err = GetReplyCount(op.ID)
if err == nil {
return html + gclog.Printf(lErrorLog,
"Error getting replies to /%s/%d: %s",
board.Dir, op.ID, err.Error()) + "<br />"
}
thread.NumReplies = replycount
// Get the number of image replies in this thread
queryStr += " AND filesize <> 0"
if err = queryRowSQL(queryStr,
[]interface{}{board.ID, op.ID, op.DeletedTimestamp},
[]interface{}{&thread.NumImages},
); err != nil {
var fileCount, err = GetReplyFileCount(op.ID)
if err == nil {
return html + gclog.Printf(lErrorLog,
"Error getting number of image replies to /%s/%d: %s",
"Error getting file count to /%s/%d: %s",
board.Dir, op.ID, err.Error()) + "<br />"
}
thread.NumImages = fileCount
thread.OP = op

View file

@ -151,3 +151,13 @@ func GetRecentPosts(amount int, onlyWithFile bool) (recentPosts []RecentPost) {
return recentPostsArr
}
// GetReplyCount gets the total amount non-deleted of replies in a thread
func GetReplyCount(postID int) (replyCount int, err error) {
}
// GetReplyFileCount gets the amount of files non-deleted posted in total in a thread
func GetReplyFileCount(postID int) (fileCount int, err error) {
}