Skip to content

Commit 6c1512b

Browse files
committed
Query "Client API Actions" audit event table directly and use modern column names
1 parent bc18897 commit 6c1512b

File tree

4 files changed

+8
-17
lines changed

4 files changed

+8
-17
lines changed

WNPRC_EHR/resources/queries/core/SiteBackupLog.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@ comment
2020

2121
FROM auditlog."Client API Actions" a
2222

23-
WHERE
24-
a.key1 = 'LabKey Server Backup'
23+
WHERE a.SubType = 'LabKey Server Backup'

WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/AdminAlertsNotificationRevamp.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
import org.labkey.api.data.SimpleFilter;
66
import org.labkey.api.data.Sort;
77
import org.labkey.api.module.Module;
8-
import org.labkey.api.query.FieldKey;
98
import org.labkey.api.security.User;
109

11-
import java.lang.reflect.Array;
1210
import java.util.ArrayList;
1311
import java.util.Date;
1412
import java.util.HashMap;
@@ -142,14 +140,13 @@ void getNumClientErrorsSinceYesterday() {
142140
// Creates filter.
143141
Date dateYesterday = dateToolkit.getDateXDaysFromNow(-1);
144142
SimpleFilter myFilter = new SimpleFilter("date", dateYesterday, CompareType.DATE_GTE);
145-
myFilter.addCondition("key1", "LabKey Server Backup", CompareType.NEQ_OR_NULL);
146-
myFilter.addCondition("EventType", "Client API Actions", CompareType.EQUAL);
143+
myFilter.addCondition("SubType", "LabKey Server Backup", CompareType.NEQ_OR_NULL);
147144

148145
// Runs query.
149-
ArrayList<String> returnArray = notificationToolkit.getTableMultiRowSingleColumn(currentContainer, currentUser, "auditlog", "audit", myFilter, null, "RowId", null);
146+
ArrayList<String> returnArray = notificationToolkit.getTableMultiRowSingleColumn(currentContainer, currentUser, "auditlog", "Client API Actions", myFilter, null, "RowId", null);
150147
this.numClientErrorsSinceYesterday = Long.valueOf(returnArray.size());
151148
// Creates a URL to view number of client errors since yesterday.
152-
this.numClientErrorsSinceYesterdayURLView = notificationToolkit.createQueryURL(currentContainer, "execute", "auditlog", "audit", myFilter);
149+
this.numClientErrorsSinceYesterdayURLView = notificationToolkit.createQueryURL(currentContainer, "execute", "auditlog", "Client API Actions", myFilter);
153150
}
154151
}
155152
}

WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/SiteErrorAlertsRevamp.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ public String getCategory() {
5656
return "Revamped Notifications";
5757
}
5858

59-
60-
61-
62-
6359
//Message Creation
6460
@Override
6561
public String getMessageBodyHTML(Container c, User u) {
@@ -69,13 +65,13 @@ public String getMessageBodyHTML(Container c, User u) {
6965

7066
// Creates filter.
7167
SimpleFilter myFilter = new SimpleFilter("date", lastRunDate, CompareType.GTE);
72-
myFilter.addCondition("key1", "LabKeyServer Backup", CompareType.NEQ);
68+
myFilter.addCondition("SubType", "LabKeyServer Backup", CompareType.NEQ);
7369
// Gets columns to retrieve.
7470
String[] targetColumns = new String[]{"id"};
7571
// Runs query.
76-
ArrayList<HashMap<String, String>> returnArray = notificationToolkit.getTableMultiRowMultiColumnWithFieldKeys(c, u, "auditlog", "audit", myFilter, null, targetColumns);
72+
ArrayList<HashMap<String, String>> returnArray = notificationToolkit.getTableMultiRowMultiColumnWithFieldKeys(c, u, "auditlog", "Client API Actions", myFilter, null, targetColumns);
7773
// Creates URL.
78-
String queryURL = notificationToolkit.createQueryURL(c, "execute", "auditlog", "audit", myFilter);
74+
String queryURL = notificationToolkit.createQueryURL(c, "execute", "auditlog", "Client API Actions", myFilter);
7975

8076
// Sends the message only if there are results (otherwise sends notification to admins via emptyNotificationRevamp).
8177
if (returnArray.isEmpty()) {
@@ -89,7 +85,6 @@ public String getMessageBodyHTML(Container c, User u) {
8985
return messageBody.toString();
9086
}
9187
}
92-
9388
}
9489

9590

docker/ehrcron/scripts/pg_backup/lkServerBackup.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ sub lk_log {
508508
-queryName => "Client API Actions",
509509
-rows =>
510510
[ {
511-
"Key1" => "LabKey Server Backup",
511+
"SubType" => "LabKey Server Backup",
512512
"Comment" => $status,
513513
"Date" => $date
514514
} ]

0 commit comments

Comments
 (0)