Progress on adding game search api
This commit is contained in:
parent
e99c2233fd
commit
17ce28a39b
|
@ -50,10 +50,13 @@ object Search extends LilaController {
|
|||
failure => Ok(html.search.index(failure, none, nbGames)).fuccess,
|
||||
data => data.nonEmptyQuery ?? { query =>
|
||||
env.paginator(query, page) map (_.some)
|
||||
} map { pager =>
|
||||
Ok(_)
|
||||
} map { pager => pager match {
|
||||
case Some(s) => Env.search.jsonView.showResults(s)
|
||||
case None => Ok("Hello World")
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ final class Env(
|
|||
private val Writeable = config getBoolean "writeable"
|
||||
private val Endpoint = config getString "endpoint"
|
||||
|
||||
lazy val jsonView = new JsonView()
|
||||
|
||||
val makeClient = (index: Index) =>
|
||||
if (Enabled) new ESClientHttp(Endpoint, index, Writeable)
|
||||
else new ESClientStub
|
||||
|
|
24
modules/search/src/main/JsonView.scala
Normal file
24
modules/search/src/main/JsonView.scala
Normal file
|
@ -0,0 +1,24 @@
|
|||
package lila.search
|
||||
|
||||
import play.api.libs.json._
|
||||
import play.api.mvc.Result
|
||||
import play.api.mvc.Results._
|
||||
|
||||
import play.api.data._
|
||||
import play.api.data.Forms._
|
||||
|
||||
import lila.common.LightUser
|
||||
import lila.common.paginator._
|
||||
import lila.common.PimpedJson._
|
||||
import lila.game.Game
|
||||
|
||||
final class JsonView() {
|
||||
|
||||
def showResults(pager: Paginator[Game]): Result =
|
||||
Ok(PaginatorJson(pager.mapResults { g =>
|
||||
Json.obj(
|
||||
"id" -> g.id
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
|
@ -135,7 +135,7 @@ object ApplicationBuild extends Build {
|
|||
libraryDependencies ++= Seq(findbugs, spray.caching) ++ provided(play.api, reactivemongo.driver)
|
||||
)
|
||||
|
||||
lazy val search = project("search", Seq(common, hub)).settings(
|
||||
lazy val search = project("search", Seq(common, game, hub)).settings(
|
||||
libraryDependencies ++= provided(play.api)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue