Skip to content

Commit

Permalink
Update NationDB.java
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed May 3, 2024
1 parent 3c89704 commit 1916bac
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/main/java/link/locutus/discord/db/NationDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -4307,14 +4307,11 @@ public Map<Integer, List<AllianceChange>> getRemovesByAlliances(Set<Integer> all
Set<Integer> fastMap = new IntOpenHashSet(alliances);
List<Integer> alliancesSorted = new ArrayList<>(alliances);
alliancesSorted.sort(Comparator.naturalOrder());
String query = "SELECT * FROM KICKS2 WHERE (from_aa IN (?) OR to_aa IN (?))" + (cutoff > 0 ? " AND date > ? " : "") + "ORDER BY date DESC";
String alliancesSortedStr = alliancesSorted.stream().map(String::valueOf).collect(Collectors.joining(","));
String query = "SELECT * FROM KICKS2 WHERE (from_aa IN " + StringMan.getString(alliancesSorted) + " OR to_aa IN " + StringMan.getString(alliancesSorted) + ")" + (cutoff > 0 ? " AND date > ? " : "") + "ORDER BY date DESC";

try (PreparedStatement stmt = getConnection().prepareStatement(query)) {
stmt.setString(1, alliancesSortedStr);
stmt.setString(2, alliancesSortedStr);
if (cutoff > 0) {
stmt.setLong(3, cutoff);
stmt.setLong(1, cutoff);
}
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
Expand Down

0 comments on commit 1916bac

Please sign in to comment.