Skip to content

Commit

Permalink
Geolocale taxon record alert. Doubled request tracking.
Browse files Browse the repository at this point in the history
  • Loading branch information
remarq committed Jun 27, 2021
1 parent 2e03d83 commit d57b849
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/org/calacademy/antweb/upload/UploadAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ Not all actions consider the submitGroup (currently).
+ "<br><br>or"
+ "<br><br>'<b>Regional_Taxon_List</b>' in the filename."
+ "<br>File can be downloaded from http://www.antwiki.org/wiki/images/0/0c/AntWiki_Regional_Taxon_List.txt."
+ "<br>File likely to require editing/massage. If file is 'binary', select * in Textwrangler and save in a new file (with name that contains 'Regional_Taxon_List'."
+ "<br>File may be persisted in source tree at /web/data/. After this first step is complete, execute "
+ "<br>File likely to require editing/massage. If file is 'binary', select * in BBEdit and save in a new file (with a name that contains 'Regional_Taxon_List')."
+ "<br>After the upload is complete, execute "
+ "<a href='" + AntwebProps.getDomainApp() + "/utilData.do?action=populateFromAntwikiData'>" + AntwebProps.getDomainApp() + "/utilData.do?action=populateFromAntwikiData'</a>"
+ "<br>in order to push data from the antwiki_taxon_country into the geolocale_taxon table with source = 'antwiki'."
+ "<br><br>or"
Expand Down
20 changes: 18 additions & 2 deletions src/org/calacademy/antweb/util/PageTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ public static void add(HttpServletRequest request) {
}

String target = HttpUtil.getTarget(request);


int targetCount = PageTracker.getTargetCount(target);
if (targetCount > 0) {
s_log.warn("add() targetCount:" + targetCount + " target:" + target);
}

// Curator pages can go in here. Things that an admin would notice going wrong may be exempt.
if (target.contains("curate.do")
|| target.contains("adminAlert.do")
) return;

Tracker tracker = new Tracker();
tracker.setTarget(target);
tracker.setStartTime(new Date());
Expand Down Expand Up @@ -112,7 +118,17 @@ public static Date getTime(HttpServletRequest request) {
public static int getRequestCount() {
return trackerMap.size();
}


public static int getTargetCount(String target) {
if (target == null) return 0;
int targetCount = 0;
Collection<Tracker> trackers = trackerMap.values();
for (Tracker tracker : trackers) {
if (target.equals(tracker.getTarget())) targetCount = targetCount + 1;
}
return targetCount;
}

public static String showRequests() {
String message = "";

Expand Down
10 changes: 10 additions & 0 deletions src/org/calacademy/antweb/util/Queries.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public static ArrayList<String> getDevIntegrityNamesArray() {
public static ArrayList<NamedQuery> getAdminCheckQueries() {
String[] list = {
"brokenTaxaHierarchy"
, "geolocaleTaxaPresent"
//, "missingDefaultSpecimen"
};

Expand Down Expand Up @@ -211,6 +212,15 @@ private static ArrayList<NamedQuery> getTaxaNamedQueries() {
, ""
, "select taxon_name from taxon where taxarank = 'species' and (species is null or species = '') and taxon_name not like '%(%'"
));

// SHould be over 57000 records from: select count(*) from geolocale_taxon gt, geolocale g where gt.geolocale_id = g.id and g.georank = 'country';
queries.add(new NamedQuery(
"geolocaleTaxaPresent"
, "Geolocale Taxa Present: Aught to be at least 50,000 geolocale_taxa country records. Row will be returned if less, and that is a problem. Check literature records."
, ""
//, "select count(*) from geolocale_taxon gt, geolocale g where gt.geolocale_id = g.id and g.georank = 'country' having count(*) > 50000;"
, "select if (count(*) < 50000, 'records missing!', 0) isLow from geolocale_taxon gt, geolocale g where gt.geolocale_id = g.id and g.georank = 'country'"
));

queries.add(new NamedQuery(
"nonAsciiTaxonName"
Expand Down
18 changes: 13 additions & 5 deletions src/org/calacademy/antweb/util/QueryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public static String getQueryList(String listName) {
if (i == queries.size()) html += "</ul>";
}
return html;
}

}

// ----------------

Expand All @@ -53,11 +52,20 @@ public static String adminAlerts(Connection connection) throws SQLException {
ArrayList<NamedQuery> queryList = Queries.getAdminCheckQueries();
// Above, due to scrappy groups/login design, it is possible to not specify a admin_login for a group, and when the group is created
// and used for insertion of records (SpecimenUpload.java:309) there is no access_login created, causing problems at loadAllSpecimenFiles times.
A.log("Running adminAlerts:" + queryList);
for (NamedQuery namedQuery : queryList) {
String results = runNamedQueryHtml(namedQuery, connection);
//A.log("namedQuery:" + namedQuery + " results:" + results);
if (results != null)
if (!results.contains("rowCount:</b>0"))
message += results;
if ("geolocaleTaxaPresent".equals(namedQuery.getName())) {
if (results.contains("records missing")) {
s_log.warn("Investigate: " + results);
message += results;
}
} else{
if (!results.contains("rowCount:</b>0"))
message += results;
}
}
if ("".equals(message)) message = "Success";
return message;
Expand Down Expand Up @@ -280,7 +288,7 @@ public static String runNamedQueryHtml(NamedQuery namedQuery, Connection connect
if (namedQuery.getDesc() != null)
message.append("<br><br><b>Description:</b>" + namedQuery.getDesc() + "\r");

A.log("namedQuery:" + namedQuery.getDesc());
//A.log("namedQuery:" + namedQuery.getDesc());

message.append("<br><br><b>Query:</b> " + namedQuery.getQuery() + "\n");
message.append("<br><br><table>");
Expand Down
3 changes: 1 addition & 2 deletions src/org/calacademy/antweb/util/SessionRequestFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
ServletContext ctx = request.getSession().getServletContext();

PageTracker.add(request);



//A.log("target:"+ target);

Login accessLogin = LoginMgr.getAccessLogin(request);
Expand Down

0 comments on commit d57b849

Please sign in to comment.