diff --git a/grails-app/services/au/org/ala/alerts/MyAnnotationService.groovy b/grails-app/services/au/org/ala/alerts/MyAnnotationService.groovy index c34d359..628e136 100644 --- a/grails-app/services/au/org/ala/alerts/MyAnnotationService.groovy +++ b/grails-app/services/au/org/ala/alerts/MyAnnotationService.groovy @@ -126,17 +126,24 @@ class MyAnnotationService{ * @return */ private static def findVerifiedAssertions(JSONArray assertions, String userId) { - def verifiedAssertions = [] + def sortedAssertions = [] if (assertions) { // all the original user assertions (issues users flagged) def origUserAssertions = assertions.findAll { it.uuid && !it.relatedUuid && it.userId == userId } // Find assertions which commented on the original user assertions def myOriginalUuids = origUserAssertions*.uuid - // todo - need to check if 50003 or 50001 is the correct status for Verified assertions - verifiedAssertions = myOriginalUuids.collectMany { uuid -> - assertions.findAll { it.relatedUuid == uuid && ( it.qaStatus == 50003 || it.qaStatus == 50001)} + def verifiedAssertions = myOriginalUuids.collectMany { uuid -> + assertions.findAll { it.relatedUuid == uuid && ( it.qaStatus == 50001 || it.qaStatus == 50002 || it.qaStatus == 50003) } + } + + try { + sortedAssertions = verifiedAssertions.sort { a, b -> + Date.parse("yyyy-MM-dd'T'HH:mm:ssX", b.created) <=> Date.parse("yyyy-MM-dd'T'HH:mm:ssX", a.created) + } + } catch (Exception e) { + sortedAssertions = verifiedAssertions } } - return verifiedAssertions + return sortedAssertions } } diff --git a/grails-app/services/au/org/ala/alerts/NotificationService.groovy b/grails-app/services/au/org/ala/alerts/NotificationService.groovy index 1dfb3a0..23b3e9c 100644 --- a/grails-app/services/au/org/ala/alerts/NotificationService.groovy +++ b/grails-app/services/au/org/ala/alerts/NotificationService.groovy @@ -3,10 +3,8 @@ package au.org.ala.alerts import com.jayway.jsonpath.JsonPath import grails.gorm.transactions.NotTransactional import grails.converters.JSON -import org.apache.commons.io.IOUtils import org.apache.commons.lang.time.DateUtils import org.grails.web.json.JSONArray -import org.grails.web.json.JSONElement import org.grails.web.json.JSONObject import javax.transaction.Transactional diff --git a/src/test/groovy/au/org/ala/alerts/MyAnnotationServiceSpec.groovy b/src/test/groovy/au/org/ala/alerts/MyAnnotationServiceSpec.groovy index ea0b817..a89467d 100644 --- a/src/test/groovy/au/org/ala/alerts/MyAnnotationServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/alerts/MyAnnotationServiceSpec.groovy @@ -3,7 +3,7 @@ package au.org.ala.alerts import grails.testing.services.ServiceUnitTest import spock.lang.Specification -class MyAnnotationServiceSpec extends Specification implements ServiceUnitTest{ +class MyAnnotationServiceSpec extends Specification implements ServiceUnitTest { def assertionService @@ -22,7 +22,7 @@ class MyAnnotationServiceSpec extends Specification implements ServiceUnitTest