table checks + task timer 1m -> 10s

This commit is contained in:
Gxorge committed 2023-05-23 00:04:51 +01:00
1 parent 937273607c
commit e462263e0c
2 files changed
+40 -2

No files matched your search

@@ -35,6 +35,8 @@ public class DatabaseManager {
checkWebTable();
checkLinkCodeTable();
checkStaffIpTable();
checkAuditTable();
checkAppealTable();
}
public Connection createConnection() throws SQLException, ClassNotFoundException {
@@ -325,7 +327,7 @@ public class DatabaseManager {
private void checkAuditTable() {
try (Connection connection = createConnection()) {
DatabaseMetaData meta = connection.getMetaData();
ResultSet resultSet = meta.getTables(null, null, "staffog_staffip", new String[] {"TABLE"});
ResultSet resultSet = meta.getTables(null, null, "staffog_audit", new String[] {"TABLE"});
if (resultSet.next()) {
return;
@@ -349,4 +351,40 @@ public class DatabaseManager {
e.printStackTrace();
}
}
private void checkAppealTable() {
try (Connection connection = createConnection()) {
DatabaseMetaData meta = connection.getMetaData();
ResultSet resultSet = meta.getTables(null, null, "staffog_appeal", new String[] {"TABLE"});
if (resultSet.next()) {
return;
}
// Table does not exist
Statement statement = connection.createStatement();
String sql = "CREATE TABLE `staffog_appeal` (" +
" `id` int(11) NOT NULL AUTO_INCREMENT," +
" `uuid` varchar(36) NOT NULL," +
" `time` bigint(20) NOT NULL," +
" `type` varchar(128) NOT NULL," +
" `pid` int(11) NOT NULL," +
" `reason` varchar(2048) NOT NULL," +
" `open` bit(1) NOT NULL DEFAULT b'1'," +
" `assigned` varchar(36) DEFAULT NULL," +
" `verdict` bit(1) DEFAULT NULL," +
" `verdict_time` bigint(20) DEFAULT NULL," +
" `comment` varchar(2048) DEFAULT NULL," +
" PRIMARY KEY (`id`)" +
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4";
statement.executeUpdate(sql);
Console.info("Created 'staffog_appeal' table, was missing.");
} catch (Exception e) {
Console.error("Failed to check 'staffog_appeal' table.");
e.printStackTrace();
}
}
}
@@ -32,7 +32,7 @@ public class TaskManager {
}
}
}
}, 0, 1200);
}, 0, 200);
}
private ArrayList<TaskEntry> checkForTasks() {