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:
parent
b7ae15496d
commit
28269aa329
@ -69,12 +69,17 @@ func (h *SummariesHandler) loadUserSummaries(r *http.Request) ([]*models.Summary
|
|||||||
|
|
||||||
var start, end time.Time
|
var start, end time.Time
|
||||||
if rangeParam != "" {
|
if rangeParam != "" {
|
||||||
|
// range param takes precedence
|
||||||
if err, parsedFrom, parsedTo := utils.ResolveInterval(rangeParam); err == nil {
|
if err, parsedFrom, parsedTo := utils.ResolveInterval(rangeParam); err == nil {
|
||||||
start, end = parsedFrom, parsedTo
|
start, end = parsedFrom, parsedTo
|
||||||
} else {
|
} else {
|
||||||
return nil, errors.New("invalid 'range' parameter"), http.StatusBadRequest
|
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 {
|
} else {
|
||||||
|
// eventually, consider start and end params a date
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
start, err = time.Parse(time.RFC3339, strings.Replace(startParam, " ", "+", 1))
|
start, err = time.Parse(time.RFC3339, strings.Replace(startParam, " ", "+", 1))
|
||||||
|
Loading…
Reference in New Issue
Block a user