expose fishnet status - closes #2507
parent
1b854215b9
commit
2060b9bb86
|
@ -61,6 +61,10 @@ object Fishnet extends LilaController {
|
|||
}
|
||||
}
|
||||
|
||||
def status = Action.async {
|
||||
api.status map { Ok(_) }
|
||||
}
|
||||
|
||||
private def ClientAction[A <: JsonApi.Request](f: A => lila.fishnet.Client => Fu[Either[Result, Option[JsonApi.Work]]])(implicit reads: Reads[A]) =
|
||||
Action.async(BodyParsers.parse.tolerantJson) { req =>
|
||||
req.body.validate[A].fold(
|
||||
|
|
|
@ -266,6 +266,7 @@ POST /fishnet/move/$workId<\w{8}> controllers.Fishnet.move(workId: S
|
|||
POST /fishnet/analysis/$workId<\w{8}> controllers.Fishnet.analysis(workId: String)
|
||||
POST /fishnet/abort/$workId<\w{8}> controllers.Fishnet.abort(workId: String)
|
||||
GET /fishnet/key/$key<\w{8}> controllers.Fishnet.keyExists(key: String)
|
||||
GET /fishnet/status controllers.Fishnet.status
|
||||
|
||||
# Pref
|
||||
POST /pref/:name controllers.Pref.set(name: String)
|
||||
|
|
|
@ -139,6 +139,13 @@ final class FishnetApi(
|
|||
def prioritaryAnalysisInProgress(gameId: String): Fu[Option[Work.InProgress]] =
|
||||
repo.getAnalysisByGameId(gameId) map { _.flatMap(_.inProgress) }
|
||||
|
||||
def status = repo.countAnalysis(acquired = false) map { queued =>
|
||||
import play.api.libs.json.Json
|
||||
Json.obj(
|
||||
"analysis" -> Json.obj(
|
||||
"queued" -> queued))
|
||||
}
|
||||
|
||||
private[fishnet] def createClient(userId: Client.UserId, skill: String): Fu[Client] =
|
||||
Client.Skill.byKey(skill).fold(fufail[Client](s"Invalid skill $skill")) { sk =>
|
||||
val client = Client(
|
||||
|
|
Loading…
Reference in New Issue