Skip to content

Commit

Permalink
tweaked backend json format
Browse files Browse the repository at this point in the history
  • Loading branch information
euanwm committed Dec 31, 2023
1 parent b56c923 commit 315d846
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions backend/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func Leaderboard(c *gin.Context) {
// @Param enddate query string false "End date to filter to"
// @Accept json
// @Produce json
// @Success 200 {array} []structs.EventsList
// @Success 200 {array} structs.EventsList
// @Failure 204 {object} nil
// @Router /events [options]
func Events(c *gin.Context) {
Expand All @@ -201,20 +201,21 @@ func Events(c *gin.Context) {
// @Param id body string true "ID of the event"
// @Accept json
// @Produce json
// @Success 200 {array} []structs.Entry
// @Success 200 {array} []structs.LeaderboardResponse
// @Failure 204 {object} nil
// @Router /events [post]
func SingleEvent(c *gin.Context) {
var response []structs.Entry
var response structs.LeaderboardResponse
var query structs.SingleEvent
if err := c.BindJSON(&query); err != nil {
abortErr := c.AbortWithError(http.StatusBadRequest, err)
log.Println(abortErr)
return
}

response = dbtools.LoadSingleEvent(query.Federation, query.ID)
if len(response) == 0 {
response.Data = dbtools.LoadSingleEvent(query.Federation, query.ID)
response.Size = len(response.Data)
if response.Size == 0 {
c.JSON(http.StatusNoContent, nil)
return
}
Expand Down

0 comments on commit 315d846

Please sign in to comment.