21999cd7c6
Tweaked the preparser to hopefully fix a few problems with the WYSIWYG Editor. Added BulkGetCopy to the ForumStores. Added InternalErrorXML and SilentInternalErrorXML. Tweaked the element queries so that the topic titles aren't truncated too short. Began refactoring the topic list logic, more to come here.
36 lines
894 B
Go
36 lines
894 B
Go
package common
|
|
|
|
import "strconv"
|
|
import "../query_gen/lib"
|
|
|
|
// Internal. Don't rely on it.
|
|
func ForumListToArgQ(forums []Forum) (argList []interface{}, qlist string) {
|
|
for _, forum := range forums {
|
|
argList = append(argList, strconv.Itoa(forum.ID))
|
|
qlist += "?,"
|
|
}
|
|
if qlist != "" {
|
|
qlist = qlist[0 : len(qlist)-1]
|
|
}
|
|
return argList, qlist
|
|
}
|
|
|
|
// Internal. Don't rely on it.
|
|
func ArgQToTopicCount(argList []interface{}, qlist string) (topicCount int, err error) {
|
|
topicCountStmt, err := qgen.Builder.SimpleCount("topics", "parentID IN("+qlist+")", "")
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
defer topicCountStmt.Close()
|
|
|
|
err = topicCountStmt.QueryRow(argList...).Scan(&topicCount)
|
|
if err != nil && err != ErrNoRows {
|
|
return 0, err
|
|
}
|
|
return topicCount, err
|
|
}
|
|
|
|
func TopicCountInForums(forums []Forum) (topicCount int, err error) {
|
|
return ArgQToTopicCount(ForumListToArgQ(forums))
|
|
}
|