Merge branch 'master' into tournamentLeader
* master: add daily crazyhouse to tournament winners leaderboard rename Page functions reorganize content pages Move pages router to save chess960 Adds several new pages
This commit is contained in:
commit
4d40bbc417
|
@ -7,29 +7,37 @@ import views._
|
|||
|
||||
object Page extends LilaController {
|
||||
|
||||
private def page(bookmark: String) = Open { implicit ctx =>
|
||||
OptionOk(Prismic oneShotBookmark bookmark) {
|
||||
private def bookmark(name: String) = Open { implicit ctx =>
|
||||
OptionOk(Prismic oneShotBookmark name) {
|
||||
case (doc, resolver) => views.html.site.page(doc, resolver)
|
||||
}
|
||||
}
|
||||
|
||||
def thanks = page("thanks")
|
||||
def thanks = bookmark("thanks")
|
||||
|
||||
def tos = page("tos")
|
||||
def tos = bookmark("tos")
|
||||
|
||||
def helpLichess = page("help")
|
||||
def contribute = bookmark("help")
|
||||
|
||||
def streamHowTo = page("stream-howto")
|
||||
def streamHowTo = bookmark("stream-howto")
|
||||
|
||||
def contact = page("contact")
|
||||
def contact = bookmark("contact")
|
||||
|
||||
def kingOfTheHill = page("king-of-the-hill")
|
||||
def master = bookmark("master")
|
||||
|
||||
def atomic = page("atomic")
|
||||
def kingOfTheHill = bookmark("king-of-the-hill")
|
||||
|
||||
def racingKings = page("racing-kings")
|
||||
def atomic = bookmark("atomic")
|
||||
|
||||
def crazyhouse = page("crazyhouse")
|
||||
def antichess = bookmark("antichess")
|
||||
|
||||
def privacy = page("privacy")
|
||||
def chess960 = bookmark("chess960")
|
||||
|
||||
def horde = bookmark("horde")
|
||||
|
||||
def racingKings = bookmark("racing-kings")
|
||||
|
||||
def crazyhouse = bookmark("crazyhouse")
|
||||
|
||||
def privacy = bookmark("privacy")
|
||||
}
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
@url = {
|
||||
@variant match {
|
||||
case chess.variant.Standard => {https://en.wikipedia.org/wiki/Chess}
|
||||
case chess.variant.Chess960 => {https://en.wikipedia.org/wiki/Chess960}
|
||||
case chess.variant.Chess960 => {@routes.Page.chess960}
|
||||
case chess.variant.KingOfTheHill => {@routes.Page.kingOfTheHill}
|
||||
case chess.variant.ThreeCheck => {http://en.wikipedia.org/wiki/Three-check_chess}
|
||||
case chess.variant.Antichess => {http://en.wikipedia.org/wiki/Losing_chess}
|
||||
case chess.variant.Antichess => {@routes.Page.antichess}
|
||||
case chess.variant.FromPosition => {@routes.Editor.index?fen=@initialFen.map(_.replace(" ", "_"))}
|
||||
case chess.variant.Atomic => {@routes.Page.atomic}
|
||||
case chess.variant.Horde => {http://en.wikipedia.org/wiki/Dunsany%27s_chess#Horde_variant}
|
||||
case chess.variant.Horde => {@routes.Page.horde}
|
||||
case chess.variant.RacingKings => {@routes.Page.racingKings}
|
||||
case chess.variant.Crazyhouse => {@routes.Page.crazyhouse}
|
||||
case _ => {}
|
||||
|
|
32
conf/routes
32
conf/routes
|
@ -387,24 +387,32 @@ GET /network/stream controllers.WorldMap.stream
|
|||
POST /mobile/register/:platform/:deviceId controllers.Main.mobileRegister(platform: String, deviceId: String)
|
||||
POST /mobile/unregister controllers.Main.mobileUnregister
|
||||
|
||||
# Pages
|
||||
GET /thanks controllers.Page.thanks
|
||||
GET /help-lichess controllers.Page.helpLichess
|
||||
GET /terms-of-service controllers.Page.tos
|
||||
GET /how-to-stream-on-lichess controllers.Page.streamHowTo
|
||||
GET /contact controllers.Page.contact
|
||||
GET /king-of-the-hill controllers.Page.kingOfTheHill
|
||||
GET /atomic controllers.Page.atomic
|
||||
GET /racing-kings controllers.Page.racingKings
|
||||
GET /crazyhouse controllers.Page.crazyhouse
|
||||
GET /privacy controllers.Page.privacy
|
||||
|
||||
# Donate
|
||||
GET /donate controllers.Donation.index
|
||||
GET /donate/thanks controllers.Donation.thanks
|
||||
POST /donate/thanks controllers.Donation.thanksRedirect
|
||||
POST /donate/ipn controllers.Donation.ipn
|
||||
|
||||
# Pages
|
||||
GET /thanks controllers.Page.thanks
|
||||
GET /terms-of-service controllers.Page.tos
|
||||
GET /privacy controllers.Page.privacy
|
||||
GET /contact controllers.Page.contact
|
||||
|
||||
# Variants
|
||||
GET /variant/king-of-the-hill controllers.Page.kingOfTheHill
|
||||
GET /variant/atomic controllers.Page.atomic
|
||||
GET /variant/antichess controllers.Page.antichess
|
||||
GET /variant/chess960 controllers.Page.chess960
|
||||
GET /variant/horde controllers.Page.horde
|
||||
GET /variant/racing-kings controllers.Page.racingKings
|
||||
GET /variant/crazyhouse controllers.Page.crazyhouse
|
||||
|
||||
# Help
|
||||
GET /help/contribute controllers.Page.contribute
|
||||
GET /help/master controllers.Page.master
|
||||
GET /help/stream-on-lichess controllers.Page.streamHowTo
|
||||
|
||||
POST /jslog/$id<\w{12}> controllers.Main.jslog(id)
|
||||
|
||||
# Assets
|
||||
|
|
|
@ -124,7 +124,7 @@ object PlayerRepo {
|
|||
b += (u.get.asInstanceOf[BSONString].value -> r)
|
||||
r = r + 1
|
||||
}
|
||||
b.result()
|
||||
b.result
|
||||
case _ => Map.empty
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package lila.tournament
|
|||
|
||||
import org.joda.time.DateTime
|
||||
import reactivemongo.bson.{ BSONDocument, BSONArray, BSONInteger }
|
||||
import chess.variant.Variant
|
||||
|
||||
import BSONHandlers._
|
||||
import lila.common.paginator.Paginator
|
||||
|
@ -25,7 +26,7 @@ object TournamentRepo {
|
|||
private val unfinishedSelect = BSONDocument("status" -> BSONDocument("$ne" -> Status.Finished.id))
|
||||
private[tournament] val scheduledSelect = BSONDocument("schedule" -> BSONDocument("$exists" -> true))
|
||||
private def sinceSelect(date: DateTime) = BSONDocument("startsAt" -> BSONDocument("$gt" -> date))
|
||||
private def variantSelect(variant: chess.variant.Variant) =
|
||||
private def variantSelect(variant: Variant) =
|
||||
if (variant.standard) BSONDocument("variant" -> BSONDocument("$exists" -> false))
|
||||
else BSONDocument("variant" -> variant.id)
|
||||
|
||||
|
@ -187,13 +188,18 @@ object TournamentRepo {
|
|||
}._1.reverse
|
||||
}
|
||||
|
||||
def lastFinishedScheduledByFreqStandard(freq: Schedule.Freq, since: DateTime): Fu[List[Tournament]] = coll.find(
|
||||
def lastFinishedScheduledByFreq(freq: Schedule.Freq, since: DateTime): Fu[List[Tournament]] = coll.find(
|
||||
finishedSelect ++ sinceSelect(since) ++ variantSelect(chess.variant.Standard) ++ BSONDocument(
|
||||
"schedule.freq" -> freq.name,
|
||||
"schedule.speed" -> BSONDocument("$in" -> Schedule.Speed.mostPopular.map(_.name))
|
||||
)
|
||||
).sort(BSONDocument("startsAt" -> -1)).toList[Tournament](Schedule.Speed.mostPopular.size.some)
|
||||
|
||||
def lastFinishedDaily(variant: Variant): Fu[Option[Tournament]] = coll.find(
|
||||
finishedSelect ++ sinceSelect(DateTime.now minusDays 1) ++ variantSelect(variant) ++
|
||||
BSONDocument("schedule.freq" -> Schedule.Freq.Daily.name)
|
||||
).sort(BSONDocument("startsAt" -> -1)).one[Tournament]
|
||||
|
||||
def update(tour: Tournament) = coll.update(BSONDocument("_id" -> tour.id), tour)
|
||||
|
||||
def insert(tour: Tournament) = coll.insert(tour)
|
||||
|
|
|
@ -21,9 +21,11 @@ final class Winners(
|
|||
import Schedule.Freq
|
||||
private def fetchScheduled(nb: Int): Fu[List[Winner]] = {
|
||||
val since = DateTime.now minusMonths 1
|
||||
List(Freq.Marathon, Freq.Monthly, Freq.Weekly, Freq.Daily).map { freq =>
|
||||
TournamentRepo.lastFinishedScheduledByFreqStandard(freq, since) flatMap toursToWinners
|
||||
}.sequenceFu.map(_.flatten)
|
||||
List(Freq.Monthly, Freq.Weekly, Freq.Daily).map { freq =>
|
||||
TournamentRepo.lastFinishedScheduledByFreq(freq, since)
|
||||
}.sequenceFu.map(_.flatten) flatMap { stds =>
|
||||
TournamentRepo.lastFinishedDaily(chess.variant.Crazyhouse) map (stds ::: _.toList)
|
||||
} flatMap toursToWinners
|
||||
}
|
||||
|
||||
private def toursToWinners(tours: List[Tournament]): Fu[List[Winner]] =
|
||||
|
|
Loading…
Reference in a new issue