mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 09:00:28 +08:00
Fixes Clean SQLException of TPS Table
This commit is contained in:
parent
e8cc93ea21
commit
6ddaf8dec8
@ -132,12 +132,18 @@ public class TPSTable extends Table {
|
|||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public void clean() throws SQLException {
|
public void clean() throws SQLException {
|
||||||
|
Optional<TPS> allTimePeak = getAllTimePeak();
|
||||||
|
int p = -1;
|
||||||
|
if (allTimePeak.isPresent()) {
|
||||||
|
p = allTimePeak.get().getPlayers();
|
||||||
|
}
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
statement = prepareStatement("DELETE FROM " + tableName +
|
statement = prepareStatement("DELETE FROM " + tableName +
|
||||||
" WHERE (" + columnDate + "<?)" +
|
" WHERE (" + columnDate + "<?)" +
|
||||||
" AND (" + columnPlayers + "" +
|
" AND (" + columnPlayers + "" +
|
||||||
" != (SELECT MAX(" + columnPlayers + ") FROM " + tableName + "))");
|
" != ?)");
|
||||||
|
statement.setInt(1, p);
|
||||||
// More than 2 Months ago.
|
// More than 2 Months ago.
|
||||||
long fiveWeeks = TimeAmount.MONTH.ms() * 2L;
|
long fiveWeeks = TimeAmount.MONTH.ms() * 2L;
|
||||||
statement.setLong(1, MiscUtils.getTime() - fiveWeeks);
|
statement.setLong(1, MiscUtils.getTime() - fiveWeeks);
|
||||||
|
Loading…
Reference in New Issue
Block a user