Accurate purge count

This commit is contained in:
t00thpick1 2014-08-03 21:14:24 -04:00
parent ae5347bc0f
commit fe29bb4b9f

View File

@ -80,13 +80,13 @@ public final class SQLDatabaseManager implements DatabaseManager {
Connection connection = null; Connection connection = null;
Statement statement = null; Statement statement = null;
List<String> usernames = new ArrayList<String>(); int purged = 0;
try { try {
connection = connectionPool.getConnection(POOL_FETCH_TIMEOUT); connection = connectionPool.getConnection(POOL_FETCH_TIMEOUT);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("DELETE FROM u, e, h, s, c USING " + tablePrefix + "users u " + purged = statement.executeUpdate("DELETE FROM u, e, h, s, c USING " + tablePrefix + "users u " +
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " + "JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
@ -115,7 +115,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
} }
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database."); mcMMO.p.getLogger().info("Purged " + purged + " users from the database.");
} }
public void purgeOldUsers() { public void purgeOldUsers() {
@ -123,13 +123,13 @@ public final class SQLDatabaseManager implements DatabaseManager {
Connection connection = null; Connection connection = null;
Statement statement = null; Statement statement = null;
List<String> usernames = new ArrayList<String>(); int purged = 0;
try { try {
connection = connectionPool.getConnection(POOL_FETCH_TIMEOUT); connection = connectionPool.getConnection(POOL_FETCH_TIMEOUT);
statement = connection.createStatement(); statement = connection.createStatement();
statement.executeUpdate("DELETE FROM u, e, h, s, c USING " + tablePrefix + "users u " + purged = statement.executeUpdate("DELETE FROM u, e, h, s, c USING " + tablePrefix + "users u " +
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " + "JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
@ -158,7 +158,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
} }
} }
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database."); mcMMO.p.getLogger().info("Purged " + purged + " users from the database.");
} }
public boolean removeUser(String playerName) { public boolean removeUser(String playerName) {