Skip to content

Commit

Permalink
fix: return score_id on pin endpoints (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsunyoku authored Nov 5, 2023
1 parent 5b83fdc commit 712e110
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/v1/user_scores.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ type userScoresResponse struct {
Scores []userScore `json:"scores"`
}

type pinResponse struct {
common.ResponseBase
ScoreId string `json:"score_id"`
}

const relaxScoreSelectBase = `
SELECT
scores_relax.id, scores_relax.beatmap_md5, scores_relax.score,
Expand Down Expand Up @@ -277,7 +282,10 @@ func pinScore(md common.MethodData, id int64, relax int, userId int) common.Code
return common.SimpleResponse(404, "I'd also like to pin a score I don't have... but I can't.")
}

return common.SimpleResponse(200, "Score pinned.")
r := pinResponse{}
r.Code = 200
r.ScoreId = strconv.FormatInt(id, 10)
return r
}

func unpinScore(md common.MethodData, id int64, relax int, userId int) common.CodeMessager {
Expand All @@ -301,7 +309,10 @@ func unpinScore(md common.MethodData, id int64, relax int, userId int) common.Co
}

md.DB.Exec(fmt.Sprintf("UPDATE %s SET pinned = 0 WHERE id = ?", table), id)
return common.SimpleResponse(200, "Score unpinned.")
r := pinResponse{}
r.Code = 200
r.ScoreId = strconv.FormatInt(id, 10)
return r
}

func scoresPuts(md common.MethodData, whereClause string, params ...interface{}) common.CodeMessager {
Expand Down

0 comments on commit 712e110

Please sign in to comment.