From bda590e64db7281ef8eb2a9d82572ddf462e267a Mon Sep 17 00:00:00 2001 From: Mats Bovin Date: Tue, 1 Oct 2024 11:33:00 +0200 Subject: [PATCH] Improve IPT sync view (#9) * Cleanup * Fetch dataset record count with one api call * Remove backend sorting * Add frontend sorting * --amend --- .../org/ala/collectory/IptController.groovy | 28 ++-- grails-app/views/ipt/syncView.gsp | 158 +++++++++--------- 2 files changed, 87 insertions(+), 99 deletions(-) diff --git a/grails-app/controllers/au/org/ala/collectory/IptController.groovy b/grails-app/controllers/au/org/ala/collectory/IptController.groovy index 01a8e523..350d106c 100644 --- a/grails-app/controllers/au/org/ala/collectory/IptController.groovy +++ b/grails-app/controllers/au/org/ala/collectory/IptController.groovy @@ -32,6 +32,7 @@ class IptController { def collectoryAuthService def iptService def providerGroupService + def dataResourceService /** * Scan an IPT instance described by a data provider and provide a list of datasets that need to be updated. @@ -230,8 +231,6 @@ class IptController { def syncView() { def provider = providerGroupService._get(params.uid) - def sortBy = params.sort ?: "title" - def sortDirection = params.order ?: "asc" def onlyUnsynced = Boolean.parseBoolean(params.onlyUnsynced ?: "false") def result = [] def iptTotalCount = 0 @@ -244,6 +243,8 @@ class IptController { dataResourceMap.put(it.gbifRegistryKey, it) } + def dataResourceRecordCountMap = dataResourceService.getDataresourceRecordCounts() + def iptInventory = new JsonSlurper().parse(new URL(provider.websiteUrl + "/inventory/dataset")) iptInventory.registeredResources.each { @@ -262,9 +263,7 @@ class IptController { if (dataResource) { row.uid = dataResource.uid row.atlasPublished = dataResource.dataCurrency.toLocalDateTime().toLocalDate().toString() - def countUrl = grailsApplication.config.biocacheServicesUrl + "/occurrences/search?pageSize=0&fq=data_resource_uid:" + dataResource.uid - def countJson = new JsonSlurper().parse(new URL(countUrl)) - row.atlasCount = it.type == "CHECKLIST" ? null : countJson.totalRecords + row.atlasCount = it.type == "CHECKLIST" ? null : dataResourceRecordCountMap.getOrDefault(row.uid, 0) } iptTotalCount += (row.iptCount ?: 0) @@ -276,18 +275,15 @@ class IptController { } } - result.sort { it[sortBy] } - if (sortDirection == "desc") { - result = result.reverse() - } + result.sort { it["title"] } } - [result: result, - iptTotalCount: iptTotalCount, - atlasTotalCount: atlasTotalCount, - instance: provider, - sortBy: sortBy, - sortDirection: sortDirection, - onlyUnsynced: onlyUnsynced] + [ + result: result, + iptTotalCount: iptTotalCount, + atlasTotalCount: atlasTotalCount, + instance: provider, + onlyUnsynced: onlyUnsynced + ] } } diff --git a/grails-app/views/ipt/syncView.gsp b/grails-app/views/ipt/syncView.gsp index 4067ef5c..7fcc0caf 100644 --- a/grails-app/views/ipt/syncView.gsp +++ b/grails-app/views/ipt/syncView.gsp @@ -10,105 +10,97 @@ /> ${instance.name} vs Atlas +

${instance.name} vs Atlas

${result.size} unsynced datasets • - + Show allonly unsynced datasets
- - - - - - - - - - - +
- - Title - - - - UID - - - - Type - - - - IPT date - - - - Atlas date - - - - IPT count - - - - Atlas count - -
+ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + - - - - - - - - - - - - +
- ${item.title}
- IPT   - Atlas -
- ${item.uid} - - ${item.type} - - ${item.iptPublished} + TitleUIDTypeIPT dateAtlas dateIPT countAtlas countDiff
+ ${item.title}
+ IPT   + Atlas +
+ ${item.uid} + + ${item.type} + + ${item.iptPublished} + style="color: red"> + ${item.atlasPublished} + + + color: red"> + + + + + +
+ Total all datasets style="color: red"> - ${item.atlasPublished} + + - + color: red"> + color: red"> - - -
- () +
+ +
- Total all datasets - - - color: red"> - - -
- () -
-
- +
+