Skip to content

Commit

Permalink
#357 fix lastcheck date in Biosecurity alerts for the scheduler
Browse files Browse the repository at this point in the history
And the preview data was unexpectedly stored in the database.
  • Loading branch information
qifeng-bai committed Jan 16, 2025
1 parent 2473ec6 commit e6b15f1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ class AdminController {
qr.previousCheck = qr.lastChecked
qr.lastChecked = since
query.lastChecked = since


def records = notificationService.retrieveRecordForQuery(qr.query, qr)

String urlPrefix = "${grailsApplication.config.getProperty("grails.serverURL")}${grailsApplication.config.getProperty('security.cas.contextPath', '')}"
Expand All @@ -383,7 +381,7 @@ class AdminController {
def unsubscribeOneUrl

def alaUser = authService.userDetails()
def user = userService.getUserByEmail(alaUser?.email)
def user = User.findByEmail(alaUser?.email)
def unsubscribeToken = notificationService.getUnsubscribeToken(user, query)
if (user && unsubscribeToken) {
unsubscribeOneUrl = urlPrefix + "/unsubscribe?token=${unsubscribeToken}"
Expand Down
5 changes: 4 additions & 1 deletion grails-app/domain/au/org/ala/alerts/Query.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class Query {
String recordJsonPath

transient String listId //species list id
transient Date lastChecked // Date when the last execution performed
// Date when the last execution performed.
// NOTE: Except Biosecurity, other queries may have 4 lastChecked dates, matching the 4 frequencies
// Only used for passing the checked date to the Email template
transient Date lastChecked

static hasMany = [notifications: Notification, queryResults: QueryResult, propertyPaths: PropertyPath]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BiosecurityService {
*/
def triggerBiosecuritySubscription(Query query) {
//If has not been checked before, then set the lastChecked to 7 days before
Date lastChecked = query.lastChecked ?: DateUtils.addDays(new Date(), -1 * grailsApplication.config.getProperty("biosecurity.legacy.firstLoadedDateAge", Integer, 7))
Date lastChecked = queryService.getLastCheckedDate(query) ?: DateUtils.addDays(new Date(), -1 * grailsApplication.config.getProperty("biosecurity.legacy.firstLoadedDateAge", Integer, 7))
triggerBiosecuritySubscription(query, lastChecked)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class NotificationService {
def grailsApplication
def dateFormatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss")

@Transactional
QueryResult getQueryResult(Query query, Frequency frequency) {
QueryResult qr = QueryResult.findByQueryAndFrequency(query, frequency)
if (qr == null) {
Expand Down

0 comments on commit e6b15f1

Please sign in to comment.