Skip to content

Commit

Permalink
#346 sort verified assertions with created date
Browse files Browse the repository at this point in the history
Thus, my annotation email always displays the latest assertions
  • Loading branch information
qifeng-bai committed Jan 9, 2025
1 parent edcda4c commit 27efbb7
Show file tree
Hide file tree
Showing 3 changed files with 911 additions and 582 deletions.
17 changes: 12 additions & 5 deletions grails-app/services/au/org/ala/alerts/MyAnnotationService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 27efbb7

Please sign in to comment.