Rest of NetworkKey suppliers, tests, Plugins tab stuff to Analysis

This commit is contained in:
Rsl1122 2018-06-21 11:36:47 +03:00
parent 9ec6d21b93
commit c4c5b374f8
12 changed files with 272 additions and 37 deletions

View File

@ -5,8 +5,6 @@ import com.djrapitops.plan.data.PlayerProfile;
import com.djrapitops.plan.data.ServerProfile;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.data.element.AnalysisContainer;
import com.djrapitops.plan.data.plugin.PluginData;
import com.djrapitops.plan.data.store.mutators.RetentionData;
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
@ -29,7 +27,6 @@ import com.djrapitops.plan.utilities.html.graphs.calendar.ServerCalendar;
import com.djrapitops.plan.utilities.html.graphs.line.*;
import com.djrapitops.plan.utilities.html.graphs.pie.ActivityPie;
import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator;
import com.djrapitops.plan.utilities.html.tables.CommandUseTable;
import com.djrapitops.plugin.api.TimeAmount;
@ -64,12 +61,6 @@ public class AnalysisData extends RawData {
stickyMonthData = new HashSet<>();
}
public void parsePluginsSection(Map<PluginData, AnalysisContainer> containers) {
String[] navAndTabs = AnalysisPluginsTabContentCreator.createContent(containers);
addValue("navPluginsTabs", navAndTabs[0]);
addValue("tabsPlugins", navAndTabs[1]);
}
private void addConstants() {
addValue("version", PlanPlugin.getInstance().getVersion());
addValue("worldPieColors", Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));

View File

@ -23,6 +23,7 @@ import com.djrapitops.plan.utilities.html.graphs.calendar.ServerCalendar;
import com.djrapitops.plan.utilities.html.graphs.line.*;
import com.djrapitops.plan.utilities.html.graphs.pie.ActivityPie;
import com.djrapitops.plan.utilities.html.graphs.pie.WorldPie;
import com.djrapitops.plan.utilities.html.structure.AnalysisPluginsTabContentCreator;
import com.djrapitops.plan.utilities.html.structure.RecentLoginList;
import com.djrapitops.plan.utilities.html.structure.SessionAccordion;
import com.djrapitops.plan.utilities.html.tables.CommandUseTable;
@ -51,6 +52,10 @@ public class AnalysisContainer extends DataContainer {
addAnalysisSuppliers();
}
public ServerContainer getServerContainer() {
return serverContainer;
}
private void addAnalysisSuppliers() {
putSupplier(AnalysisKeys.SESSIONS_MUTATOR, () -> SessionsMutator.forContainer(serverContainer));
putSupplier(AnalysisKeys.TPS_MUTATOR, () -> TPSMutator.forContainer(serverContainer));
@ -63,6 +68,7 @@ public class AnalysisContainer extends DataContainer {
addTPSAverageSuppliers();
addCommandSuppliers();
addServerHealth();
addPluginSuppliers();
}
private void addConstants() {
@ -140,9 +146,9 @@ public class AnalysisContainer extends DataContainer {
Key<PlayersMutator> newDay = new Key<>(PlayersMutator.class, "NEW_DAY");
Key<PlayersMutator> newWeek = new Key<>(PlayersMutator.class, "NEW_WEEK");
Key<PlayersMutator> newMonth = new Key<>(PlayersMutator.class, "NEW_MONTH");
Key<PlayersMutator> uniqueDay = new Key<>(PlayersMutator.class, "NEW_DAY");
Key<PlayersMutator> uniqueWeek = new Key<>(PlayersMutator.class, "NEW_WEEK");
Key<PlayersMutator> uniqueMonth = new Key<>(PlayersMutator.class, "NEW_MONTH");
Key<PlayersMutator> uniqueDay = new Key<>(PlayersMutator.class, "UNIQUE_DAY");
Key<PlayersMutator> uniqueWeek = new Key<>(PlayersMutator.class, "UNIQUE_WEEK");
Key<PlayersMutator> uniqueMonth = new Key<>(PlayersMutator.class, "UNIQUE_MONTH");
putSupplier(newDay, () -> PlayersMutator.copyOf(getUnsafe(AnalysisKeys.PLAYERS_MUTATOR))
.filterRegisteredBetween(getUnsafe(AnalysisKeys.ANALYSIS_TIME_DAY_AGO), getUnsafe(AnalysisKeys.ANALYSIS_TIME))
);
@ -366,4 +372,11 @@ public class AnalysisContainer extends DataContainer {
putSupplier(AnalysisKeys.HEALTH_INDEX, () -> getUnsafe(healthInformation).getServerHealth());
putSupplier(AnalysisKeys.HEALTH_NOTES, () -> getUnsafe(healthInformation).toHtml());
}
private void addPluginSuppliers() {
// TODO Refactor into a system that supports running the analysis on Bungee
String[] navAndTabs = AnalysisPluginsTabContentCreator.createContent(getUnsafe(AnalysisKeys.PLAYERS_MUTATOR).uuids());
putRawData(AnalysisKeys.PLUGINS_TAB_NAV, navAndTabs[0]);
putRawData(AnalysisKeys.PLUGINS_TAB, navAndTabs[1]);
}
}

View File

@ -1,11 +1,26 @@
package com.djrapitops.plan.data.store.containers;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
import com.djrapitops.plan.data.store.Key;
import com.djrapitops.plan.data.store.keys.NetworkKeys;
import com.djrapitops.plan.data.store.keys.ServerKeys;
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
import com.djrapitops.plan.data.store.mutators.TPSMutator;
import com.djrapitops.plan.data.store.mutators.formatting.Formatters;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.settings.theme.Theme;
import com.djrapitops.plan.system.settings.theme.ThemeVal;
import com.djrapitops.plan.utilities.MiscUtils;
import com.djrapitops.plan.utilities.html.graphs.WorldMap;
import com.djrapitops.plan.utilities.html.graphs.line.OnlineActivityGraph;
import com.djrapitops.plugin.api.utility.log.Log;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
/**
* DataContainer for the whole network.
@ -18,8 +33,35 @@ public class NetworkContainer extends DataContainer {
private final ServerContainer bungeeContainer;
private final Map<UUID, AnalysisContainer> serverContainers;
public NetworkContainer(ServerContainer bungeeContainer) {
this.bungeeContainer = bungeeContainer;
serverContainers = new HashMap<>();
putSupplier(NetworkKeys.PLAYERS_MUTATOR, () -> PlayersMutator.forContainer(bungeeContainer));
addConstants();
addPlayerInformation();
}
public void putAnalysisContainer(AnalysisContainer analysisContainer) {
serverContainers.put(analysisContainer.getServerContainer().getUnsafe(ServerKeys.SERVER_UUID), analysisContainer);
}
public Optional<AnalysisContainer> getAnalysisContainer(UUID serverUUID) {
AnalysisContainer container = serverContainers.get(serverUUID);
if (container != null) {
return Optional.of(container);
}
try {
AnalysisContainer analysisContainer = new AnalysisContainer(Database.getActive().fetch().getServerContainer(serverUUID));
serverContainers.put(serverUUID, analysisContainer);
return Optional.of(analysisContainer);
} catch (DBOpException e) {
Log.toLog(this.getClass(), e);
}
return Optional.empty();
}
private void addConstants() {
@ -32,6 +74,67 @@ public class NetworkContainer extends DataContainer {
putSupplier(NetworkKeys.NETWORK_NAME, () -> bungeeContainer.getValue(ServerKeys.NAME).orElse("Plan"));
putSupplier(NetworkKeys.PLAYERS_ONLINE, ServerInfo.getServerProperties()::getOnlinePlayers);
putRawData(NetworkKeys.WORLD_MAP_LOW_COLOR, Theme.getValue(ThemeVal.WORLD_MAP_LOW));
putRawData(NetworkKeys.WORLD_MAP_HIGH_COLOR, Theme.getValue(ThemeVal.WORLD_MAP_HIGH));
putRawData(NetworkKeys.PLAYERS_GRAPH_COLOR, Theme.getValue(ThemeVal.GRAPH_PLAYERS_ONLINE));
}
private void addPlayerInformation() {
putSupplier(NetworkKeys.PLAYERS_TOTAL, () -> bungeeContainer.getValue(ServerKeys.PLAYER_COUNT).orElse(-1));
putSupplier(NetworkKeys.WORLD_MAP_SERIES, () ->
new WorldMap(PlayersMutator.forContainer(bungeeContainer)).toHighChartsSeries()
);
putSupplier(NetworkKeys.PLAYERS_ONLINE_SERIES, () ->
new OnlineActivityGraph(TPSMutator.forContainer(bungeeContainer)).toHighChartsSeries()
);
putSupplier(NetworkKeys.ALL_TIME_PEAK_TIME_F, () ->
bungeeContainer.getValue(ServerKeys.ALL_TIME_PEAK_PLAYERS).map(Formatters.year()::apply).orElse("No data")
);
putSupplier(NetworkKeys.RECENT_PEAK_TIME_F, () ->
bungeeContainer.getValue(ServerKeys.RECENT_PEAK_PLAYERS).map(Formatters.year()::apply).orElse("No data")
);
putSupplier(NetworkKeys.PLAYERS_ALL_TIME_PEAK, () ->
bungeeContainer.getValue(ServerKeys.ALL_TIME_PEAK_PLAYERS).map(dateObj -> "" + dateObj.getValue()).orElse("-")
);
putSupplier(NetworkKeys.PLAYERS_RECENT_PEAK, () ->
bungeeContainer.getValue(ServerKeys.RECENT_PEAK_PLAYERS).map(dateObj -> "" + dateObj.getValue()).orElse("-")
);
addPlayerCounts();
}
private void addPlayerCounts() {
Key<PlayersMutator> newDay = new Key<>(PlayersMutator.class, "NEW_DAY");
Key<PlayersMutator> newWeek = new Key<>(PlayersMutator.class, "NEW_WEEK");
Key<PlayersMutator> newMonth = new Key<>(PlayersMutator.class, "NEW_MONTH");
Key<PlayersMutator> uniqueDay = new Key<>(PlayersMutator.class, "UNIQUE_DAY");
Key<PlayersMutator> uniqueWeek = new Key<>(PlayersMutator.class, "UNIQUE_WEEK");
Key<PlayersMutator> uniqueMonth = new Key<>(PlayersMutator.class, "UNIQUE_MONTH");
putSupplier(newDay, () -> PlayersMutator.copyOf(getUnsafe(NetworkKeys.PLAYERS_MUTATOR))
.filterRegisteredBetween(getUnsafe(NetworkKeys.REFRESH_TIME_DAY_AGO), getUnsafe(NetworkKeys.REFRESH_TIME))
);
putSupplier(newWeek, () -> PlayersMutator.copyOf(getUnsafe(NetworkKeys.PLAYERS_MUTATOR))
.filterRegisteredBetween(getUnsafe(NetworkKeys.REFRESH_TIME_WEEK_AGO), getUnsafe(NetworkKeys.REFRESH_TIME))
);
putSupplier(newMonth, () -> PlayersMutator.copyOf(getUnsafe(NetworkKeys.PLAYERS_MUTATOR))
.filterRegisteredBetween(getUnsafe(NetworkKeys.REFRESH_TIME_MONTH_AGO), getUnsafe(NetworkKeys.REFRESH_TIME))
);
putSupplier(uniqueDay, () -> PlayersMutator.copyOf(getUnsafe(NetworkKeys.PLAYERS_MUTATOR))
.filterRegisteredBetween(getUnsafe(NetworkKeys.REFRESH_TIME_DAY_AGO), getUnsafe(NetworkKeys.REFRESH_TIME))
);
putSupplier(uniqueWeek, () -> PlayersMutator.copyOf(getUnsafe(NetworkKeys.PLAYERS_MUTATOR))
.filterRegisteredBetween(getUnsafe(NetworkKeys.REFRESH_TIME_WEEK_AGO), getUnsafe(NetworkKeys.REFRESH_TIME))
);
putSupplier(uniqueMonth, () -> PlayersMutator.copyOf(getUnsafe(NetworkKeys.PLAYERS_MUTATOR))
.filterRegisteredBetween(getUnsafe(NetworkKeys.REFRESH_TIME_MONTH_AGO), getUnsafe(NetworkKeys.REFRESH_TIME))
);
putSupplier(NetworkKeys.PLAYERS_NEW_DAY, () -> getUnsafe(newDay).count());
putSupplier(NetworkKeys.PLAYERS_NEW_WEEK, () -> getUnsafe(newWeek).count());
putSupplier(NetworkKeys.PLAYERS_NEW_MONTH, () -> getUnsafe(newMonth).count());
putSupplier(NetworkKeys.PLAYERS_DAY, () -> getUnsafe(uniqueDay).count());
putSupplier(NetworkKeys.PLAYERS_WEEK, () -> getUnsafe(uniqueWeek).count());
putSupplier(NetworkKeys.PLAYERS_MONTH, () -> getUnsafe(uniqueMonth).count());
}
}

View File

@ -2,6 +2,7 @@ package com.djrapitops.plan.data.store.keys;
import com.djrapitops.plan.data.store.Key;
import com.djrapitops.plan.data.store.PlaceholderKey;
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
/**
* Key objects for {@link com.djrapitops.plan.data.store.containers.NetworkContainer}.
@ -21,9 +22,9 @@ public class NetworkKeys {
public static final PlaceholderKey<String> WORLD_MAP_LOW_COLOR = CommonPlaceholderKeys.WORLD_MAP_LOW_COLOR;
public static final PlaceholderKey<String> REFRESH_TIME_F = CommonPlaceholderKeys.REFRESH_TIME_F;
public static final PlaceholderKey<String> LAST_PEAK_TIME_F = CommonPlaceholderKeys.LAST_PEAK_TIME_F;
public static final PlaceholderKey<String> RECENT_PEAK_TIME_F = CommonPlaceholderKeys.LAST_PEAK_TIME_F;
public static final PlaceholderKey<String> ALL_TIME_PEAK_TIME_F = CommonPlaceholderKeys.ALL_TIME_PEAK_TIME_F;
public static final PlaceholderKey<String> PLAYERS_LAST_PEAK = CommonPlaceholderKeys.PLAYERS_LAST_PEAK;
public static final PlaceholderKey<String> PLAYERS_RECENT_PEAK = CommonPlaceholderKeys.PLAYERS_LAST_PEAK;
public static final PlaceholderKey<String> PLAYERS_ALL_TIME_PEAK = CommonPlaceholderKeys.PLAYERS_ALL_TIME_PEAK;
public static final PlaceholderKey<Integer> PLAYERS_DAY = CommonPlaceholderKeys.PLAYERS_DAY;
public static final PlaceholderKey<Integer> PLAYERS_WEEK = CommonPlaceholderKeys.PLAYERS_WEEK;
@ -36,6 +37,10 @@ public class NetworkKeys {
public static final PlaceholderKey<String> PLAYERS_ONLINE_SERIES = CommonPlaceholderKeys.PLAYERS_ONLINE_SERIES;
public static final Key<Long> REFRESH_TIME = new Key<>(Long.class, "REFRESH_TIME");
public static final Key<Long> REFRESH_TIME_DAY_AGO = new Key<>(Long.class, "REFRESH_TIME_DAY_AGO");
public static final Key<Long> REFRESH_TIME_WEEK_AGO = new Key<>(Long.class, "REFRESH_TIME_WEEK_AGO");
public static final Key<Long> REFRESH_TIME_MONTH_AGO = new Key<>(Long.class, "REFRESH_TIME_MONTH_AGO");
public static final Key<PlayersMutator> PLAYERS_MUTATOR = CommonKeys.PLAYERS_MUTATOR;
private NetworkKeys() {
/* static variable class */

View File

@ -1,6 +1,7 @@
package com.djrapitops.plan.data.store.mutators;
import com.djrapitops.plan.data.container.GeoInfo;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.store.containers.DataContainer;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
@ -194,4 +195,18 @@ public class PlayersMutator {
}
return new PlayersMutator(toBeRetained);
}
public List<Session> getSessions() {
return players.stream()
.map(player -> player.getValue(PlayerKeys.SESSIONS).orElse(new ArrayList<>()))
.flatMap(Collection::stream)
.collect(Collectors.toList());
}
public List<UUID> uuids() {
return players.stream()
.map(player -> player.getValue(PlayerKeys.UUID).orElse(null))
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
}

View File

@ -12,6 +12,7 @@ import com.djrapitops.plan.data.store.keys.PerServerKeys;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.store.keys.ServerKeys;
import com.djrapitops.plan.data.store.mutators.PerServerDataMutator;
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
import com.djrapitops.plan.data.store.mutators.SessionsMutator;
import com.djrapitops.plan.data.store.objects.DateObj;
import com.djrapitops.plan.data.time.WorldTimes;
@ -33,6 +34,13 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
public ServerContainer getServerContainer(UUID serverUUID) {
ServerContainer container = new ServerContainer();
Optional<Server> serverInfo = serverTable.getServerInfo(serverUUID);
if (!serverInfo.isPresent()) {
return container;
}
container.putRawData(ServerKeys.SERVER_UUID, serverUUID);
container.putRawData(ServerKeys.NAME, serverInfo.get().getName());
container.putSupplier(ServerKeys.PLAYERS, () -> getPlayerContainers(serverUUID));
container.putSupplier(ServerKeys.PLAYER_COUNT, container.getUnsafe(ServerKeys.PLAYERS)::size);
@ -61,6 +69,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
// Calculating getters
container.putSupplier(ServerKeys.OPERATORS, () -> container.getUnsafe(ServerKeys.PLAYERS).stream()
.filter(player -> player.getValue(PlayerKeys.OPERATOR).orElse(false)).collect(Collectors.toList()));
container.putSupplier(ServerKeys.SESSIONS, () -> PlayersMutator.forContainer(container).getSessions());
container.putSupplier(ServerKeys.PLAYER_KILLS, SessionsMutator.forContainer(container)::toPlayerKillList);
container.putSupplier(ServerKeys.PLAYER_KILL_COUNT, container.getUnsafe(ServerKeys.PLAYER_KILLS)::size);
container.putSupplier(ServerKeys.MOB_KILL_COUNT, SessionsMutator.forContainer(container)::toMobKillCount);

View File

@ -69,21 +69,20 @@ public class Analysis implements Callable<AnalysisData> {
*
* @return ServerProfile being analyzed or null if analysis is not being run.
*/
// TODO Remove use of this method in PluginData
public static ServerProfile getServerProfile() {
return serverProfile;
}
@Override
public AnalysisData call() throws Exception {
return runAnalysis();
// TODO Remove use of this method and replace with a new source for the method
@Deprecated
public static boolean isAnalysisBeingRun() {
return serverProfile != null;
}
private AnalysisData runAnalysis() throws Exception {
((ServerTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis();
Benchmark.start("Analysis: Total");
log(Locale.get(Msg.ANALYSIS_START).toString());
return analyze();
@Override
public AnalysisData call() {
return runAnalysis();
}
private static void updateRefreshDate() {
@ -157,9 +156,12 @@ public class Analysis implements Callable<AnalysisData> {
return containers;
}
@Deprecated
public static boolean isAnalysisBeingRun() {
return serverProfile != null;
private AnalysisData runAnalysis() {
((ServerTaskSystem) TaskSystem.getInstance()).cancelBootAnalysis();
Benchmark.start("Analysis: Total");
log(Locale.get(Msg.ANALYSIS_START).toString());
return analyze();
}
private static void setServerProfile(ServerProfile serverProfile) {
@ -194,8 +196,6 @@ public class Analysis implements Callable<AnalysisData> {
Benchmark.stop("Analysis", "Analysis: Data Analysis");
log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString());
Log.logDebug("Analysis", "Analyzing additional data sources (3rd party)");
analysisData.parsePluginsSection(analyzeAdditionalPluginData(server.getUuids()));
return analysisData;
} finally {
Analysis.updateRefreshDate();

View File

@ -1,5 +1,7 @@
package com.djrapitops.plan.utilities.html.graphs;
import com.djrapitops.plan.data.store.mutators.PlayersMutator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -18,6 +20,10 @@ public class WorldMap implements HighChart {
this.geoLocations = geoLocations;
}
public WorldMap(PlayersMutator mutator) {
this(mutator.getGeolocations());
}
private static Map<String, String> getGeoCodes(Map<String, Integer> geoCodeCounts) {
Map<String, String> geoCodes = new HashMap<>();
// Countries & Codes have been copied from a iso-a3 specification file.

View File

@ -4,16 +4,19 @@
*/
package com.djrapitops.plan.utilities.html.structure;
import com.djrapitops.plan.PlanPlugin;
import com.djrapitops.plan.data.element.AnalysisContainer;
import com.djrapitops.plan.data.element.InspectContainer;
import com.djrapitops.plan.data.plugin.HookHandler;
import com.djrapitops.plan.data.plugin.PluginData;
import com.djrapitops.plan.utilities.analysis.Analysis;
import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator;
import com.djrapitops.plan.utilities.html.tables.PluginPlayersTable;
import com.djrapitops.plugin.StaticHolder;
import com.djrapitops.plugin.api.Benchmark;
import com.djrapitops.plugin.api.utility.log.Log;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* Creates Plugin section contents for Analysis page.
@ -22,11 +25,13 @@ import java.util.Map;
*/
public class AnalysisPluginsTabContentCreator {
public static String[] createContent(Map<PluginData, AnalysisContainer> containers) {
if (containers.isEmpty()) {
public static String[] createContent(List<UUID> uuids) {
if (uuids.isEmpty()) {
return new String[]{"<li><a>No Data</a></li>", ""};
}
Map<PluginData, AnalysisContainer> containers = analyzeAdditionalPluginData(uuids);
List<PluginData> order = new ArrayList<>(containers.keySet());
order.sort(new PluginDataNameComparator());
@ -84,6 +89,32 @@ public class AnalysisPluginsTabContentCreator {
};
}
private static Map<PluginData, AnalysisContainer> analyzeAdditionalPluginData(Collection<UUID> uuids) {
Map<PluginData, AnalysisContainer> containers = new HashMap<>();
List<PluginData> sources = HookHandler.getInstance().getAdditionalDataSources();
sources.parallelStream().forEach(source -> {
PlanPlugin plugin = PlanPlugin.getInstance();
StaticHolder.saveInstance(AnalysisPluginsTabContentCreator.class, plugin.getClass());
try {
Benchmark.start("Analysis", "Analysis: Source " + source.getSourcePlugin());
AnalysisContainer container = source.getServerData(uuids, new AnalysisContainer());
if (container != null && !container.isEmpty()) {
containers.put(source, container);
}
} catch (Exception | NoClassDefFoundError | NoSuchFieldError | NoSuchMethodError e) {
Log.error("A PluginData-source caused an exception: " + source.getSourcePlugin());
Log.toLog(AnalysisPluginsTabContentCreator.class, e);
} finally {
Benchmark.stop("Analysis", "Analysis: Source " + source.getSourcePlugin());
}
});
return containers;
}
public static void appendThird(PluginData pluginData, InspectContainer container, StringBuilder generalTab) {
generalTab.append("<div class=\"col-xs-12 col-sm-12 col-md-4 col-lg-4\">" +
"<div class=\"card\">" +

View File

@ -293,7 +293,7 @@
<ul class="dashboard-stat-list">
<li>
<i class="col-blue fa fa-users"></i> Unique | 24h
<span class="pull-right"><b>${playersUniqueDay}</b></span>
<span class="pull-right"><b>${playersDay}</b></span>
</li>
<li>
<i class="col-light-green fa fa-user-plus"></i> New | 24h
@ -302,7 +302,7 @@
<li></li>
<li>
<i class="col-blue fa fa-users"></i> Unique | 7d
<span class="pull-right"><b>${playersUniqueWeek}</b></span>
<span class="pull-right"><b>${playersWeek}</b></span>
</li>
<li>
<i class="col-light-green fa fa-user-plus"></i> New | 7d
@ -311,7 +311,7 @@
<li></li>
<li>
<i class="col-blue fa fa-users"></i> Unique | 30d
<span class="pull-right"><b>${playersUniqueMonth}</b></span>
<span class="pull-right"><b>${playersMonth}</b></span>
</li>
<li>
<i class="col-light-green fa fa-user-plus"></i> New | 30d

View File

@ -11,8 +11,13 @@ import com.djrapitops.plan.api.exceptions.database.DBInitException;
import com.djrapitops.plan.data.Actions;
import com.djrapitops.plan.data.WebUser;
import com.djrapitops.plan.data.container.*;
import com.djrapitops.plan.data.store.Key;
import com.djrapitops.plan.data.store.containers.AnalysisContainer;
import com.djrapitops.plan.data.store.containers.PlayerContainer;
import com.djrapitops.plan.data.store.containers.ServerContainer;
import com.djrapitops.plan.data.store.keys.AnalysisKeys;
import com.djrapitops.plan.data.store.keys.PlayerKeys;
import com.djrapitops.plan.data.store.keys.ServerKeys;
import com.djrapitops.plan.data.store.objects.Nickname;
import com.djrapitops.plan.data.time.GMTimes;
import com.djrapitops.plan.data.time.WorldTimes;
@ -38,6 +43,7 @@ import utilities.mocks.SystemMockUtil;
import java.io.UnsupportedEncodingException;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.reflect.Field;
import java.security.NoSuchAlgorithmException;
import java.util.*;
@ -1083,4 +1089,56 @@ public class SQLiteTest {
// TODO Test rest
}
@Test
public void playerContainerSupportsAllPlayerKeys() throws UnsupportedEncodingException, NoSuchAlgorithmException, IllegalAccessException {
saveAllData(db);
PlayerContainer playerContainer = db.fetch().getPlayerContainer(TestConstants.PLAYER_ONE_UUID);
// Active sessions are added after fetching
playerContainer.putRawData(PlayerKeys.ACTIVE_SESSION, RandomData.randomSession());
List<String> unsupported = new ArrayList<>();
for (Field field : PlayerKeys.class.getDeclaredFields()) {
Key key = (Key) field.get(null);
if (!playerContainer.supports(key)) {
unsupported.add(field.getName());
}
}
assertTrue("Some keys are not supported by PlayerContainer: PlayerKeys." + unsupported.toString(), unsupported.isEmpty());
}
@Test
public void serverContainerSupportsAllServerKeys() throws UnsupportedEncodingException, NoSuchAlgorithmException, IllegalAccessException {
saveAllData(db);
ServerContainer serverContainer = db.fetch().getServerContainer(TestConstants.SERVER_UUID);
List<String> unsupported = new ArrayList<>();
for (Field field : ServerKeys.class.getDeclaredFields()) {
Key key = (Key) field.get(null);
if (!serverContainer.supports(key)) {
unsupported.add(field.getName());
}
}
assertTrue("Some keys are not supported by ServerContainer: ServerKeys." + unsupported.toString(), unsupported.isEmpty());
}
@Test
public void analysisContainerSupportsAllAnalysisKeys() throws IllegalAccessException, UnsupportedEncodingException, NoSuchAlgorithmException {
serverContainerSupportsAllServerKeys();
AnalysisContainer analysisContainer = new AnalysisContainer(db.fetch().getServerContainer(TestConstants.SERVER_UUID));
List<String> unsupported = new ArrayList<>();
for (Field field : AnalysisKeys.class.getDeclaredFields()) {
Key key = (Key) field.get(null);
if (!analysisContainer.supports(key)) {
unsupported.add(field.getName());
}
}
assertTrue("Some keys are not supported by AnalysisContainer: AnalysisKeys." + unsupported.toString(), unsupported.isEmpty());
}
}

View File

@ -48,11 +48,15 @@ public class RandomData {
public static List<Session> randomSessions() {
List<Session> test = new ArrayList<>();
for (int i = 0; i < 20; i++) {
test.add(new Session(1, TestConstants.PLAYER_ONE_UUID, TestConstants.SERVER_UUID, r.nextLong(), r.nextLong(), 0, 0, 0));
test.add(randomSession());
}
return test;
}
public static Session randomSession() {
return new Session(1, TestConstants.PLAYER_ONE_UUID, TestConstants.SERVER_UUID, r.nextLong(), r.nextLong(), 0, 0, 0);
}
public static List<Point> randomPoints() {
List<Point> test = new ArrayList<>();
for (int i = 0; i < 20; i++) {