remove video_filter unused collection, reformat code
This commit is contained in:
parent
d50f3d5bd2
commit
cf9dafbeb0
|
@ -27,8 +27,7 @@ final class Env(
|
|||
|
||||
lazy val api = new VideoApi(
|
||||
videoColl = videoColl,
|
||||
viewColl = viewColl,
|
||||
filterColl = filterColl)
|
||||
viewColl = viewColl)
|
||||
|
||||
private lazy val sheet = new Sheet(
|
||||
url = SheetUrl,
|
||||
|
@ -52,7 +51,6 @@ final class Env(
|
|||
|
||||
private[video] lazy val videoColl = db(CollectionVideo)
|
||||
private[video] lazy val viewColl = db(CollectionView)
|
||||
private[video] lazy val filterColl = db(CollectionFilter)
|
||||
}
|
||||
|
||||
object Env {
|
||||
|
|
|
@ -13,8 +13,7 @@ import lila.user.{ User, UserRepo }
|
|||
|
||||
private[video] final class VideoApi(
|
||||
videoColl: Coll,
|
||||
viewColl: Coll,
|
||||
filterColl: Coll) {
|
||||
viewColl: Coll) {
|
||||
|
||||
import lila.db.BSON.BSONJodaDateTimeHandler
|
||||
import reactivemongo.bson.Macros
|
||||
|
@ -184,7 +183,13 @@ private[video] final class VideoApi(
|
|||
private val max = 25
|
||||
|
||||
import videoColl.BatchCommands.AggregationFramework, AggregationFramework.{
|
||||
Descending, GroupField, Match, Project, Unwind, Sort, SumValue
|
||||
Descending,
|
||||
GroupField,
|
||||
Match,
|
||||
Project,
|
||||
Unwind,
|
||||
Sort,
|
||||
SumValue
|
||||
}
|
||||
|
||||
private val pathsCache = AsyncCache[List[Tag], List[TagNb]](
|
||||
|
@ -193,13 +198,11 @@ private[video] final class VideoApi(
|
|||
if (filterTags.isEmpty) allPopular map { tags =>
|
||||
tags.filterNot(_.isNumeric)
|
||||
}
|
||||
else {
|
||||
videoColl.aggregate(
|
||||
Match(BSONDocument("tags" -> BSONDocument("$all" -> filterTags))),
|
||||
List(Project(BSONDocument("tags" -> BSONBoolean(true))),
|
||||
Unwind("tags"), GroupField("tags")("nb" -> SumValue(1)))).map(
|
||||
else videoColl.aggregate(
|
||||
Match(BSONDocument("tags" -> BSONDocument("$all" -> filterTags))),
|
||||
List(Project(BSONDocument("tags" -> BSONBoolean(true))),
|
||||
Unwind("tags"), GroupField("tags")("nb" -> SumValue(1)))).map(
|
||||
_.documents.flatMap(_.asOpt[TagNb]))
|
||||
}
|
||||
|
||||
allPopular zip allPaths map {
|
||||
case (all, paths) =>
|
||||
|
@ -225,7 +228,7 @@ private[video] final class VideoApi(
|
|||
Project(BSONDocument("tags" -> BSONBoolean(true))), List(
|
||||
Unwind("tags"), GroupField("tags")("nb" -> SumValue(1)),
|
||||
Sort(Descending("nb")))).map(
|
||||
_.documents.flatMap(_.asOpt[TagNb])),
|
||||
_.documents.flatMap(_.asOpt[TagNb])),
|
||||
timeToLive = 1.day)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue