Implement get_user_best and get_user_recent in peppyapi

This commit is contained in:
Howl
2016-05-28 20:24:39 +02:00
parent db323908ac
commit 6a374a4f9d
8 changed files with 129 additions and 5 deletions

View File

@@ -1,8 +1,10 @@
package common
import "strconv"
// In picks x if y < x, picks z if y > z, or if none of the previous
// conditions is satisfies, it simply picks y.
func In(x, y, z int) {
func In(x, y, z int) int {
switch {
case y < x:
return x
@@ -11,3 +13,13 @@ func In(x, y, z int) {
}
return y
}
// InString takes y as a string, also allows for a default value should y be
// invalid as a number.
func InString(x int, y string, z, def int) int {
num, err := strconv.Atoi(y)
if err != nil {
return def
}
return In(x, num, z)
}

View File

@@ -0,0 +1,4 @@
package common
// OsuTimeFormat is the time format for scores in the DB. Can be used with time.Parse etc.
const OsuTimeFormat = "060102150405"