Created
February 20, 2017 09:32
-
-
Save sebprunier/d28d53d296adf447545a260e484396cf to your computer and use it in GitHub Desktop.
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
def index(page: Int) = Action.async { implicit request => | |
for { | |
api <- fetchApi | |
response <- api.forms("everything") | |
.query( | |
Predicate.at("document.type", "Blog-post") | |
) | |
.ref(ref(api)) | |
.orderings("[Blog-post.date]") | |
.pageSize(10) | |
.page(page).submit() | |
} yield { | |
val newResponse = response.copy(results = response.results.sortWith((a, b) => { | |
a.getDate("Blog-post.date").map(_.value).getOrElse(LocalDate.now()) | |
.isAfter(b.getDate("Blog-post.date").map(_.value).getOrElse(LocalDate.now())) | |
})) | |
Ok(views.html.index(newResponse)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment