| 28 | for _, ex := range d.Exercises { |
| 29 | total++ |
| 30 | total += len(ex.Sets) |
| 31 | } |
| 32 | } |
| 33 | if total > models.MaxProgramRows { |
| 34 | sl.ReportError(req.Days, "Days", "Days", "maxtotalrows", "") |
| 35 | } |
| 36 | }, models.CreateProgramRequest{}) |
| 37 | } |
| 38 | |
| 39 | func (h *Handler) ListPrograms(c *gin.Context) { |
| 40 | uid := middleware.UserID(c) |
| 41 | f := stores.ProgramFilter{Limit: 20, Query: c.Query("q")} |
| 42 | if l, err := strconv.Atoi(c.Query("limit")); err == nil && l > 0 && l <= 100 { |
| 43 | f.Limit = l |
| 44 | } |
| 45 | if o, err := strconv.Atoi(c.Query("offset")); err == nil && o >= 0 { |
| 46 | f.Offset = o |
| 47 | } |
| 48 | programs, err := h.s.Program.List(uid, f) |
| 49 | if utils.DBError(c, err) { |