diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/ServerAggregateQueries.java b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/ServerAggregateQueries.java
index 0a88369ce..75bc15f0c 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/ServerAggregateQueries.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/ServerAggregateQueries.java
@@ -160,4 +160,126 @@ public class ServerAggregateQueries {
}
};
}
+
+ public static Query totalPlaytime(UUID serverUUID) {
+ String sql = SELECT + "SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + ") as playtime" +
+ FROM + SessionsTable.TABLE_NAME +
+ WHERE + SessionsTable.SERVER_UUID + "=?";
+ return new QueryStatement(sql) {
+ @Override
+ public void prepare(PreparedStatement statement) throws SQLException {
+ statement.setString(1, serverUUID.toString());
+ }
+
+ @Override
+ public Long processResults(ResultSet set) throws SQLException {
+ return set.next() ? set.getLong("playtime") : 0L;
+ }
+ };
+ }
+
+ public static Query 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(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 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(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 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(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 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(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 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(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;
+ }
+ };
+ }
}
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/analysis/PlayerCountQueries.java b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/analysis/PlayerCountQueries.java
new file mode 100644
index 000000000..ef9f41ec3
--- /dev/null
+++ b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/analysis/PlayerCountQueries.java
@@ -0,0 +1,66 @@
+package com.djrapitops.plan.db.access.queries.analysis;
+
+import com.djrapitops.plan.db.access.Query;
+import com.djrapitops.plan.db.access.QueryStatement;
+import com.djrapitops.plan.db.sql.tables.SessionsTable;
+import com.djrapitops.plan.db.sql.tables.UserInfoTable;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.UUID;
+
+import static com.djrapitops.plan.db.sql.parsing.Sql.*;
+
+/**
+ * Queries for server overview tab data.
+ *
+ * @author Rsl1122
+ */
+public class PlayerCountQueries {
+
+ private PlayerCountQueries() {
+ // Static method class
+ }
+
+ private static QueryStatement queryPlayerCount(String sql, long after, long before, UUID serverUUID) {
+ return new QueryStatement(sql) {
+ @Override
+ public void prepare(PreparedStatement statement) throws SQLException {
+ statement.setLong(1, before);
+ statement.setLong(2, after);
+ statement.setString(3, serverUUID.toString());
+ }
+
+ @Override
+ public Integer processResults(ResultSet set) throws SQLException {
+ return set.next() ? set.getInt("player_count") : 0;
+ }
+ };
+ }
+
+ public static Query uniquePlayerCount(long after, long before, UUID serverUUID) {
+ String sql = SELECT + "COUNT(" + SessionsTable.USER_UUID + ") as player_count" +
+ FROM + SessionsTable.TABLE_NAME +
+ WHERE + SessionsTable.SESSION_END + "<=?" +
+ AND + SessionsTable.SESSION_START + ">=?" +
+ AND + SessionsTable.SERVER_UUID + "=?" +
+ GROUP_BY + SessionsTable.USER_UUID;
+
+ return queryPlayerCount(sql, after, before, serverUUID);
+ }
+
+ public static Query uniquePlayerCountPerDay(long after, long before, UUID serverUUID) {
+ return db -> 0; // TODO
+ }
+
+ public static Query newPlayerCount(long after, long before, UUID serverUUID) {
+ String sql = SELECT + "COUNT(" + UserInfoTable.USER_UUID + ") as player_count" +
+ FROM + UserInfoTable.TABLE_NAME +
+ WHERE + UserInfoTable.REGISTERED + "<=?" +
+ AND + UserInfoTable.REGISTERED + ">=?" +
+ AND + UserInfoTable.SERVER_UUID + "=?";
+
+ return queryPlayerCount(sql, after, before, serverUUID);
+ }
+}
\ No newline at end of file
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/ServerPlayersTableContainersQuery.java b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/ServerPlayersTableContainersQuery.java
index c1594e184..68950c5e4 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/ServerPlayersTableContainersQuery.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/containers/ServerPlayersTableContainersQuery.java
@@ -27,6 +27,7 @@ import com.djrapitops.plan.db.access.queries.objects.BaseUserQueries;
import com.djrapitops.plan.db.access.queries.objects.GeoInfoQueries;
import com.djrapitops.plan.db.access.queries.objects.SessionQueries;
import com.djrapitops.plan.db.access.queries.objects.UserInfoQueries;
+import com.djrapitops.plan.system.json.PlayersTableJSONParser;
import java.util.*;
@@ -34,7 +35,7 @@ import java.util.*;
* Optimized version of {@link ServerPlayerContainersQuery} for /server page Players table.
*
* @author Rsl1122
- * @see com.djrapitops.plan.utilities.html.tables.PlayersTableJSONParser For what needs to be included.
+ * @see PlayersTableJSONParser For what needs to be included.
*/
public class ServerPlayersTableContainersQuery implements Query> {
diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/objects/TPSQueries.java b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/objects/TPSQueries.java
index 528e3a863..abe479e45 100644
--- a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/objects/TPSQueries.java
+++ b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/objects/TPSQueries.java
@@ -81,6 +81,43 @@ public class TPSQueries {
};
}
+ public static Query> fetchTPSDataOfServer(long after, long before, UUID serverUUID) {
+ String sql = Select.all(TABLE_NAME)
+ .where(SERVER_ID + "=" + ServerTable.STATEMENT_SELECT_SERVER_ID)
+ .and(DATE + ">=?").and(DATE + "<=?")
+ .toString();
+
+ return new QueryStatement>(sql, 50000) {
+ @Override
+ public void prepare(PreparedStatement statement) throws SQLException {
+ statement.setString(1, serverUUID.toString());
+ statement.setLong(2, after);
+ statement.setLong(3, before);
+ }
+
+ @Override
+ public List processResults(ResultSet set) throws SQLException {
+ List data = new ArrayList<>();
+ while (set.next()) {
+
+ TPS tps = TPSBuilder.get()
+ .date(set.getLong(DATE))
+ .tps(set.getDouble(TPS))
+ .playersOnline(set.getInt(PLAYERS_ONLINE))
+ .usedCPU(set.getDouble(CPU_USAGE))
+ .usedMemory(set.getLong(RAM_USAGE))
+ .entities(set.getInt(ENTITIES))
+ .chunksLoaded(set.getInt(CHUNKS))
+ .freeDiskSpace(set.getLong(FREE_DISK))
+ .toTPS();
+
+ data.add(tps);
+ }
+ return data;
+ }
+ };
+ }
+
public static Query
Low TPS Spikes
Server downtime
setLoadingText('Calculating values..');
- loadServerOverviewValues(
- {
- last_7_days: {
- unique_players: 5,
- unique_players_day: 2,
- new_players: 0,
- new_players_retention: 0,
- new_players_retention_perc: '-',
- average_tps: '19,92',
- low_tps_spikes: 0,
- downtime: '5d 3h 33m 46s'
- },
- numbers: {
- total_players: 4353,
- regular_players: 432,
- online_players: 43,
- last_peak_date: 'Yesterday, 16:28',
- last_peak_players: 43,
- best_peak_date: 'Sep 5 2017, 12:43',
- best_peak_players: 51,
- playtime: '8h 5m 56s',
- player_playtime: '43m 5s',
- sessions: 98,
- player_kills: 0,
- mob_kills: 22,
- deaths: 8
- },
- weeks: {
- unique_before: 5,
- unique_after: 5,
- unique_trend: {
- text: 0,
- direction: null
- },
- new_before: 45,
- new_after: 44,
- new_trend: {
- text: 1,
- direction: '-'
- },
- regular_before: 427,
- regular_after: 432,
- regular_trend: {
- text: 5,
- direction: '+'
- },
- playtime_before: '8h 5m 56s',
- playtime_after: '8h 53m 24s',
- playtime_trend: {
- text: '47m 32s',
- direction: '+'
- },
- sessions_before: '32',
- sessions_after: '64',
- sessions_trend: {
- text: 32,
- direction: '+'
- },
- player_kills_before: 32,
- player_kills_after: 64,
- player_kills_trend: {
- text: 32,
- direction: '+'
- },
- mob_kills_before: 5432,
- mob_kills_after: 654,
- mob_kills_trend: {
- text: 4778,
- direction: '-'
- },
- deaths_before: 8,
- deaths_after: 13,
- deaths_trend: {
- text: 5,
- direction: '+',
- reversed: true
- }
- }
- }, null // TODO Replace with result of a XMLHTTPRequest
- );
+ jsonRequest("../v1/serverOverview?serverName=${serverName}", loadServerOverviewValues);
loadOnlineActivityOverviewValues(
{
numbers: {