diff --git a/internal/merch/helper.go b/internal/merch/helper.go index 95fdec2..68396e2 100644 --- a/internal/merch/helper.go +++ b/internal/merch/helper.go @@ -3,6 +3,8 @@ package merch import ( "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" + "strconv" + "strings" "time" ) @@ -31,3 +33,12 @@ func getPeriod(days int) time.Time { } return time.Now().UTC().Add(-(time.Duration(days) * time.Hour * 24)) } + +func getDays(c *gin.Context) int { + daysQuery := strings.ToLower(c.Query("days")) + days, err := strconv.Atoi(daysQuery) + if err != nil { + days = 7 + } + return days +}