Add beatmap rank requests
This commit is contained in:
@@ -22,6 +22,9 @@ type Conf struct {
|
||||
BeatmapRequestsPerUser int
|
||||
RankQueueSize int
|
||||
OsuAPIKey string
|
||||
RedisAddr string
|
||||
RedisPassword string
|
||||
RedisDB int
|
||||
}
|
||||
|
||||
var cachedConf *Conf
|
||||
@@ -43,6 +46,7 @@ func Load() (c Conf, halt bool) {
|
||||
HanayoKey: "Potato",
|
||||
BeatmapRequestsPerUser: 2,
|
||||
RankQueueSize: 25,
|
||||
RedisAddr: "localhost:6379",
|
||||
}, "api.conf")
|
||||
fmt.Println("Please compile the configuration file (api.conf).")
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/DataDog/datadog-go/statsd"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"gopkg.in/redis.v5"
|
||||
)
|
||||
|
||||
// MethodData is a struct containing the data passed over to an API method.
|
||||
@@ -15,6 +16,7 @@ type MethodData struct {
|
||||
RequestData RequestData
|
||||
C *gin.Context
|
||||
Doggo *statsd.Client
|
||||
R *redis.Client
|
||||
}
|
||||
|
||||
// Err logs an error into gin.
|
||||
|
@@ -5,6 +5,7 @@ package common
|
||||
type WhereClause struct {
|
||||
Clause string
|
||||
Params []interface{}
|
||||
useOr bool
|
||||
}
|
||||
|
||||
// Where adds a new WHERE clause to the WhereClause.
|
||||
@@ -26,10 +27,26 @@ func (w *WhereClause) addWhere() {
|
||||
if w.Clause == "" {
|
||||
w.Clause += "WHERE "
|
||||
} else {
|
||||
if w.useOr {
|
||||
w.Clause += " OR "
|
||||
return
|
||||
}
|
||||
w.Clause += " AND "
|
||||
}
|
||||
}
|
||||
|
||||
// Or enables using OR instead of AND
|
||||
func (w *WhereClause) Or() *WhereClause {
|
||||
w.useOr = true
|
||||
return w
|
||||
}
|
||||
|
||||
// And enables using AND instead of OR
|
||||
func (w *WhereClause) And() *WhereClause {
|
||||
w.useOr = false
|
||||
return w
|
||||
}
|
||||
|
||||
// In generates an IN clause.
|
||||
// initial is the initial part, e.g. "users.id".
|
||||
// Fields are the possible values.
|
||||
|
Reference in New Issue
Block a user