Skip to content

Instantly share code, notes, and snippets.

@riking
Created June 8, 2013 05:34
Show Gist options
  • Save riking/5734179 to your computer and use it in GitHub Desktop.
Save riking/5734179 to your computer and use it in GitHub Desktop.
public void purgePowerlessUsers() {
mcMMO.p.getLogger().info("Purging powerless users...");
try {
// This does the deleting and returns the usernames of who we deleted
ResultSet result = SQLStatements.getInstance().getStatement("powerlessPurge").executeQuery();
int purgeCount = 0;
while (result.next()) {
Misc.profileCleanup(result.getString(0));
purgeCount++;
}
mcMMO.p.getLogger().info("Purged " + purgeCount + " users from the database.");
} catch (SQLException e) {
printErrors(e);
}
}
addStatement("powerlessPurge",
"SELECT u.user FROM OLD TABLE (" +
"DELETE FROM u, e, h, s, c USING {TAB}users u " +
"JOIN {TAB}experience e ON (u.id = e.user_id) " +
"JOIN {TAB}huds h ON (u.id = h.user_id) " +
"JOIN {TAB}skills s ON (u.id = s.user_id) " +
"JOIN {TAB}cooldowns c ON (u.id = c.user_id) " +
"WHERE (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0" +
")");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment