fix GetPopularGameInfosHandler
Some checks failed
docker / prepare-and-build (push) Successful in 2m38s
release / goreleaser (push) Has been cancelled

This commit is contained in:
Nite07 2024-11-23 02:47:06 +08:00
parent 4490c817db
commit d91ca35a83

View File

@ -20,7 +20,7 @@ type GetPopularGamesResponse struct {
// @Tags popular
// @Accept json
// @Produce json
// @Param type path string true "Type(igdb-most-visited, igdb-most-wanted-to-play, igdb-most-playing, igdb-most-played, steam-top, v, steam-best-of-the-year, steam-most-played)"
// @Param type path string true "Type(igdb-most-visited, igdb-most-wanted-to-play, igdb-most-playing, igdb-most-played, steam-top, steam-week-top, steam-best-of-the-year, steam-most-played)"
// @Success 200 {object} GetPopularGamesResponse
// @Failure 400 {object} GetPopularGamesResponse
// @Failure 500 {object} GetPopularGamesResponse
@ -68,7 +68,9 @@ func GetPopularGameInfosHandler(c *gin.Context) {
Message: err.Error(),
})
}
if len(infos) > 10 {
infos = infos[:10]
}
} else {
offset := 0
for len(infos) < 10 {
@ -97,8 +99,10 @@ func GetPopularGameInfosHandler(c *gin.Context) {
}
infos = append(infos, newInfos...)
}
if len(infos) > 10 {
infos = infos[:10]
}
}
c.JSON(http.StatusOK, GetPopularGamesResponse{
Status: "ok",
Games: infos,