Skip to content

Instantly share code, notes, and snippets.

@terjokhin
Created February 12, 2019 08:43
Show Gist options
  • Save terjokhin/3acf7986ded18a9d785859081cec2451 to your computer and use it in GitHub Desktop.
Save terjokhin/3acf7986ded18a9d785859081cec2451 to your computer and use it in GitHub Desktop.
def getBlocks: Route = (get & paging & sorting(sortByFieldMappings, Some("height")) & startEndDate) {
(o, l, field, so, start, end) =>
val sTs = start.getOrElse(0L)
val eTs = end.getOrElse(System.currentTimeMillis() + oneDayMillis)
val p = Paging(offset = o, limit = l)
val s = Sorting(sortBy = field, order = so)
val items = bs.getBlocks(p, s, sTs, eTs)
val count = bs.count(sTs, eTs)
val itemsResponse = (items, count).parMapN(ItemsResponse.apply)
itemsResponse
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment