mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-30 13:08:00 +01:00
parent
6d9ef8a3db
commit
e52f082200
@ -36,17 +36,19 @@ public class BadNukkitRegisterValuePatch extends Patch {
|
||||
|
||||
@Override
|
||||
public boolean hasBeenApplied() {
|
||||
return !hasWrongRegisterDates();
|
||||
return hasNoWrongRegisterDates(UserInfoTable.TABLE_NAME, UserInfoTable.REGISTERED)
|
||||
&& hasNoWrongRegisterDates(UsersTable.TABLE_NAME, UsersTable.REGISTERED);
|
||||
}
|
||||
|
||||
public boolean hasWrongRegisterDates() {
|
||||
String sql = SELECT + "COUNT(*) as c" + FROM + UserInfoTable.TABLE_NAME + WHERE + UserInfoTable.REGISTERED + "<?";
|
||||
return query(new HasMoreThanZeroQueryStatement(sql) {
|
||||
public boolean hasNoWrongRegisterDates(String tableName, String registered) {
|
||||
String sql = SELECT + "COUNT(*) as c" + FROM + tableName + WHERE + registered + "<?";
|
||||
Boolean foundWrongRegisterDates = query(new HasMoreThanZeroQueryStatement(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setLong(1, 20000000); // Before 20th August 1970
|
||||
statement.setLong(1, System.currentTimeMillis() / 1000L);
|
||||
}
|
||||
});
|
||||
return !foundWrongRegisterDates;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +64,7 @@ public class BadNukkitRegisterValuePatch extends Patch {
|
||||
execute(new ExecStatement(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setLong(1, 20000000); // Before 20th August 1970
|
||||
statement.setLong(1, System.currentTimeMillis() / 1000L);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -29,9 +29,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
abstract class DBPatchRegressionTest {
|
||||
|
||||
private String insertServer = "INSERT INTO plan_servers (uuid) VALUES ('" + TestConstants.SERVER_UUID + "')";
|
||||
private String insertUser = "INSERT INTO plan_users (uuid, name, registered) VALUES ('" + TestConstants.PLAYER_ONE_UUID + "', 'TestName', 1234)";
|
||||
private String insertUser2 = "INSERT INTO plan_users (uuid, name, registered) VALUES ('" + TestConstants.PLAYER_TWO_UUID + "', 'TestName2', 1234)";
|
||||
private String insertUserInfo = "INSERT INTO plan_user_info (user_id, registered, server_id) VALUES (1, 1234, 1)";
|
||||
private String insertUser = "INSERT INTO plan_users (uuid, name, registered) VALUES ('" + TestConstants.PLAYER_ONE_UUID + "', 'TestName', " + 1581687385 + ")";
|
||||
private String insertUser2 = "INSERT INTO plan_users (uuid, name, registered) VALUES ('" + TestConstants.PLAYER_TWO_UUID + "', 'TestName2', " + System.currentTimeMillis() + ")";
|
||||
private String insertUserInfo = "INSERT INTO plan_user_info (user_id, registered, server_id) VALUES (1, " + System.currentTimeMillis() + ", 1)";
|
||||
private String insertIP = "INSERT INTO plan_ips (user_id, ip, geolocation, ip_hash, last_used) VALUES (1, '1.1.1.1', 'Finland', 'hash', 1234)";
|
||||
private String insertNickname = "INSERT INTO plan_nicknames (user_id, nickname, server_id, last_used) VALUES (1, 'Nickname', 1, 1234)";
|
||||
private String insertSession = "INSERT INTO plan_sessions (user_id, server_id, session_start, session_end, mob_kills, deaths, afk_time) VALUES (1,1,1234,5678,2,2,2)";
|
||||
|
Loading…
Reference in New Issue
Block a user