mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-03 11:46:22 -07:00
Finished moving all SQL out of building.go
This commit is contained in:
parent
c45e6f6350
commit
f7f0927ba2
2 changed files with 17 additions and 14 deletions
|
@ -150,28 +150,21 @@ func buildBoardPages(board *Board) (html string) {
|
||||||
var thread Thread
|
var thread Thread
|
||||||
var postsInThread []Post
|
var postsInThread []Post
|
||||||
|
|
||||||
// Get the number of replies to this thread.
|
var replyCount, err = GetReplyCount(op.ID)
|
||||||
queryStr := "SELECT COUNT(*) FROM DBPREFIXposts WHERE thread_id = ? AND parentid = ? AND deleted_timestamp = ?"
|
if err == nil {
|
||||||
|
|
||||||
if err = queryRowSQL(queryStr,
|
|
||||||
[]interface{}{board.ID, op.ID, nilTimestamp},
|
|
||||||
[]interface{}{&thread.NumReplies},
|
|
||||||
); err != nil {
|
|
||||||
return html + gclog.Printf(lErrorLog,
|
return html + gclog.Printf(lErrorLog,
|
||||||
"Error getting replies to /%s/%d: %s",
|
"Error getting replies to /%s/%d: %s",
|
||||||
board.Dir, op.ID, err.Error()) + "<br />"
|
board.Dir, op.ID, err.Error()) + "<br />"
|
||||||
}
|
}
|
||||||
|
thread.NumReplies = replycount
|
||||||
|
|
||||||
// Get the number of image replies in this thread
|
var fileCount, err = GetReplyFileCount(op.ID)
|
||||||
queryStr += " AND filesize <> 0"
|
if err == nil {
|
||||||
if err = queryRowSQL(queryStr,
|
|
||||||
[]interface{}{board.ID, op.ID, op.DeletedTimestamp},
|
|
||||||
[]interface{}{&thread.NumImages},
|
|
||||||
); err != nil {
|
|
||||||
return html + gclog.Printf(lErrorLog,
|
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 />"
|
board.Dir, op.ID, err.Error()) + "<br />"
|
||||||
}
|
}
|
||||||
|
thread.NumImages = fileCount
|
||||||
|
|
||||||
thread.OP = op
|
thread.OP = op
|
||||||
|
|
||||||
|
|
|
@ -151,3 +151,13 @@ func GetRecentPosts(amount int, onlyWithFile bool) (recentPosts []RecentPost) {
|
||||||
|
|
||||||
return recentPostsArr
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue