All 3 in 1
This commit is contained in:
parent
333ca2743d
commit
147274ebcb
@ -9,17 +9,17 @@ import (
|
|||||||
"zxq.co/x/getrank"
|
"zxq.co/x/getrank"
|
||||||
)
|
)
|
||||||
|
|
||||||
type userScore struct {
|
type userScoreAuto struct {
|
||||||
Score
|
Score
|
||||||
Beatmap beatmap `json:"beatmap"`
|
Beatmap beatmap `json:"beatmap"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type userScoresResponse struct {
|
type userScoresResponseAuto struct {
|
||||||
common.ResponseBase
|
common.ResponseBase
|
||||||
Scores []userScore `json:"scores"`
|
Scores []userScoreAuto `json:"scores"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const userScoreSelectBase = `
|
const userScoreSelectBaseAp = `
|
||||||
SELECT
|
SELECT
|
||||||
scores_auto.id, scores_auto.beatmap_md5, scores_auto.score,
|
scores_auto.id, scores_auto.beatmap_md5, scores_auto.score,
|
||||||
scores_auto.max_combo, scores_auto.full_combo, scores_auto.mods,
|
scores_auto.max_combo, scores_auto.full_combo, scores_auto.mods,
|
||||||
@ -50,7 +50,7 @@ func UserScoresBestAPGET(md common.MethodData) common.CodeMessager {
|
|||||||
if getMode(md.Query("mode")) != "ctb" {
|
if getMode(md.Query("mode")) != "ctb" {
|
||||||
mc += " AND scores_auto.pp > 0"
|
mc += " AND scores_auto.pp > 0"
|
||||||
}
|
}
|
||||||
return scoresPuts(md, fmt.Sprintf(
|
return scoresPutsAp(md, fmt.Sprintf(
|
||||||
`WHERE
|
`WHERE
|
||||||
scores_auto.completed = '3'
|
scores_auto.completed = '3'
|
||||||
AND %s
|
AND %s
|
||||||
@ -67,7 +67,7 @@ func UserScoresRecentAPGET(md common.MethodData) common.CodeMessager {
|
|||||||
if cm != nil {
|
if cm != nil {
|
||||||
return *cm
|
return *cm
|
||||||
}
|
}
|
||||||
return scoresPuts(md, fmt.Sprintf(
|
return scoresPutsAp(md, fmt.Sprintf(
|
||||||
`WHERE
|
`WHERE
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
@ -77,16 +77,16 @@ func UserScoresRecentAPGET(md common.MethodData) common.CodeMessager {
|
|||||||
), param)
|
), param)
|
||||||
}
|
}
|
||||||
|
|
||||||
func scoresPuts(md common.MethodData, whereClause string, params ...interface{}) common.CodeMessager {
|
func scoresPutsAp(md common.MethodData, whereClause string, params ...interface{}) common.CodeMessager {
|
||||||
rows, err := md.DB.Query(userScoreSelectBase+whereClause, params...)
|
rows, err := md.DB.Query(userScoreSelectBaseAp+whereClause, params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
md.Err(err)
|
md.Err(err)
|
||||||
return Err500
|
return Err500
|
||||||
}
|
}
|
||||||
var scores []userScore
|
var scores []userScoreAuto
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var (
|
var (
|
||||||
us userScore
|
us userScoreAuto
|
||||||
b beatmap
|
b beatmap
|
||||||
)
|
)
|
||||||
err = rows.Scan(
|
err = rows.Scan(
|
||||||
@ -120,7 +120,7 @@ func scoresPuts(md common.MethodData, whereClause string, params ...interface{})
|
|||||||
))
|
))
|
||||||
scores = append(scores, us)
|
scores = append(scores, us)
|
||||||
}
|
}
|
||||||
r := userScoresResponse{}
|
r := userScoresResponseAuto{}
|
||||||
r.Code = 200
|
r.Code = 200
|
||||||
r.Scores = scores
|
r.Scores = scores
|
||||||
return r
|
return r
|
||||||
|
@ -9,17 +9,17 @@ import (
|
|||||||
"zxq.co/x/getrank"
|
"zxq.co/x/getrank"
|
||||||
)
|
)
|
||||||
|
|
||||||
type userScore struct {
|
type userScoreRx struct {
|
||||||
Score
|
Score
|
||||||
Beatmap beatmap `json:"beatmap"`
|
Beatmap beatmap `json:"beatmap"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type userScoresResponse struct {
|
type userScoresResponseRx struct {
|
||||||
common.ResponseBase
|
common.ResponseBase
|
||||||
Scores []userScore `json:"scores"`
|
Scores []userScoreRx `json:"scores"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const userScoreSelectBase = `
|
const userScoreSelectBaseRelax = `
|
||||||
SELECT
|
SELECT
|
||||||
scores_relax.id, scores_relax.beatmap_md5, scores_relax.score,
|
scores_relax.id, scores_relax.beatmap_md5, scores_relax.score,
|
||||||
scores_relax.max_combo, scores_relax.full_combo, scores_relax.mods,
|
scores_relax.max_combo, scores_relax.full_combo, scores_relax.mods,
|
||||||
@ -50,7 +50,7 @@ func UserScoresBestRelaxGET(md common.MethodData) common.CodeMessager {
|
|||||||
if getMode(md.Query("mode")) != "ctb" {
|
if getMode(md.Query("mode")) != "ctb" {
|
||||||
mc += " AND scores_relax.pp > 0"
|
mc += " AND scores_relax.pp > 0"
|
||||||
}
|
}
|
||||||
return scoresPuts(md, fmt.Sprintf(
|
return scoresPutsRx(md, fmt.Sprintf(
|
||||||
`WHERE
|
`WHERE
|
||||||
scores_relax.completed = '3'
|
scores_relax.completed = '3'
|
||||||
AND %s
|
AND %s
|
||||||
@ -67,7 +67,7 @@ func UserScoresRecentRelaxGET(md common.MethodData) common.CodeMessager {
|
|||||||
if cm != nil {
|
if cm != nil {
|
||||||
return *cm
|
return *cm
|
||||||
}
|
}
|
||||||
return scoresPuts(md, fmt.Sprintf(
|
return scoresPutsRx(md, fmt.Sprintf(
|
||||||
`WHERE
|
`WHERE
|
||||||
%s
|
%s
|
||||||
%s
|
%s
|
||||||
@ -77,16 +77,16 @@ func UserScoresRecentRelaxGET(md common.MethodData) common.CodeMessager {
|
|||||||
), param)
|
), param)
|
||||||
}
|
}
|
||||||
|
|
||||||
func scoresPuts(md common.MethodData, whereClause string, params ...interface{}) common.CodeMessager {
|
func scoresPutsRx(md common.MethodData, whereClause string, params ...interface{}) common.CodeMessager {
|
||||||
rows, err := md.DB.Query(userScoreSelectBase+whereClause, params...)
|
rows, err := md.DB.Query(userScoreSelectBaseRelax+whereClause, params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
md.Err(err)
|
md.Err(err)
|
||||||
return Err500
|
return Err500
|
||||||
}
|
}
|
||||||
var scores []userScore
|
var scores []userScoreRx
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var (
|
var (
|
||||||
us userScore
|
us userScoreRx
|
||||||
b beatmap
|
b beatmap
|
||||||
)
|
)
|
||||||
err = rows.Scan(
|
err = rows.Scan(
|
||||||
@ -120,7 +120,7 @@ func scoresPuts(md common.MethodData, whereClause string, params ...interface{})
|
|||||||
))
|
))
|
||||||
scores = append(scores, us)
|
scores = append(scores, us)
|
||||||
}
|
}
|
||||||
r := userScoresResponse{}
|
r := userScoresResponseRx{}
|
||||||
r.Code = 200
|
r.Code = 200
|
||||||
r.Scores = scores
|
r.Scores = scores
|
||||||
return r
|
return r
|
||||||
|
Loading…
Reference in New Issue
Block a user