From 8e6540b9854843d20b7e2c18e5c2d07bd33be0fa Mon Sep 17 00:00:00 2001 From: Timo Rantalaiho Date: Tue, 18 Sep 2018 12:40:41 +0300 Subject: [PATCH] OY-227 : Sort all applications Flatmapping a set messed up the order of even single person oid, and for multiple oids there is no other solution than sorting here. --- .../fi/vm/sade/omatsivut/servlet/ApplicationsServlet.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/fi/vm/sade/omatsivut/servlet/ApplicationsServlet.scala b/src/main/scala/fi/vm/sade/omatsivut/servlet/ApplicationsServlet.scala index c6c1a2960..afad9c3ef 100644 --- a/src/main/scala/fi/vm/sade/omatsivut/servlet/ApplicationsServlet.scala +++ b/src/main/scala/fi/vm/sade/omatsivut/servlet/ApplicationsServlet.scala @@ -3,7 +3,7 @@ package fi.vm.sade.omatsivut.servlet import fi.vm.sade.groupemailer.GroupEmailComponent import fi.vm.sade.hakemuseditori._ import fi.vm.sade.hakemuseditori.hakemus.domain.HakemusMuutos -import fi.vm.sade.hakemuseditori.hakemus.{ApplicationValidatorComponent, Fetch, HakemusRepositoryComponent, SpringContextComponent} +import fi.vm.sade.hakemuseditori.hakemus.{ApplicationValidatorComponent, Fetch, HakemusInfo, HakemusRepositoryComponent, SpringContextComponent} import fi.vm.sade.hakemuseditori.json.JsonFormats import fi.vm.sade.hakemuseditori.localization.TranslationsComponent import fi.vm.sade.hakemuseditori.lomake.LomakeRepositoryComponent @@ -68,7 +68,7 @@ trait ApplicationsServletContainer { val allOids: Iterable[String] = oppijanumerorekisteriService.fetchAllDuplicateOids(oppijanumero) var allSuccess = true - val allHakemukset = allOids.flatMap(oid => { + val allHakemukset: List[HakemusInfo] = allOids.toList.flatMap(oid => { hakemusEditori.fetchByPersonOid(request, oid, Fetch) match { case FullSuccess(hakemukset) => hakemukset case PartialSuccess(partialHakemukset, exceptions) => @@ -80,7 +80,7 @@ trait ApplicationsServletContainer { allSuccess = false List.empty } - }) + }).sortBy(_.hakemus.received).reverse Map("allApplicationsFetched" -> allSuccess, "applications" -> allHakemukset) }