mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Implemented average players to Playerbase as Numbers
Affects issues: - Close #1796
This commit is contained in:
parent
368f1e5002
commit
26f76d9540
@ -183,6 +183,13 @@ public class TPSMutator {
|
||||
return spikeCount;
|
||||
}
|
||||
|
||||
public int averagePlayers() {
|
||||
return (int) tpsData.stream()
|
||||
.mapToInt(TPS::getPlayers)
|
||||
.filter(num -> num >= 0)
|
||||
.average().orElse(-1);
|
||||
}
|
||||
|
||||
public double averageTPS() {
|
||||
return tpsData.stream()
|
||||
.mapToDouble(TPS::getTicksPerSecond)
|
||||
|
@ -104,6 +104,9 @@ public class PerformanceJSONCreator implements ServerTabJSONCreator<Map<String,
|
||||
numbers.put("server_downtime_7d", timeAmount.apply(tpsDataWeek.serverDownTime()));
|
||||
numbers.put("server_downtime_24h", timeAmount.apply(tpsDataDay.serverDownTime()));
|
||||
|
||||
numbers.put("players_30d", tpsDataMonth.averagePlayers());
|
||||
numbers.put("players_7d", tpsDataWeek.averagePlayers());
|
||||
numbers.put("players_24h", tpsDataDay.averagePlayers());
|
||||
numbers.put("tps_30d", format(tpsDataMonth.averageTPS()));
|
||||
numbers.put("tps_7d", format(tpsDataWeek.averageTPS()));
|
||||
numbers.put("tps_24h", format(tpsDataDay.averageTPS()));
|
||||
|
@ -317,6 +317,9 @@ function loadPerformanceValues(json, error) {
|
||||
element.querySelector('#data_server_downtime_30d').innerText = data.server_downtime_30d;
|
||||
element.querySelector('#data_server_downtime_7d').innerText = data.server_downtime_7d;
|
||||
element.querySelector('#data_server_downtime_24h').innerText = data.server_downtime_24h;
|
||||
element.querySelector('#data_players_30d').innerText = data.players_30d;
|
||||
element.querySelector('#data_players_7d').innerText = data.players_7d;
|
||||
element.querySelector('#data_players_24h').innerText = data.players_24h;
|
||||
element.querySelector('#data_tps_30d').innerText = data.tps_30d;
|
||||
element.querySelector('#data_tps_7d').innerText = data.tps_7d;
|
||||
element.querySelector('#data_tps_24h').innerText = data.tps_24h;
|
||||
|
@ -1107,6 +1107,12 @@
|
||||
<td id="data_server_downtime_7d"></td>
|
||||
<td id="data_server_downtime_24h"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-fw fa-user col-light-blue"></i> Average Players</td>
|
||||
<td id="data_players_30d"></td>
|
||||
<td id="data_players_7d"></td>
|
||||
<td id="data_players_24h"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-fw fa-tachometer-alt col-orange"></i> Average TPS</td>
|
||||
<td id="data_tps_30d"></td>
|
||||
|
@ -206,7 +206,7 @@ public class PlayerOnlineListener implements FabricListener {
|
||||
session.getExtraData().put(ServerName.class, new ServerName(serverInfo.getServer().getIdentifiableName()));
|
||||
session.getExtraData().put(JoinAddress.class, new JoinAddress(getHostName));
|
||||
sessionCache.cacheSession(playerUUID, session)
|
||||
.ifPresent(previousSession -> database.executeTransaction(new SessionEndTransaction(previousSession)));
|
||||
.ifPresent(previousSession -> database.executeTransaction(new StoreSessionTransaction(previousSession)));
|
||||
|
||||
database.executeTransaction(new NicknameStoreTransaction(
|
||||
playerUUID, new Nickname(displayName, time, serverUUID),
|
||||
@ -225,7 +225,7 @@ public class PlayerOnlineListener implements FabricListener {
|
||||
if (socketAddress == null) return;
|
||||
InetAddress address = InetAddresses.forString(socketAddress.getAddress().toString().replace("/", ""));
|
||||
database.executeTransaction(
|
||||
new GeoInfoStoreTransaction(playerUUID, address, time, geolocationCache::getCountry)
|
||||
new StoreGeoInfoTransaction(playerUUID, address, time, geolocationCache::getCountry)
|
||||
);
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ public class PlayerOnlineListener implements FabricListener {
|
||||
dbSystem.getDatabase().executeTransaction(new BanStatusTransaction(playerUUID, serverUUID, () -> server.getPlayerManager().getUserBanList().contains(player.getGameProfile())));
|
||||
|
||||
sessionCache.endSession(playerUUID, time)
|
||||
.ifPresent(endedSession -> dbSystem.getDatabase().executeTransaction(new SessionEndTransaction(endedSession)));
|
||||
.ifPresent(endedSession -> dbSystem.getDatabase().executeTransaction(new StoreSessionTransaction(endedSession)));
|
||||
|
||||
if (config.isTrue(ExportSettings.EXPORT_ON_ONLINE_STATUS_CHANGE)) {
|
||||
processing.submitNonCritical(() -> exporter.exportPlayerPage(playerUUID, playerName));
|
||||
|
Loading…
Reference in New Issue
Block a user