Skip to content

Commit

Permalink
#259 fix link error of my annotations
Browse files Browse the repository at this point in the history
CSS templates improvements
  • Loading branch information
qifeng-bai committed Dec 19, 2024
1 parent 9b11c6d commit 32a45d1
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 115 deletions.
4 changes: 1 addition & 3 deletions grails-app/domain/au/org/ala/alerts/QueryResult.groovy
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package au.org.ala.alerts

import com.jayway.jsonpath.JsonPath

import java.text.SimpleDateFormat
import java.util.zip.GZIPInputStream
import java.util.zip.GZIPOutputStream
Expand Down Expand Up @@ -75,7 +73,7 @@ class QueryResult {
}

String toString() {
"${frequency?.name}: ${lastChanged ? 'Changed' : 'No Change'} on ${lastChecked}"
"${frequency?.name}: ${query?.name} : ${id} ${lastChanged ? 'Changed' : 'No Change'} on ${lastChecked}"
}

Map brief() {
Expand Down
5 changes: 4 additions & 1 deletion grails-app/jobs/ala/postie/HourlyQueriesJob.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package ala.postie

import grails.plugins.schwartz.monitor.listener.QuartzJobListener
import org.quartz.JobExecutionContext

class HourlyQueriesJob {

static triggers = {
Expand All @@ -11,6 +14,6 @@ class HourlyQueriesJob {
def execute() {
log.info("****** Starting hourly update ****** " + new Date())
notificationService.execQueryForFrequency('hourly')
log.info("****** Finished hourly update ******" + new Date())
log.info("****** Finished hourly update ****** " + new Date())
}
}
32 changes: 17 additions & 15 deletions grails-app/services/au/org/ala/alerts/DiffService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,23 @@ class DiffService {
// The following check is determined by the last propertyValue, since it overwrites the previous one

queryResult.propertyValues.each { pv ->
log.debug("[QUERY " + queryResult.query.id + "] " +
" Has changed check:" + pv.propertyPath.name
+ ", value:" + pv.currentValue
+ ", previous:" + pv.previousValue
+ ", fireWhenNotZero:" + pv.propertyPath.fireWhenNotZero
+ ", fireWhenChange:" + pv.propertyPath.fireWhenChange
)

// Two different types of queries: Biocache and Blog/News
// Biocache: totalRecords and last_loaded_records
// Blog/News: last_blog_id
if (pv.propertyPath.fireWhenNotZero) {
changed = pv.currentValue?.toInteger() ?: 0 > 0
} else if (pv.propertyPath.fireWhenChange) {
changed = pv.previousValue != pv.currentValue
if (pv) {
log.debug("[QUERY " + queryResult.query.id + "] " +
" Has changed check:" + pv.propertyPath.name
+ ", value:" + pv.currentValue
+ ", previous:" + pv.previousValue
+ ", fireWhenNotZero:" + pv.propertyPath.fireWhenNotZero
+ ", fireWhenChange:" + pv.propertyPath.fireWhenChange
)

// Two different types of queries: Biocache and Blog/News
// Biocache: totalRecords and last_loaded_records
// Blog/News: last_blog_id
if (pv.propertyPath.fireWhenNotZero) {
changed = pv.currentValue?.toInteger() ?: 0 > 0
} else if (pv?.propertyPath.fireWhenChange) {
changed = pv.previousValue != pv.currentValue
}
}
}

Expand Down
18 changes: 11 additions & 7 deletions grails-app/services/au/org/ala/alerts/NotificationService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,17 @@ class NotificationService {
def duration = TimeCategory.minus(endTime, startTime)
qr.addLog("Time cost: ${duration}")
if(!dryRun) {
QueryResult.withTransaction {
if (!qr.save(validate: true, flush: true)) {
qr.errors.allErrors.each {
log.error(it)
try {
QueryResult.withTransaction {
if (!qr.save(validate: true)) {
qr.errors.allErrors.each {
log.error(it)
}
}
}
} catch (Exception e) {
//todo check why sometimes scheduler cannot save the queryresult
log.error("An unexpected error occurred in saving queryresult: ${qr}", e)
}
}
else {
Expand Down Expand Up @@ -646,10 +651,9 @@ class NotificationService {
log.debug("Checking frequency : " + frequencyName)
Date now = new Date()
Frequency frequency = Frequency.findByName(frequencyName)
execQueryForFrequency(frequency, sendEmails)
//update the frequency last checked
frequency = Frequency.findByName(frequencyName)
if (frequency) {
execQueryForFrequency(frequency, sendEmails)
//update the frequency last checked
frequency.lastChecked = now
Frequency.withTransaction {
if (!frequency.save(validate: true, flush: true)) {
Expand Down
45 changes: 27 additions & 18 deletions grails-app/views/email/annotations.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,34 @@
<table style="width: 100%">
<tr style="vertical-align: top;">
<td style="width: 37%">
<a href="${occurrencelink}" style="color: #003A70;text-decoration: none;font-family: 'Arial', sans-serif;font-size: 16px;line-height: 1.5;">
<g:if test="${ oc.scientificName?:oc.vernacularName ?: oc.raw_raw_scientificName}">
<strong>${i+1}. <em>${oc.scientificName?: oc.vernacularName ?: oc.raw_raw_scientificName }</em></strong>
</g:if>
</a>
<p style="padding-left: 15px;">
${oc.vernacularName}<br/>
<g:if test="${oc.stateProvince}">
${oc.stateProvince}<br/>
</g:if>
<g:if test="${oc.family}">
Family: ${oc.family}<br/>
</g:if>
<g:if test="${oc.dataProviderName}">
Source: ${oc.dataProviderName}
</g:if>
</p>
<table>
<tr>
<td style="white-space: nowrap; vertical-align: top; text-align: right; padding-right: 10px;">
<strong>${i+1}. </strong>
</td>
<td style="vertical-align: top;">
<a href="${occurrencelink}" style="color: #003A70;text-decoration: none;font-family: 'Arial', sans-serif;font-size: 16px;line-height: 1.5;">
<strong><em>${oc.scientificName?: oc.vernacularName ?: oc.raw_raw_scientificName }</em></strong>
</a>
<p>
<g:if test="${oc.vernacularName}">
${oc.vernacularName}<br/>
</g:if>
<g:if test="${oc.stateProvince}">
${oc.stateProvince}<br/>
</g:if>
<g:if test="${oc.family}">
Family: ${oc.family}<br/>
</g:if>
<g:if test="${oc.dataProviderName}">
Source: ${oc.dataProviderName}
</g:if>
</p>
</td>
</tr>
</table>
</td>
<td class="annotation" nowrap="nowrap" style="width: 30%; word-wrap: break-word; white-space: normal;">
<td class="annotation" nowrap="nowrap" style="width: 30%; padding-left:10px;padding-top:8px; word-wrap: break-word; white-space: normal;">
<g:if test="${oc.user_assertions?.size() > 0}">
<%
def latestAssertion = oc.user_assertions[0] // Get the first (latest) assertion
Expand Down
60 changes: 32 additions & 28 deletions grails-app/views/email/dataresource.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,39 @@
<table style="width: 100%">
<tr style="vertical-align: top;">
<td style="width: 70%">
${i+1}.
<a href="${oclink}" style="color: #003A70;text-decoration: none;">
<strong>${oc.label}</strong>
</a>

<p style="padding-left: 15px;">
<g:if test="${oc.count}">
Total records: ${oc.count}<br/>
</g:if>

<g:if test="${oc.details?.licenseType}">
Licence: ${oc.details?.licenseType}<br/>
</g:if>
<g:if test="${oc.details?.resourceType}">
Content type: ${oc.details?.resourceType}<br/>
</g:if>


<br/>
<g:if test="${oc.details?.pubShortDescription}">
${StringUtils.abbreviate(oc.details?.pubShortDescription, 200)}<br/>
</g:if>
<g:else>
<g:if test="${oc.details?.pubDescription}">
${StringUtils.abbreviate(oc.details?.pubDescription, 200)}<br/>
</g:if>
</g:else>
</p>
<table>
<tr>
<td style="white-space: nowrap; vertical-align: top; text-align: right; padding-right: 10px;">
<strong>${i+1}. </strong>
</td>
<td style="vertical-align: top;">
<a href="${oclink}" style="color: #003A70;font-family: 'Arial', sans-serif;font-size: 16px;line-height: 1.5;">
<strong><em>${oc.label}</em></strong>
</a>
<p>
<g:if test="${oc.count}">
Total records: ${oc.count}<br/>
</g:if>

<g:if test="${oc.details?.licenseType}">
Licence: ${oc.details?.licenseType}<br/>
</g:if>
<g:if test="${oc.details?.resourceType}">
Content type: ${oc.details?.resourceType}<br/>
</g:if>
<br/>
<g:if test="${oc.details?.pubShortDescription}">
${StringUtils.abbreviate(oc.details?.pubShortDescription, 200)}<br/>
</g:if>
<g:else>
<g:if test="${oc.details?.pubDescription}">
${StringUtils.abbreviate(oc.details?.pubDescription, 200)}<br/>
</g:if>
</g:else>
</p>
</td>
</tr>
</table>
</td>
<td style="width: 33%; text-align: right;" >

Expand Down
57 changes: 30 additions & 27 deletions grails-app/views/email/datasets.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,36 @@ a {
<table style="width: 100%">
<tr style="vertical-align: top;">
<td style="width: 70%">
<strong>${i+1}.</strong>
<a href="${oclink}" style="color: #003A70;font-family: 'Arial', sans-serif;font-size: 16px;line-height: 1.5;">
<strong><em>${oc.name}</em></strong>
</a>
<p style="padding-left: 15px;">

<g:if test="${oc.details?.licenseType}">
Licence: ${oc.details?.licenseType}<br/>
</g:if>
<g:if test="${oc.details?.resourceType}">
Content type: ${oc.details?.resourceType}<br/>
</g:if>


<br/>
<g:if test="${oc.details?.pubShortDescription}">
${StringUtils.abbreviate(oc.details?.pubShortDescription, 200)}
<br/>
</g:if>
<g:else>
<g:if test="${oc.details?.pubDescription}">
${StringUtils.abbreviate(oc.details?.pubDescription, 200)}
<br/>
</g:if>
</g:else>
</p>

<table>
<tr>
<td style="white-space: nowrap; vertical-align: top; text-align: right; padding-right: 10px;">
<strong>${i+1}. </strong>
</td>
<td style="vertical-align: top;">
<a href="${oclink}" style="color: #003A70;font-family: 'Arial', sans-serif;font-size: 16px;line-height: 1.5;">
<strong><em>${oc.name}</em></strong>
</a>
<p>
<g:if test="${oc.details?.licenseType}">
Licence: ${oc.details?.licenseType}<br/>
</g:if>
<g:if test="${oc.details?.resourceType}">
Content type: ${oc.details?.resourceType}<br/>
</g:if>
<g:if test="${oc.details?.pubShortDescription}">
${StringUtils.abbreviate(oc.details?.pubShortDescription, 200)}
<br/>
</g:if>
<g:else>
<g:if test="${oc.details?.pubDescription}">
${StringUtils.abbreviate(oc.details?.pubDescription, 200)}
<br/>
</g:if>
</g:else>
</p>
</td>
</tr>
</table>
</td>
<td style="width: 33%; text-align: right;" >
<g:if test="${oc.image != null}">
Expand Down
Loading

0 comments on commit 32a45d1

Please sign in to comment.