Skip to content

Commit

Permalink
Update ipt sync view. Add totals. Add diff. Styling
Browse files Browse the repository at this point in the history
  • Loading branch information
matsbov committed May 13, 2024
1 parent 5828b5b commit b84d734
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ class IptController {
def sortDirection = params.order ?: "asc"
def onlyUnsynced = Boolean.parseBoolean(params.onlyUnsynced ?: "false")
def result = []
def iptTotalCount = 0
def atlasTotalCount = 0

if (provider.websiteUrl) {

Expand Down Expand Up @@ -265,6 +267,9 @@ class IptController {
row.atlasCount = it.type == "CHECKLIST" ? null : countJson.totalRecords
}

iptTotalCount += (row.iptCount ?: 0)
atlasTotalCount += (row.atlasCount ?: 0)

def isUnsynced = row.iptCount != row.atlasCount || row.iptPublished != row.atlasPublished
if (!onlyUnsynced || isUnsynced) {
result.add(row)
Expand All @@ -277,6 +282,12 @@ class IptController {
}
}

[result: result, instance: provider, sortBy: sortBy, sortDirection: sortDirection, onlyUnsynced: onlyUnsynced]
[result: result,
iptTotalCount: iptTotalCount,
atlasTotalCount: atlasTotalCount,
instance: provider,
sortBy: sortBy,
sortDirection: sortDirection,
onlyUnsynced: onlyUnsynced]
}
}
35 changes: 29 additions & 6 deletions grails-app/views/ipt/syncView.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@
</th>
<th style="xtext-align: right">
<a href="/ipt/syncView?uid=${instance.uid}&onlyUnsynced=${onlyUnsynced}&sort=iptPublished&order=${sortBy=="iptPublished" && sortDirection=="asc" ? "desc" : "asc"}">
IPT published
IPT date
</a>
</th>
<th style="xtext-align: right">
<a href="/ipt/syncView?uid=${instance.uid}&onlyUnsynced=${onlyUnsynced}&sort=atlasPublished&order=${sortBy=="atlasPublished" && sortDirection=="asc" ? "desc" : "asc"}">
Atlas published
Atlas date
</a>
</th>
<th style="text-align: right">
<a href="/ipt/syncView?uid=${instance.uid}&onlyUnsynced=${onlyUnsynced}&sort=iptCount&order=${sortBy=="iptCount" && sortDirection=="asc" ? "desc" : "asc"}">
IPT record count
IPT count
</a>
</th>
<th style="text-align: right">
<a href="/ipt/syncView?uid=${instance.uid}&onlyUnsynced=${onlyUnsynced}&sort=atlasCount&order=${sortBy=="atlasCount" && sortDirection=="asc" ? "desc" : "asc"}">
Atlas record count
Atlas count
</a>
</th>
</tr>
Expand All @@ -68,20 +68,43 @@
<td>
${item.type}
</td>
<td <g:if test="${item.iptPublished != item.atlasPublished}">style="color: green"</g:if>>
<td>
${item.iptPublished}
</td>
<td <g:if test="${item.iptPublished != item.atlasPublished}">style="color: red"</g:if>>
${item.atlasPublished}
</td>
<td style="text-align: right; <g:if test="${item.iptCount != item.atlasCount}">color: green</g:if>">
<td style="text-align: right;">
<g:formatNumber number="${item.iptCount}" format="###,###,##0" />
</td>
<td style="text-align: right; <g:if test="${item.iptCount != item.atlasCount}">color: red</g:if>">
<g:formatNumber number="${item.atlasCount}" format="###,###,##0" />
<g:if test="${item.iptCount != item.atlasCount}">
<br>
(<g:formatNumber number="${item.atlasCount - item.iptCount}" format="+###,###,##0;-###,###,##0" />)
</g:if>
</td>
</tr>
</g:each>
<tr>
<td style="font-style: italic">
Total all datasets
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td style="text-align: right">
<em><g:formatNumber number="${iptTotalCount}" format="###,###,##0" /></em>
</td>
<td style="text-align: right; font-style: italic; <g:if test="${iptTotalCount != atlasTotalCount}">color: red</g:if>">
<em><g:formatNumber number="${atlasTotalCount}" format="###,###,##0" /></em>
<g:if test="${iptTotalCount != atlasTotalCount}">
<br>
(<g:formatNumber number="${atlasTotalCount - iptTotalCount}" format="+###,###,##0;-###,###,##0" />)
</g:if>
</td>
</tr>
</table>

</body>
Expand Down

0 comments on commit b84d734

Please sign in to comment.