mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-10 18:37:57 +01:00
parent
31b430ea95
commit
bb83adfd51
@ -63,7 +63,7 @@ public class TPSMutator {
|
||||
return filterBy(tps -> tps.getDate() >= after && tps.getDate() <= before);
|
||||
}
|
||||
|
||||
public TPSMutator filterTPSBetween(int above, int below) {
|
||||
public TPSMutator filterTPSBetween(double above, double below) {
|
||||
return filterBy(tps -> tps.getTicksPerSecond() > above && tps.getTicksPerSecond() < below);
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ public class TPSMutator {
|
||||
return count * 1.0 / tpsData.size();
|
||||
}
|
||||
|
||||
public int lowTpsSpikeCount(int threshold) {
|
||||
public int lowTpsSpikeCount(double threshold) {
|
||||
boolean wasLow = false;
|
||||
int spikeCount = 0;
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class PerformanceJSONCreator implements ServerTabJSONCreator<Map<String,
|
||||
TPSMutator tpsDataWeek = tpsDataMonth.filterDataBetween(weekAgo, now);
|
||||
TPSMutator tpsDataDay = tpsDataWeek.filterDataBetween(dayAgo, now);
|
||||
|
||||
Integer tpsThreshold = config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED);
|
||||
Double tpsThreshold = config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED);
|
||||
numbers.put("low_tps_spikes_30d", tpsDataMonth.lowTpsSpikeCount(tpsThreshold));
|
||||
numbers.put("low_tps_spikes_7d", tpsDataWeek.lowTpsSpikeCount(tpsThreshold));
|
||||
numbers.put("low_tps_spikes_24h", tpsDataDay.lowTpsSpikeCount(tpsThreshold));
|
||||
@ -144,7 +144,7 @@ public class PerformanceJSONCreator implements ServerTabJSONCreator<Map<String,
|
||||
|
||||
private Map<String, Object> createInsightsMap(List<TPS> tpsData) {
|
||||
TPSMutator tpsMutator = new TPSMutator(tpsData);
|
||||
Integer tpsThreshold = config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED);
|
||||
Double tpsThreshold = config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED);
|
||||
TPSMutator lowTPS = tpsMutator.filterTPSBetween(-1, tpsThreshold);
|
||||
|
||||
Map<String, Object> insights = new HashMap<>();
|
||||
|
@ -133,7 +133,7 @@ public class NetworkPerformanceJSONResolver implements Resolver {
|
||||
mutatorsOfServersDay.put(entry.getKey(), mutator.filterDataBetween(dayAgo, now));
|
||||
}
|
||||
|
||||
Integer tpsThreshold = config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED);
|
||||
Double tpsThreshold = config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED);
|
||||
numbers.put("low_tps_spikes_30d", tpsDataMonth.lowTpsSpikeCount(tpsThreshold));
|
||||
numbers.put("low_tps_spikes_7d", tpsDataWeek.lowTpsSpikeCount(tpsThreshold));
|
||||
numbers.put("low_tps_spikes_24h", tpsDataDay.lowTpsSpikeCount(tpsThreshold));
|
||||
|
@ -275,6 +275,11 @@ public class ConfigNode {
|
||||
: new ConfigValueParser.StringParser().compose(value);
|
||||
}
|
||||
|
||||
public Double getDouble() {
|
||||
return value == null ? null
|
||||
: new ConfigValueParser.DoubleParser().compose(value);
|
||||
}
|
||||
|
||||
public boolean getBoolean() {
|
||||
return new ConfigValueParser.BooleanParser().compose(value);
|
||||
}
|
||||
@ -310,6 +315,10 @@ public class ConfigNode {
|
||||
return getNode(path).map(ConfigNode::getBoolean).orElse(false);
|
||||
}
|
||||
|
||||
public Double getDouble(String path) {
|
||||
return getNode(path).map(ConfigNode::getDouble).orElse(null);
|
||||
}
|
||||
|
||||
public void copyMissing(ConfigNode from) {
|
||||
// Override comment conditionally
|
||||
if (comment.size() < from.comment.size()) {
|
||||
|
@ -142,6 +142,23 @@ public interface ConfigValueParser<T> {
|
||||
}
|
||||
}
|
||||
|
||||
class DoubleParser implements ConfigValueParser<Double> {
|
||||
@Override
|
||||
public Double compose(String fromValue) {
|
||||
try {
|
||||
return Double.parseDouble(fromValue);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decompose(Double ofValue) {
|
||||
if (ofValue == null) throw nullInvalidException();
|
||||
return Double.toString(ofValue);
|
||||
}
|
||||
}
|
||||
|
||||
class BooleanParser implements ConfigValueParser<Boolean> {
|
||||
@Override
|
||||
public Boolean compose(String fromValue) {
|
||||
|
@ -18,6 +18,7 @@ package com.djrapitops.plan.settings.config.paths;
|
||||
|
||||
import com.djrapitops.plan.settings.config.ConfigNode;
|
||||
import com.djrapitops.plan.settings.config.paths.key.BooleanSetting;
|
||||
import com.djrapitops.plan.settings.config.paths.key.DoubleSetting;
|
||||
import com.djrapitops.plan.settings.config.paths.key.IntegerSetting;
|
||||
import com.djrapitops.plan.settings.config.paths.key.Setting;
|
||||
import com.djrapitops.plan.settings.config.paths.key.StringSetting;
|
||||
@ -36,8 +37,8 @@ public class DisplaySettings {
|
||||
public static final Setting<Integer> PLAYERS_PER_PLAYERS_PAGE = new IntegerSetting("Display_options.Players_table.Show_on_players_page");
|
||||
public static final Setting<Boolean> OPEN_PLAYER_LINKS_IN_NEW_TAB = new BooleanSetting("Display_options.Open_player_links_in_new_tab");
|
||||
public static final Setting<Boolean> GAPS_IN_GRAPH_DATA = new BooleanSetting("Display_options.Graphs.Show_gaps_in_data");
|
||||
public static final Setting<Integer> GRAPH_TPS_THRESHOLD_HIGH = new IntegerSetting("Display_options.Graphs.TPS.High_threshold");
|
||||
public static final Setting<Integer> GRAPH_TPS_THRESHOLD_MED = new IntegerSetting("Display_options.Graphs.TPS.Medium_threshold");
|
||||
public static final Setting<Double> GRAPH_TPS_THRESHOLD_HIGH = new DoubleSetting("Display_options.Graphs.TPS.High_threshold");
|
||||
public static final Setting<Double> GRAPH_TPS_THRESHOLD_MED = new DoubleSetting("Display_options.Graphs.TPS.Medium_threshold");
|
||||
public static final Setting<Integer> GRAPH_DISK_THRESHOLD_HIGH = new IntegerSetting("Display_options.Graphs.Disk_space.High_threshold");
|
||||
public static final Setting<Integer> GRAPH_DISK_THRESHOLD_MED = new IntegerSetting("Display_options.Graphs.Disk_space.Medium_threshold");
|
||||
public static final Setting<String> CMD_COLOR_MAIN = new StringSetting("Display_options.Command_colors.Main");
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.settings.config.paths.key;
|
||||
|
||||
import com.djrapitops.plan.settings.config.ConfigNode;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/**
|
||||
* Setting implementation for Double (floating point) value settings.
|
||||
*/
|
||||
public class DoubleSetting extends Setting<Double> {
|
||||
|
||||
public DoubleSetting(String path) {
|
||||
super(path, Double.class);
|
||||
}
|
||||
|
||||
public DoubleSetting(String path, Predicate<Double> validator) {
|
||||
super(path, Double.class, validator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getValueFrom(ConfigNode node) {
|
||||
return node.getDouble(path);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user