Skip to content

Commit

Permalink
Add dateRange always to leaderboard response
Browse files Browse the repository at this point in the history
  • Loading branch information
aaricdev committed Dec 16, 2023
1 parent 505c45f commit dc6e431
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions internal/mock_api/endpoints/bits/leaderboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func getBitsLeaderboard(w http.ResponseWriter, r *http.Request) {
// check if the started_at date is valid and then add it to the start/end range
if period != "all" {
if startedAt == "" {
startedAt = time.Now().Format(time.RFC3339)
w.Write(mock_errors.GetErrorBytes(http.StatusBadRequest, errors.New("Bad Request"), "invalid value provided for started_at"))
w.WriteHeader(http.StatusBadRequest)
return
}

sa, err := time.Parse(time.RFC3339, startedAt)
Expand Down Expand Up @@ -199,12 +201,9 @@ func getBitsLeaderboard(w http.ResponseWriter, r *http.Request) {

length := len(bl)
apiR := models.APIResponse{
Data: bl,
Total: &length,
}

if dateRange.StartedAt != "" {
apiR.DateRange = &dateRange
Data: bl,
DateRange: &dateRange,
Total: &length,
}

body, _ := json.Marshal(apiR)
Expand Down

0 comments on commit dc6e431

Please sign in to comment.