Skip to content

Commit

Permalink
Scala tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Jun 3, 2024
1 parent d027685 commit 23cec5d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions modules/app/src/main/scala/http.middleware.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def ApplyMiddleware(config: HttpServerConfig)(routes: HttpRoutes[IO])(using Logg
val middleware = autoSlash.andThen(timeout)

def verboseLogger =
RequestLogger.httpApp[IO](true, true) andThen
ResponseLogger.httpApp[IO, Request[IO]](true, true)
RequestLogger.httpApp[IO](true, true).andThen(ResponseLogger.httpApp[IO, Request[IO]](true, true))

val logger =
if config.apiLogger then verboseLogger
Expand Down
1 change: 0 additions & 1 deletion modules/app/src/main/scala/service.search.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package app
import cats.effect.*
import lila.search.spec.*
import org.typelevel.log4cats.Logger
import forum.ForumQuery.*
import io.github.arainko.ducktape.*
import org.joda.time.DateTime
import smithy4s.Timestamp
Expand Down
7 changes: 3 additions & 4 deletions modules/core/src/main/scala/forum.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ object ForumQuery:
search(index.name)
.query(makeQuery(query))
.fetchSource(false)
.sortBy(
fieldSort(Fields.date).order(SortOrder.DESC)
)
.start(from.value) size size.value
.sortBy(fieldSort(Fields.date).order(SortOrder.DESC))
.start(from.value)
.size(size.value)

def countDef(query: Forum) = index => search(index.name).query(makeQuery(query)) size 0

Expand Down
6 changes: 4 additions & 2 deletions modules/core/src/main/scala/game.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ object GameQuery:

def searchDef(query: Game)(from: From, size: Size) =
index =>
(search(index.name)
search(index.name)
.query(makeQuery(query))
.fetchSource(false)
.sortBy(query.sorting.definition)
.start(from.value) size size.value).timeout(timeout)
.start(from.value)
.size(size.value)
.timeout(timeout)

def countDef(query: Game) = index => (search(index.name).query(makeQuery(query)) size 0).timeout(timeout)

Expand Down
3 changes: 2 additions & 1 deletion modules/core/src/main/scala/study.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ object StudyQuery:
fieldSort("_score").order(SortOrder.DESC),
fieldSort(Fields.likes).order(SortOrder.DESC)
)
.start(from.value) size size.value
.start(from.value)
.size(size.value)

def countDef(query: Study) = index => search(index.name).query(makeQuery(query)) size 0

Expand Down
7 changes: 3 additions & 4 deletions modules/core/src/main/scala/team.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ object TeamQuery:
search(index.name)
.query(makeQuery(query))
.fetchSource(false)
.sortBy(
fieldSort(Fields.nbMembers).order(SortOrder.DESC)
)
.start(from.value) size size.value
.sortBy(fieldSort(Fields.nbMembers).order(SortOrder.DESC))
.start(from.value)
.size(size.value)

def countDef(query: Team) = index => search(index.name).query(makeQuery(query)) size 0

Expand Down

0 comments on commit 23cec5d

Please sign in to comment.