mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-09-11 15:56:22 -07:00
Add ability to update thread attributes from manage page
This commit is contained in:
parent
0f0c9362eb
commit
34cab06311
5 changed files with 174 additions and 70 deletions
|
@ -86,21 +86,28 @@ func GetTopPostInThread(postID int) (int, error) {
|
|||
return id, err
|
||||
}
|
||||
|
||||
func GetTopPostIDsInThreadIDs(threads ...interface{}) ([]int, error) {
|
||||
// GetTopPostIDsInThreadIDs takes a variable number of threads and returns a map[threadID]topPostID
|
||||
func GetTopPostIDsInThreadIDs(threads ...interface{}) (map[interface{}]int, error) {
|
||||
ids := make(map[interface{}]int)
|
||||
if threads == nil {
|
||||
return ids, nil
|
||||
}
|
||||
params := createArrayPlaceholder(threads)
|
||||
query := `SELECT id FROM DBPREFIXposts WHERE thread_id in ` + params
|
||||
query := `SELECT id FROM DBPREFIXposts WHERE thread_id in ` + params + " AND is_top_post"
|
||||
rows, err := QuerySQL(query, threads...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var ids []int
|
||||
var i int
|
||||
for rows.Next() {
|
||||
var id int
|
||||
if err = rows.Scan(&id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ids = append(ids, id)
|
||||
|
||||
ids[threads[i]] = id
|
||||
i++
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue