-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from lichess-org/optimize-some-queries
Optimize some queries
- Loading branch information
Showing
5 changed files
with
33 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
package lila | ||
package lila.search | ||
|
||
package object search: | ||
import com.sksamuel.elastic4s.ElasticDsl.* | ||
import com.sksamuel.elastic4s.requests.searches.queries.Query | ||
|
||
object Date: | ||
import org.joda.time.format.{ DateTimeFormat, DateTimeFormatter } | ||
val format = "yyyy-MM-dd HH:mm:ss" | ||
val formatter: DateTimeFormatter = DateTimeFormat.forPattern(format) | ||
object Date: | ||
import org.joda.time.format.{ DateTimeFormat, DateTimeFormatter } | ||
val format = "yyyy-MM-dd HH:mm:ss" | ||
val formatter: DateTimeFormatter = DateTimeFormat.forPattern(format) | ||
|
||
extension (self: Boolean) def fold[A](t: => A, f: => A): A = if self then t else f | ||
extension (self: Boolean) def fold[A](t: => A, f: => A): A = if self then t else f | ||
|
||
extension (queries: List[Query]) | ||
def compile: Query = queries match | ||
case Nil => matchAllQuery() | ||
case q :: Nil => q | ||
case _ => boolQuery().filter(queries) |
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