Skip to content

Instantly share code, notes, and snippets.

@maexrakete
Created October 24, 2019 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maexrakete/a99c6c5cc180bcde0423452045cb7282 to your computer and use it in GitHub Desktop.
Save maexrakete/a99c6c5cc180bcde0423452045cb7282 to your computer and use it in GitHub Desktop.
def findPaged(limit: Int, offset: Int)(
implicit filter: Option[IssueSortAndFilterOptions] = None)
: Future[Page[Issue]] = {
db.run(
(for {
data <- filteredQuery(filter)
.sortBy { a =>
filter.flatMap(_.term) match {
case Some(search) => a.title <<-> search
case None => ???
}
}
.drop(offset)
.take(limit)
.result
total <- filteredQuery.length.result
} yield
(Page(totalEntities = total,
data = data,
currentPage = offset / limit,
pageSize = limit))))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment