big ole refactor
This commit is contained in:
@@ -14,15 +14,15 @@ import (
|
||||
// TeamsPage renders the full page with the teams list, for use with GET requests
|
||||
func TeamsPage(
|
||||
s *hws.Server,
|
||||
conn *bun.DB,
|
||||
conn *db.DB,
|
||||
) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
pageOpts := pageOptsFromQuery(s, w, r)
|
||||
if pageOpts == nil {
|
||||
pageOpts, ok := db.GetPageOpts(s, w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var teams *db.List[db.Team]
|
||||
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
|
||||
teams, err = db.ListTeams(ctx, tx, pageOpts)
|
||||
if err != nil {
|
||||
@@ -39,15 +39,15 @@ func TeamsPage(
|
||||
// TeamsList renders just the teams list, for use with POST requests and HTMX
|
||||
func TeamsList(
|
||||
s *hws.Server,
|
||||
conn *bun.DB,
|
||||
conn *db.DB,
|
||||
) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
pageOpts := pageOptsFromForm(s, w, r)
|
||||
if pageOpts == nil {
|
||||
pageOpts, ok := db.GetPageOpts(s, w, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var teams *db.List[db.Team]
|
||||
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
|
||||
teams, err = db.ListTeams(ctx, tx, pageOpts)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user