Implement get_user_best and get_user_recent in peppyapi
This commit is contained in:
14
common/in.go
14
common/in.go
@@ -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)
|
||||
}
|
||||
|
4
common/osu_time_format.go
Normal file
4
common/osu_time_format.go
Normal 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"
|
Reference in New Issue
Block a user