1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: start and end parameter parsing for wakatime summary route

This commit is contained in:
Ferdinand Mütsch 2021-01-31 18:41:48 +01:00
parent b7ae15496d
commit 28269aa329

View File

@ -69,12 +69,17 @@ func (h *SummariesHandler) loadUserSummaries(r *http.Request) ([]*models.Summary
var start, end time.Time
if rangeParam != "" {
// range param takes precedence
if err, parsedFrom, parsedTo := utils.ResolveInterval(rangeParam); err == nil {
start, end = parsedFrom, parsedTo
} else {
return nil, errors.New("invalid 'range' parameter"), http.StatusBadRequest
}
} else if err, parsedFrom, parsedTo := utils.ResolveInterval(rangeParam); err == nil && start == end {
// also accept start param to be a range param
start, end = parsedFrom, parsedTo
} else {
// eventually, consider start and end params a date
var err error
start, err = time.Parse(time.RFC3339, strings.Replace(startParam, " ", "+", 1))