diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/json/PerformanceJSONParser.java b/Plan/common/src/main/java/com/djrapitops/plan/system/json/PerformanceJSONParser.java index 902868aae..59ec0b705 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/json/PerformanceJSONParser.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/json/PerformanceJSONParser.java @@ -28,7 +28,10 @@ import com.djrapitops.plan.utilities.formatting.Formatters; import javax.inject.Inject; import javax.inject.Singleton; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import java.util.concurrent.TimeUnit; /** @@ -68,7 +71,7 @@ public class PerformanceJSONParser implements TabJSONParser> List tpsData = db.query(TPSQueries.fetchTPSDataOfServer(monthAgo, now, serverUUID)); serverOverview.put("numbers", createNumbersMap(tpsData)); - serverOverview.put("insights", createInsightsMap(tpsData, serverUUID)); + serverOverview.put("insights", createInsightsMap(tpsData)); return serverOverview; } @@ -122,24 +125,21 @@ public class PerformanceJSONParser implements TabJSONParser> return decimalFormatter.apply(value); } - private Map createInsightsMap(List tpsData, UUID serverUUID) { - Database db = dbSystem.getDatabase(); - long now = System.currentTimeMillis(); - long monthAgo = now - TimeUnit.DAYS.toMillis(30L); - + private Map createInsightsMap(List tpsData) { TPSMutator tpsMutator = new TPSMutator(tpsData); Integer tpsThreshold = config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED); TPSMutator lowTPS = tpsMutator.filterTPSBetween(-1, tpsThreshold); Map insights = new HashMap<>(); - insights.put("low_tps_players", decimalFormatter.apply(lowTPS.averagePlayersOnline())); - insights.put("low_tps_cpu", decimalFormatter.apply(lowTPS.averageCPU())); - insights.put("low_tps_entities", decimalFormatter.apply(lowTPS.averageEntities())); - insights.put("low_tps_chunks", decimalFormatter.apply(lowTPS.averageChunks())); - - insights.put("low_tps_disconnects", "Not implemented"); - insights.put("low_disk_space_dates", Collections.emptyList()); + double avgPlayersOnline = lowTPS.averagePlayersOnline(); + double averageCPU = lowTPS.averageCPU(); + double averageEntities = lowTPS.averageEntities(); + double averageChunks = lowTPS.averageChunks(); + insights.put("low_tps_players", avgPlayersOnline != -1 ? decimalFormatter.apply(avgPlayersOnline) : "No low tps spikes"); + insights.put("low_tps_cpu", averageCPU != -1 ? decimalFormatter.apply(averageCPU) : "-"); + insights.put("low_tps_entities", averageEntities != -1 ? decimalFormatter.apply(averageEntities) : "-"); + insights.put("low_tps_chunks", averageChunks != -1 ? decimalFormatter.apply(averageChunks) : "-"); return insights; } diff --git a/Plan/common/src/main/resources/assets/plan/web/js/server-values.js b/Plan/common/src/main/resources/assets/plan/web/js/server-values.js index a8b852f50..eeea9621d 100644 --- a/Plan/common/src/main/resources/assets/plan/web/js/server-values.js +++ b/Plan/common/src/main/resources/assets/plan/web/js/server-values.js @@ -336,7 +336,8 @@ function loadPerformanceValues(json, error) { $(element).find('#data_low_tps_players').text(data.low_tps_players); $(element).find('#data_low_tps_entities').text(data.low_tps_entities); - $(element).find('#data_low_tps_disconnects').text(data.low_tps_disconnects); + $(element).find('#data_low_tps_chunks').text(data.low_tps_chunks); + $(element).find('#data_low_tps_cpu').text(data.low_tps_cpu); dates = data.low_disk_space_dates; dateString = ''; diff --git a/Plan/common/src/main/resources/assets/plan/web/server.html b/Plan/common/src/main/resources/assets/plan/web/server.html index 4379f63ac..9f75d1d33 100644 --- a/Plan/common/src/main/resources/assets/plan/web/server.html +++ b/Plan/common/src/main/resources/assets/plan/web/server.html @@ -1141,15 +1141,13 @@

During Low TPS Spikes:

Average Players

+ class="float-right">

Average Entities

-

Average Disconnects

-

- Disk Space low on

+ class="float-right">

+

Average Chunks

+

Average CPU