Skip to content

Commit

Permalink
[server/list] Support for 1000 activities in table
Browse files Browse the repository at this point in the history
  • Loading branch information
jylitalo committed Dec 22, 2024
1 parent fc23741 commit f53d5f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion server/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func newListFormData() ListFormData {
Types: map[string]bool{},
WorkoutTypes: map[string]bool{},
Years: map[int]bool{},
Limit: 100,
Limit: 1000,
}
}

Expand Down Expand Up @@ -68,6 +68,7 @@ func listPost(ctx context.Context, page *Page, db Storage) func(c echo.Context)
limit, errL := strconv.Atoi(c.FormValue("limit"))
name := c.FormValue("name")
if err = errors.Join(errV, errT, errW, errY, errL); err != nil {
slog.Error("server.listPost()", "err", err)
_ = telemetry.Error(span, err)
}
slog.Info("POST /list", "values", values)
Expand Down
6 changes: 3 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"html/template"
"io"
"log/slog"
"net/url"
"slices"
"strconv"
Expand Down Expand Up @@ -173,6 +172,7 @@ func yearValues(values url.Values) (map[int]bool, error) {
years[y] = (len(v) > 0 && v[0] == "on")
}
}
// slog.Info("server.yearValues", "years", years)
return years, nil
}

Expand Down Expand Up @@ -221,7 +221,6 @@ func Start(ctx context.Context, db Storage, selectedTypes []string, port int) er
value = false
}
span.End()
slog.Info("starting things", "page", page)

e.GET("/", indexGet(ctx, page, db))
e.POST("/best", bestPost(ctx, page, db))
Expand All @@ -247,8 +246,9 @@ func indexGet(ctx context.Context, page *Page, db Storage) func(c echo.Context)
types := selectedTypes(pf.Types)
workoutTypes := selectedWorkoutTypes(pf.WorkoutTypes)
years := selectedYears(pf.Years)
plfYears := selectedYears(page.List.Form.Years)
pld := &page.List.Data
pld.Headers, pld.Rows, errL = stats.List(ctx, db, types, workoutTypes, years, page.List.Form.Limit, "")
pld.Headers, pld.Rows, errL = stats.List(ctx, db, types, workoutTypes, plfYears, page.List.Form.Limit, "")
// init Top tab
tf := &page.Top.Form
td := &page.Top.Data
Expand Down
1 change: 1 addition & 0 deletions server/views/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<option{{ if eq .Limit 10 }} selected{{ end }}>10</option>
<option{{ if eq .Limit 20 }} selected{{ end }}>20</option>
<option{{ if eq .Limit 100 }} selected{{ end }}>100</option>
<option{{ if eq .Limit 1000 }} selected{{ end }}>1000</option>
</select>
</div>
</form>
Expand Down

0 comments on commit f53d5f6

Please sign in to comment.