mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-06 15:44:49 +08:00
Fixes Last Peak time not showing up #726
This commit is contained in:
parent
0fceaaf9e1
commit
ac3e9a969c
@ -14,9 +14,9 @@ import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class SQLFetchOps extends SQLOps implements FetchOperations {
|
||||
|
||||
@ -72,7 +72,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
||||
return null;
|
||||
});
|
||||
container.putSupplier(ServerKeys.RECENT_PEAK_PLAYERS, () -> {
|
||||
long twoDaysAgo = System.currentTimeMillis() - (TimeAmount.DAY.ms() * 2L);
|
||||
long twoDaysAgo = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(2);
|
||||
Optional<TPS> lastPeak = tpsTable.getPeakPlayerCount(serverUUID, twoDaysAgo);
|
||||
if (lastPeak.isPresent()) {
|
||||
TPS peak = lastPeak.get();
|
||||
|
@ -151,9 +151,12 @@ public class TPSTable extends Table {
|
||||
}
|
||||
|
||||
public Optional<TPS> getPeakPlayerCount(UUID serverUUID, long afterDate) {
|
||||
String subStatement = "SELECT MAX(" + Col.PLAYERS_ONLINE + ") FROM " + tableName +
|
||||
" WHERE " + Col.SERVER_ID + "=" + serverTable.statementSelectServerID +
|
||||
" AND " + Col.DATE + ">= ?";
|
||||
String sql = Select.all(tableName)
|
||||
.where(Col.SERVER_ID + "=" + serverTable.statementSelectServerID)
|
||||
.and(Col.PLAYERS_ONLINE + "= (SELECT MAX(" + Col.PLAYERS_ONLINE + ") FROM " + tableName + ")")
|
||||
.and(Col.PLAYERS_ONLINE + "= (" + subStatement + ")")
|
||||
.and(Col.DATE + ">= ?")
|
||||
.toString();
|
||||
|
||||
@ -161,13 +164,14 @@ public class TPSTable extends Table {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, afterDate);
|
||||
statement.setString(2, serverUUID.toString());
|
||||
statement.setLong(3, afterDate);
|
||||
statement.setLong(4, afterDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TPS> processResults(ResultSet set) throws SQLException {
|
||||
if (set.next()) {
|
||||
|
||||
TPS tps = TPSBuilder.get()
|
||||
.date(set.getLong(Col.DATE.get()))
|
||||
.tps(set.getDouble(Col.TPS.get()))
|
||||
|
Loading…
Reference in New Issue
Block a user