add and refine thunderball results page

This commit is contained in:
2025-03-25 14:47:41 +00:00
parent f1ad9757ba
commit 0b93fd75dd
12 changed files with 375 additions and 28 deletions

18
helpers/pagination.go Normal file
View File

@@ -0,0 +1,18 @@
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
}