Skip to content

Commit

Permalink
fix cv bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaojianli committed May 7, 2024
1 parent 5a11f80 commit 1548b1d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,10 @@ public String getMetadata(String key) throws SQLException {
}
}

public long queryBanLogsCount(Date from, Date to) throws SQLException {
public long queryBanLogsCount() throws SQLException {
try (Connection connection = manager.getConnection()) {
PreparedStatement ps;
if (from == null && to == null) {
ps = connection.prepareStatement("SELECT COUNT(*) AS count FROM ban_logs");
} else {
if (from == null || to == null) {
throw new IllegalArgumentException("from or null cannot be null if any provided");
} else {
ps = connection.prepareStatement("SELECT COUNT(*) AS count FROM ban_logs");
}
}
if (from != null) {
ps.setDate(1, from);
ps.setDate(2, to);
}
@Cleanup
ResultSet set = ps.executeQuery();
ResultSet set = connection.createStatement().executeQuery("SELECT COUNT(*) AS count FROM ban_logs");
return set.getLong("count");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public NanoHTTPD.Response handle(NanoHTTPD.IHTTPSession session) {
map.put("pageIndex", pageIndex);
map.put("pageSize", pageSize);
map.put("results", db.queryBanLogs(null, null, pageIndex, pageSize));
map.put("total", db.queryBanLogsCount(null,null));
map.put("total", db.queryBanLogsCount());
return HTTPUtil.cors(NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.OK, "application/json", JsonUtil.prettyPrinting().toJson(map)));
} catch (SQLException e) {
log.error(Lang.WEB_BANLOGS_INTERNAL_ERROR, e);
Expand Down

0 comments on commit 1548b1d

Please sign in to comment.