From 9399d8b86d7b09030598601ee0180a9932a3bd09 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 5 Nov 2015 14:42:43 +0700 Subject: [PATCH] releave db.video by simplifying /video UI for bots --- app/controllers/Video.scala | 6 +++++- app/views/video/card.scala.html | 2 +- modules/video/src/main/control.scala | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/Video.scala b/app/controllers/Video.scala index 6d8929ce16..cb0cfdef16 100644 --- a/app/controllers/Video.scala +++ b/app/controllers/Video.scala @@ -17,7 +17,11 @@ object Video extends LilaController { private def WithUserControl[A](f: UserControl => Fu[A])(implicit ctx: Context): Fu[A] = { val reqTags = get("tags") ?? (_.split('^').toList.map(_.trim.toLowerCase)) env.api.tag.paths(reqTags) map { tags => - UserControl(filter = Filter(reqTags), tags = tags, query = get("q")) + UserControl( + filter = Filter(reqTags), + tags = tags, + query = get("q"), + bot = HTTPRequest.isBot(ctx.req)) } flatMap f } diff --git a/app/views/video/card.scala.html b/app/views/video/card.scala.html index 3ded461e55..0d1d0c27b5 100644 --- a/app/views/video/card.scala.html +++ b/app/views/video/card.scala.html @@ -1,6 +1,6 @@ @(vv: lila.video.VideoView, control: lila.video.UserControl)(implicit ctx: Context) - + @if(vv.view) { watched } diff --git a/modules/video/src/main/control.scala b/modules/video/src/main/control.scala index 6ce41ba211..de4579611d 100644 --- a/modules/video/src/main/control.scala +++ b/modules/video/src/main/control.scala @@ -21,7 +21,8 @@ case class Filter(tags: List[String]) { case class UserControl( filter: Filter, tags: List[TagNb], - query: Option[String]) { + query: Option[String], + bot: Boolean) { def toggleTag(tag: String) = copy( filter = filter toggle tag, @@ -31,4 +32,6 @@ case class UserControl( filter.tags.nonEmpty option s"tags=${filter.tags.sorted mkString "^"}".replace(" ", "+"), query.map { q => s"q=$q" } ).flatten mkString "&" + + def queryStringUnlessBot = !bot ?? queryString }