- Added `RestoreMessageHandler` and route at `/account/messages/restore` - Updated `users_messages` table to support `archived_at` reset - Added restore button to archived messages template - Ensures archived messages can be moved back into inbox
27 lines
607 B
Go
27 lines
607 B
Go
package helpers
|
|
|
|
import (
|
|
"database/sql"
|
|
)
|
|
|
|
func GetTotalPages(db *sql.DB, tableName, whereClause string, args []interface{}, pageSize int) (totalPages, totalCount int) {
|
|
query := "SELECT COUNT(*) FROM " + tableName + " " + whereClause
|
|
row := db.QueryRow(query, args...)
|
|
if err := row.Scan(&totalCount); err != nil {
|
|
return 1, 0
|
|
}
|
|
totalPages = (totalCount + pageSize - 1) / pageSize
|
|
if totalPages < 1 {
|
|
totalPages = 1
|
|
}
|
|
return totalPages, totalCount
|
|
}
|
|
|
|
func MakePageRange(current, total int) []int {
|
|
var pages []int
|
|
for i := 1; i <= total; i++ {
|
|
pages = append(pages, i)
|
|
}
|
|
return pages
|
|
}
|