MCPcopy Create free account
hub / github.com/Cawlumm/lyftr / ListPrograms

Method ListPrograms

backend/controllers/programs.go:14–28  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

12 "github.com/go-playground/validator/v10"
13)
14
15// Days/Exercises/Sets in CreateProgramRequest each cap at max=500 independently
16// (models.go), which doesn't bound their product across three nested levels — a
17// request with 500 days x 500 exercises x 500 sets still passes those tags. This
18// struct-level check enforces the total-rows bound (models.MaxProgramRows) that
19// insertProgramDays's single-transaction processing actually needs, since
20// db.DB.SetMaxOpenConns(1) means that transaction holds the process's only SQLite
21// connection for the whole request. Mirrors controllers/workouts.go's init().
22func init() {
23 validate.RegisterStructValidation(func(sl validator.StructLevel) {
24 req := sl.Current().Interface().(models.CreateProgramRequest)
25 total := 0
26 for _, d := range req.Days {
27 total++
28 for _, ex := range d.Exercises {
29 total++
30 total += len(ex.Sets)
31 }

Calls 1

ListMethod · 0.45