big ole refactor

This commit is contained in:
2026-02-14 19:48:59 +11:00
parent 0fc3bb0c94
commit 4a2396bca8
66 changed files with 989 additions and 1114 deletions

View File

@@ -12,20 +12,15 @@ import (
)
// AdminUsersPage renders the full admin dashboard page with users section
func AdminUsersPage(s *hws.Server, conn *bun.DB) http.Handler {
func AdminUsersPage(s *hws.Server, conn *db.DB) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
var pageOpts *db.PageOpts
if r.Method == "GET" {
pageOpts = pageOptsFromQuery(s, w, r)
} else {
pageOpts = pageOptsFromForm(s, w, r)
}
if pageOpts == nil {
pageOpts, ok := db.GetPageOpts(s, w, r)
if !ok {
return
}
var users *db.List[db.User]
if ok := db.WithReadTx(s, w, r, conn, func(ctx context.Context, tx bun.Tx) (bool, error) {
if ok := conn.WithReadTx(s, w, r, func(ctx context.Context, tx bun.Tx) (bool, error) {
var err error
users, err = db.GetUsersWithRoles(ctx, tx, pageOpts)
if err != nil {