forked from lichess-org/lila
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
303 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package lila.forum | ||
|
||
private object BSONHandlers { | ||
|
||
import lila.db.BSON.BSONJodaDateTimeHandler | ||
implicit val CategBSONHandler = reactivemongo.bson.Macros.handler[Categ] | ||
implicit val TopicBSONHandler = reactivemongo.bson.Macros.handler[Topic] | ||
implicit val PostBSONHandler = reactivemongo.bson.Macros.handler[Post] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
package lila.forum | ||
|
||
import play.api.libs.json.Json | ||
|
||
import lila.db.api._ | ||
import lila.db.Implicits._ | ||
import tube.categTube | ||
import lila.db.dsl._ | ||
|
||
object CategRepo { | ||
|
||
def bySlug(slug: String) = $find byId slug | ||
import BSONHandlers.CategBSONHandler | ||
|
||
// dirty | ||
private val coll = Env.current.categColl | ||
|
||
def bySlug(slug: String) = coll.byId[Categ](slug) | ||
|
||
def withTeams(teams: Set[String]): Fu[List[Categ]] = | ||
$find($query($or(Seq( | ||
Json.obj("team" -> $exists(false)), | ||
Json.obj("team" -> $in(teams)) | ||
))) sort $sort.asc("pos")) | ||
coll.find($or( | ||
"team" $exists false, | ||
"team" $in teams | ||
)).sort($sort asc "pos").cursor[Categ].collect[List]() | ||
|
||
def nextPosition: Fu[Int] = $primitive.one( | ||
$select.all, | ||
"pos", | ||
_ sort $sort.desc("pos") | ||
)(_.asOpt[Int]) map (~_ + 1) | ||
def nextPosition: Fu[Int] = | ||
coll.primitiveOne[Int]($empty, $sort desc "pos", "pos") map (~_ + 1) | ||
|
||
def nbPosts(id: String): Fu[Int] = | ||
$primitive.one($select(id), "nbPosts")(_.asOpt[Int]) map (~_) | ||
coll.primitiveOne[Int]($id(id), "nbPosts") map (~_) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.