mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-23 16:41:22 +01:00
Moved some queries to different files
This commit is contained in:
parent
0b74d53918
commit
25b036aff2
@ -161,129 +161,4 @@ public class ServerAggregateQueries {
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> sessionCount(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "COUNT(1) as count" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
WHERE + SessionsTable.SERVER_UUID + "=?" +
|
||||
AND + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("count") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> playerKillCount(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "COUNT(1) as count" +
|
||||
FROM + KillsTable.TABLE_NAME +
|
||||
WHERE + KillsTable.SERVER_UUID + "=?" +
|
||||
AND + KillsTable.DATE + ">=?" +
|
||||
AND + KillsTable.DATE + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("count") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> mobKillCount(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "SUM(" + SessionsTable.MOB_KILLS + ") as count" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
WHERE + SessionsTable.SERVER_UUID + "=?" +
|
||||
AND + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("count") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> deathCount(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "SUM(" + SessionsTable.DEATHS + ") as count" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
WHERE + SessionsTable.SERVER_UUID + "=?" +
|
||||
AND + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("count") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> playtime(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + ") as playtime" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
WHERE + SessionsTable.SERVER_UUID + "=?" +
|
||||
AND + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("playtime") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> afkTime(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "SUM(" + SessionsTable.AFK_TIME + ") as afk_time" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
WHERE + SessionsTable.SERVER_UUID + "=?" +
|
||||
AND + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("afk_time") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.db.access.queries.objects;
|
||||
|
||||
import com.djrapitops.plan.data.container.PlayerKill;
|
||||
import com.djrapitops.plan.db.access.Query;
|
||||
import com.djrapitops.plan.db.access.QueryStatement;
|
||||
import com.djrapitops.plan.db.sql.tables.KillsTable;
|
||||
import com.djrapitops.plan.db.sql.tables.SessionsTable;
|
||||
import com.djrapitops.plan.db.sql.tables.UsersTable;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.*;
|
||||
|
||||
/**
|
||||
* Queries for {@link com.djrapitops.plan.data.container.PlayerKill} and {@link com.djrapitops.plan.data.container.PlayerDeath} objects.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class KillQueries {
|
||||
|
||||
private KillQueries() {
|
||||
// Static method class
|
||||
}
|
||||
|
||||
public static Query<List<PlayerKill>> fetchMostRecentPlayerKills(UUID serverUUID, int limit) {
|
||||
String sql = SELECT + KillsTable.VICTIM_UUID + ", " +
|
||||
"v." + UsersTable.USER_NAME + " as victim_name, " +
|
||||
"k." + UsersTable.USER_NAME + " as killer_name," +
|
||||
KillsTable.DATE + ", " +
|
||||
KillsTable.WEAPON +
|
||||
FROM + KillsTable.TABLE_NAME +
|
||||
INNER_JOIN + UsersTable.TABLE_NAME + " v on v." + UsersTable.USER_UUID + "=" + KillsTable.VICTIM_UUID +
|
||||
INNER_JOIN + UsersTable.TABLE_NAME + " k on k." + UsersTable.USER_UUID + "=" + KillsTable.KILLER_UUID +
|
||||
WHERE + KillsTable.TABLE_NAME + '.' + KillsTable.SERVER_UUID + "=?" +
|
||||
ORDER_BY + KillsTable.DATE + " DESC LIMIT ?";
|
||||
|
||||
return new QueryStatement<List<PlayerKill>>(sql, limit) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setInt(2, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerKill> processResults(ResultSet set) throws SQLException {
|
||||
List<PlayerKill> kills = new ArrayList<>();
|
||||
while (set.next()) {
|
||||
extractKillFromResults(set).ifPresent(kills::add);
|
||||
}
|
||||
return kills;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static Optional<PlayerKill> extractKillFromResults(ResultSet set) throws SQLException {
|
||||
String victimName = set.getString("victim_name");
|
||||
String killerName = set.getString("killer_name");
|
||||
if (victimName != null && killerName != null) {
|
||||
UUID victim = UUID.fromString(set.getString(KillsTable.VICTIM_UUID));
|
||||
long date = set.getLong(KillsTable.DATE);
|
||||
String weapon = set.getString(KillsTable.WEAPON);
|
||||
return Optional.of(new PlayerKill(victim, weapon, date, victimName, killerName));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public static Query<Long> playerKillCount(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "COUNT(1) as count" +
|
||||
FROM + KillsTable.TABLE_NAME +
|
||||
WHERE + KillsTable.SERVER_UUID + "=?" +
|
||||
AND + KillsTable.DATE + ">=?" +
|
||||
AND + KillsTable.DATE + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("count") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Double> averageKDR(long after, long before, UUID serverUUID) {
|
||||
String selectKillCounts = SELECT + "COUNT(1) as kills," + KillsTable.KILLER_UUID +
|
||||
FROM + KillsTable.TABLE_NAME +
|
||||
WHERE + KillsTable.SERVER_UUID + "=?" +
|
||||
AND + KillsTable.DATE + ">=?" +
|
||||
AND + KillsTable.DATE + "<=?" +
|
||||
GROUP_BY + KillsTable.KILLER_UUID;
|
||||
String selectDeathCounts = SELECT + "COUNT(1) as deaths," + KillsTable.VICTIM_UUID +
|
||||
FROM + KillsTable.TABLE_NAME +
|
||||
WHERE + KillsTable.SERVER_UUID + "=?" +
|
||||
AND + KillsTable.DATE + ">=?" +
|
||||
AND + KillsTable.DATE + "<=?" +
|
||||
GROUP_BY + KillsTable.VICTIM_UUID;
|
||||
String sql = SELECT + "AVG(kills/deaths) as kdr" +
|
||||
FROM + '(' + selectKillCounts + ") q1" +
|
||||
INNER_JOIN + '(' + selectDeathCounts + ") q2 on q1." + KillsTable.KILLER_UUID + "=q2." + KillsTable.VICTIM_UUID;
|
||||
|
||||
return new QueryStatement<Double>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
statement.setString(4, serverUUID.toString());
|
||||
statement.setLong(5, after);
|
||||
statement.setLong(6, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getDouble("kdr") : 0.0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> mobKillCount(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "SUM(" + SessionsTable.MOB_KILLS + ") as count" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
WHERE + SessionsTable.SERVER_UUID + "=?" +
|
||||
AND + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("count") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> deathCount(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "SUM(" + SessionsTable.DEATHS + ") as count" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
WHERE + SessionsTable.SERVER_UUID + "=?" +
|
||||
AND + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("count") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.db.access.queries.objects;
|
||||
|
||||
import com.djrapitops.plan.data.container.PlayerKill;
|
||||
import com.djrapitops.plan.db.access.Query;
|
||||
import com.djrapitops.plan.db.access.QueryStatement;
|
||||
import com.djrapitops.plan.db.sql.tables.KillsTable;
|
||||
import com.djrapitops.plan.db.sql.tables.UsersTable;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.*;
|
||||
|
||||
/**
|
||||
* Queries for {@link com.djrapitops.plan.data.container.PlayerKill} and {@link com.djrapitops.plan.data.container.PlayerDeath} objects.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlayerKillQueries {
|
||||
|
||||
private PlayerKillQueries() {
|
||||
// Static method class
|
||||
}
|
||||
|
||||
public static Query<List<PlayerKill>> fetchMostRecentPlayerKills(UUID serverUUID, int limit) {
|
||||
String sql = SELECT + KillsTable.VICTIM_UUID + ", " +
|
||||
"v." + UsersTable.USER_NAME + " as victim_name, " +
|
||||
"k." + UsersTable.USER_NAME + " as killer_name," +
|
||||
KillsTable.DATE + ", " +
|
||||
KillsTable.WEAPON +
|
||||
FROM + KillsTable.TABLE_NAME +
|
||||
INNER_JOIN + UsersTable.TABLE_NAME + " v on v." + UsersTable.USER_UUID + "=" + KillsTable.VICTIM_UUID +
|
||||
INNER_JOIN + UsersTable.TABLE_NAME + " k on k." + UsersTable.USER_UUID + "=" + KillsTable.KILLER_UUID +
|
||||
WHERE + KillsTable.TABLE_NAME + '.' + KillsTable.SERVER_UUID + "=?" +
|
||||
ORDER_BY + KillsTable.DATE + " DESC LIMIT ?";
|
||||
|
||||
return new QueryStatement<List<PlayerKill>>(sql, limit) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setInt(2, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PlayerKill> processResults(ResultSet set) throws SQLException {
|
||||
List<PlayerKill> kills = new ArrayList<>();
|
||||
while (set.next()) {
|
||||
extractKillFromResults(set).ifPresent(kills::add);
|
||||
}
|
||||
return kills;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static Optional<PlayerKill> extractKillFromResults(ResultSet set) throws SQLException {
|
||||
String victimName = set.getString("victim_name");
|
||||
String killerName = set.getString("killer_name");
|
||||
if (victimName != null && killerName != null) {
|
||||
UUID victim = UUID.fromString(set.getString(KillsTable.VICTIM_UUID));
|
||||
long date = set.getLong(KillsTable.DATE);
|
||||
String weapon = set.getString(KillsTable.WEAPON);
|
||||
return Optional.of(new PlayerKill(victim, weapon, date, victimName, killerName));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
@ -320,4 +320,67 @@ public class SessionQueries {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> sessionCount(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "COUNT(1) as count" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
WHERE + SessionsTable.SERVER_UUID + "=?" +
|
||||
AND + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("count") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> playtime(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + ") as playtime" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
WHERE + SessionsTable.SERVER_UUID + "=?" +
|
||||
AND + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("playtime") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> afkTime(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "SUM(" + SessionsTable.AFK_TIME + ") as afk_time" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
WHERE + SessionsTable.SERVER_UUID + "=?" +
|
||||
AND + SessionsTable.SESSION_END + ">=?" +
|
||||
AND + SessionsTable.SESSION_START + "<=?";
|
||||
return new QueryStatement<Long>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
statement.setLong(2, after);
|
||||
statement.setLong(3, before);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
return set.next() ? set.getLong("afk_time") : 0L;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ import com.djrapitops.plan.data.store.mutators.PlayerKillMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.containers.ServerPlayersTableContainersQuery;
|
||||
import com.djrapitops.plan.db.access.queries.objects.PlayerKillQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.KillQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.SessionQueries;
|
||||
import com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerPlayerDataTableQuery;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
@ -90,7 +90,7 @@ public class JSONFactory {
|
||||
|
||||
public List<Map<String, Object>> serverPlayerKillsAsJSONMap(UUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
List<PlayerKill> kills = db.query(PlayerKillQueries.fetchMostRecentPlayerKills(serverUUID, 100));
|
||||
List<PlayerKill> kills = db.query(KillQueries.fetchMostRecentPlayerKills(serverUUID, 100));
|
||||
return new PlayerKillMutator(kills).toJSONAsMap(formatters);
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@ import com.djrapitops.plan.data.store.mutators.PlayersOnlineResolver;
|
||||
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.data.store.mutators.TPSMutator;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.ServerAggregateQueries;
|
||||
import com.djrapitops.plan.db.access.queries.analysis.PlayerCountQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.SessionQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.TPSQueries;
|
||||
@ -132,11 +131,11 @@ public class OnlineActivityOverviewJSONParser {
|
||||
numbers.put("new_players_retention_24h", 0); // TODO
|
||||
numbers.put("new_players_retention_24h_perc", percentageFormatter.apply(-1.0)); // TODO
|
||||
|
||||
Long playtimeMonth = db.query(ServerAggregateQueries.playtime(monthAgo, now, serverUUID));
|
||||
Long playtimeWeek = db.query(ServerAggregateQueries.playtime(weekAgo, now, serverUUID));
|
||||
Long playtimeDay = db.query(ServerAggregateQueries.playtime(dayAgo, now, serverUUID));
|
||||
Long playtimeBefore = db.query(ServerAggregateQueries.playtime(monthAgo, halfMonthAgo, serverUUID));
|
||||
Long playtimeAfter = db.query(ServerAggregateQueries.playtime(halfMonthAgo, now, serverUUID));
|
||||
Long playtimeMonth = db.query(SessionQueries.playtime(monthAgo, now, serverUUID));
|
||||
Long playtimeWeek = db.query(SessionQueries.playtime(weekAgo, now, serverUUID));
|
||||
Long playtimeDay = db.query(SessionQueries.playtime(dayAgo, now, serverUUID));
|
||||
Long playtimeBefore = db.query(SessionQueries.playtime(monthAgo, halfMonthAgo, serverUUID));
|
||||
Long playtimeAfter = db.query(SessionQueries.playtime(halfMonthAgo, now, serverUUID));
|
||||
numbers.put("playtime_30d", timeAmountFormatter.apply(playtimeMonth));
|
||||
numbers.put("playtime_30d_trend", new Trend(playtimeBefore, playtimeAfter, false, timeAmountFormatter));
|
||||
numbers.put("playtime_7d", timeAmountFormatter.apply(playtimeWeek));
|
||||
@ -153,11 +152,11 @@ public class OnlineActivityOverviewJSONParser {
|
||||
numbers.put("playtime_7d_avg", timeAmountFormatter.apply(-1L));
|
||||
numbers.put("playtime_24h_avg", timeAmountFormatter.apply(-1L));
|
||||
|
||||
Long sessionsMonth = db.query(ServerAggregateQueries.sessionCount(monthAgo, now, serverUUID));
|
||||
Long sessionsWeek = db.query(ServerAggregateQueries.sessionCount(weekAgo, now, serverUUID));
|
||||
Long sessionsDay = db.query(ServerAggregateQueries.sessionCount(dayAgo, now, serverUUID));
|
||||
Long sessionsBefore = db.query(ServerAggregateQueries.sessionCount(monthAgo, halfMonthAgo, serverUUID));
|
||||
Long sessionsAfter = db.query(ServerAggregateQueries.sessionCount(halfMonthAgo, now, serverUUID));
|
||||
Long sessionsMonth = db.query(SessionQueries.sessionCount(monthAgo, now, serverUUID));
|
||||
Long sessionsWeek = db.query(SessionQueries.sessionCount(weekAgo, now, serverUUID));
|
||||
Long sessionsDay = db.query(SessionQueries.sessionCount(dayAgo, now, serverUUID));
|
||||
Long sessionsBefore = db.query(SessionQueries.sessionCount(monthAgo, halfMonthAgo, serverUUID));
|
||||
Long sessionsAfter = db.query(SessionQueries.sessionCount(halfMonthAgo, now, serverUUID));
|
||||
numbers.put("sessions_30d", sessionsMonth);
|
||||
numbers.put("sessions_30d_trend", new Trend(sessionsBefore, sessionsAfter, false));
|
||||
numbers.put("sessions_7d", sessionsWeek);
|
||||
|
@ -23,6 +23,8 @@ import com.djrapitops.plan.data.store.objects.DateObj;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.ServerAggregateQueries;
|
||||
import com.djrapitops.plan.db.access.queries.analysis.PlayerCountQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.KillQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.SessionQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.TPSQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
@ -117,12 +119,12 @@ public class ServerOverviewJSONParser {
|
||||
numbers.put("last_peak_players", lastPeak.map(dateObj -> dateObj.getValue().toString()).orElse("-"));
|
||||
numbers.put("best_peak_date", allTimePeak.map(dateFormatter).orElse("-"));
|
||||
numbers.put("best_peak_players", allTimePeak.map(dateObj -> dateObj.getValue().toString()).orElse("-"));
|
||||
numbers.put("playtime", timeAmountFormatter.apply(db.query(ServerAggregateQueries.playtime(0L, now, serverUUID))));
|
||||
numbers.put("playtime", timeAmountFormatter.apply(db.query(SessionQueries.playtime(0L, now, serverUUID))));
|
||||
numbers.put("player_playtime", "-"); // TODO
|
||||
numbers.put("sessions", db.query(ServerAggregateQueries.sessionCount(0L, now, serverUUID)));
|
||||
numbers.put("player_kills", db.query(ServerAggregateQueries.playerKillCount(0L, now, serverUUID)));
|
||||
numbers.put("mob_kills", db.query(ServerAggregateQueries.mobKillCount(0L, now, serverUUID)));
|
||||
numbers.put("deaths", db.query(ServerAggregateQueries.deathCount(0L, now, serverUUID)));
|
||||
numbers.put("sessions", db.query(SessionQueries.sessionCount(0L, now, serverUUID)));
|
||||
numbers.put("player_kills", db.query(KillQueries.playerKillCount(0L, now, serverUUID)));
|
||||
numbers.put("mob_kills", db.query(KillQueries.mobKillCount(0L, now, serverUUID)));
|
||||
numbers.put("deaths", db.query(KillQueries.deathCount(0L, now, serverUUID)));
|
||||
|
||||
return numbers;
|
||||
}
|
||||
@ -161,36 +163,36 @@ public class ServerOverviewJSONParser {
|
||||
weeks.put("regular_after", "-");
|
||||
weeks.put("regular_trend", new Trend(0, 0, false));
|
||||
|
||||
Long playtimeBefore = db.query(ServerAggregateQueries.playtime(twoWeeksAgo, oneWeekAgo, serverUUID));
|
||||
Long playtimeAfter = db.query(ServerAggregateQueries.playtime(oneWeekAgo, now, serverUUID));
|
||||
Long playtimeBefore = db.query(SessionQueries.playtime(twoWeeksAgo, oneWeekAgo, serverUUID));
|
||||
Long playtimeAfter = db.query(SessionQueries.playtime(oneWeekAgo, now, serverUUID));
|
||||
Trend playtimeTrend = new Trend(playtimeBefore, playtimeAfter, false, timeAmountFormatter);
|
||||
weeks.put("playtime_before", timeAmountFormatter.apply(playtimeBefore));
|
||||
weeks.put("playtime_after", timeAmountFormatter.apply(playtimeAfter));
|
||||
weeks.put("playtime_trend", playtimeTrend);
|
||||
|
||||
Long sessionsBefore = db.query(ServerAggregateQueries.sessionCount(twoWeeksAgo, oneWeekAgo, serverUUID));
|
||||
Long sessionsAfter = db.query(ServerAggregateQueries.sessionCount(oneWeekAgo, now, serverUUID));
|
||||
Long sessionsBefore = db.query(SessionQueries.sessionCount(twoWeeksAgo, oneWeekAgo, serverUUID));
|
||||
Long sessionsAfter = db.query(SessionQueries.sessionCount(oneWeekAgo, now, serverUUID));
|
||||
Trend sessionsTrend = new Trend(sessionsBefore, sessionsAfter, false);
|
||||
weeks.put("sessions_before", sessionsBefore);
|
||||
weeks.put("sessions_after", sessionsAfter);
|
||||
weeks.put("sessions_trend", sessionsTrend);
|
||||
|
||||
Long pksBefore = db.query(ServerAggregateQueries.playerKillCount(twoWeeksAgo, oneWeekAgo, serverUUID));
|
||||
Long pksAfter = db.query(ServerAggregateQueries.playerKillCount(oneWeekAgo, now, serverUUID));
|
||||
Long pksBefore = db.query(KillQueries.playerKillCount(twoWeeksAgo, oneWeekAgo, serverUUID));
|
||||
Long pksAfter = db.query(KillQueries.playerKillCount(oneWeekAgo, now, serverUUID));
|
||||
Trend pksTrend = new Trend(pksBefore, pksAfter, false);
|
||||
weeks.put("player_kills_before", pksBefore);
|
||||
weeks.put("player_kills_after", pksAfter);
|
||||
weeks.put("player_kills_trend", pksTrend);
|
||||
|
||||
Long mkBefore = db.query(ServerAggregateQueries.mobKillCount(twoWeeksAgo, oneWeekAgo, serverUUID));
|
||||
Long mkAfter = db.query(ServerAggregateQueries.mobKillCount(oneWeekAgo, now, serverUUID));
|
||||
Long mkBefore = db.query(KillQueries.mobKillCount(twoWeeksAgo, oneWeekAgo, serverUUID));
|
||||
Long mkAfter = db.query(KillQueries.mobKillCount(oneWeekAgo, now, serverUUID));
|
||||
Trend mkTrend = new Trend(mkBefore, mkAfter, false);
|
||||
weeks.put("mob_kills_before", mkBefore);
|
||||
weeks.put("mob_kills_after", mkAfter);
|
||||
weeks.put("mob_kills_trend", mkTrend);
|
||||
|
||||
Long deathsBefore = db.query(ServerAggregateQueries.deathCount(twoWeeksAgo, oneWeekAgo, serverUUID));
|
||||
Long deathsAfter = db.query(ServerAggregateQueries.deathCount(oneWeekAgo, now, serverUUID));
|
||||
Long deathsBefore = db.query(KillQueries.deathCount(twoWeeksAgo, oneWeekAgo, serverUUID));
|
||||
Long deathsAfter = db.query(KillQueries.deathCount(oneWeekAgo, now, serverUUID));
|
||||
Trend deathTrend = new Trend(deathsBefore, deathsAfter, true);
|
||||
weeks.put("deaths_before", deathsBefore);
|
||||
weeks.put("deaths_after", deathsAfter);
|
||||
|
@ -21,7 +21,7 @@ import com.djrapitops.plan.data.store.mutators.TPSMutator;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.data.time.GMTimes;
|
||||
import com.djrapitops.plan.db.Database;
|
||||
import com.djrapitops.plan.db.access.queries.ServerAggregateQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.SessionQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.TPSQueries;
|
||||
import com.djrapitops.plan.db.access.queries.objects.WorldTimesQueries;
|
||||
import com.djrapitops.plan.system.database.DBSystem;
|
||||
@ -92,8 +92,8 @@ public class SessionsOverviewJSONParser {
|
||||
insights.put("server_occupied", timeAmountFormatter.apply(occupied));
|
||||
insights.put("server_occupied_perc", uptime != 0 ? percentageFormatter.apply(1.0 * occupied / uptime) : "-");
|
||||
|
||||
Long playtime = db.query(ServerAggregateQueries.playtime(monthAgo, now, serverUUID));
|
||||
Long afkTime = db.query(ServerAggregateQueries.afkTime(monthAgo, now, serverUUID));
|
||||
Long playtime = db.query(SessionQueries.playtime(monthAgo, now, serverUUID));
|
||||
Long afkTime = db.query(SessionQueries.afkTime(monthAgo, now, serverUUID));
|
||||
insights.put("total_playtime", timeAmountFormatter.apply(playtime));
|
||||
insights.put("afk_time", timeAmountFormatter.apply(afkTime));
|
||||
insights.put("afk_time_perc", playtime != 0 ? percentageFormatter.apply(1.0 * afkTime / playtime) : "-");
|
||||
|
Loading…
Reference in New Issue
Block a user