mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 03:27:37 +01:00
Changed all player tables to show active playtime
Previously the tables showed playtime (with afk time) - Query result table - Server players table - Players page table Affects issues: - #1235
This commit is contained in:
parent
c5bfdb6ff3
commit
bb5195e26d
@ -33,7 +33,7 @@ public class TablePlayer implements Comparable<TablePlayer> {
|
||||
private UUID uuid;
|
||||
private String name;
|
||||
private ActivityIndex activityIndex;
|
||||
private Long playtime;
|
||||
private Long activePlaytime;
|
||||
private Integer sessionCount;
|
||||
private Long registered;
|
||||
private Long lastSeen;
|
||||
@ -67,8 +67,8 @@ public class TablePlayer implements Comparable<TablePlayer> {
|
||||
return Optional.ofNullable(activityIndex);
|
||||
}
|
||||
|
||||
public Optional<Long> getPlaytime() {
|
||||
return Optional.ofNullable(playtime);
|
||||
public Optional<Long> getActivePlaytime() {
|
||||
return Optional.ofNullable(activePlaytime);
|
||||
}
|
||||
|
||||
public Optional<Integer> getSessionCount() {
|
||||
@ -105,7 +105,7 @@ public class TablePlayer implements Comparable<TablePlayer> {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof TablePlayer)) return false;
|
||||
TablePlayer that = (TablePlayer) o;
|
||||
return playtime.equals(that.playtime) &&
|
||||
return activePlaytime.equals(that.activePlaytime) &&
|
||||
sessionCount.equals(that.sessionCount) &&
|
||||
registered.equals(that.registered) &&
|
||||
lastSeen.equals(that.lastSeen) &&
|
||||
@ -116,7 +116,7 @@ public class TablePlayer implements Comparable<TablePlayer> {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name, activityIndex, playtime, sessionCount, registered, lastSeen, geolocation);
|
||||
return Objects.hash(name, activityIndex, activePlaytime, sessionCount, registered, lastSeen, geolocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -125,7 +125,7 @@ public class TablePlayer implements Comparable<TablePlayer> {
|
||||
"uuid=" + uuid +
|
||||
", name='" + name + '\'' +
|
||||
", activityIndex=" + activityIndex +
|
||||
", playtime=" + playtime +
|
||||
", activePlaytime=" + activePlaytime +
|
||||
", sessionCount=" + sessionCount +
|
||||
", registered=" + registered +
|
||||
", lastSeen=" + lastSeen +
|
||||
@ -165,8 +165,8 @@ public class TablePlayer implements Comparable<TablePlayer> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder playtime(long playtime) {
|
||||
player.playtime = playtime;
|
||||
public Builder activePlaytime(long activePlaytime) {
|
||||
player.activePlaytime = activePlaytime;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class PlayersTableJSONCreator {
|
||||
String url = "../player/" + Html.encodeToURL(name);
|
||||
|
||||
int loginTimes = player.getSessionCount().orElse(0);
|
||||
long playtime = player.getPlaytime().orElse(-1L);
|
||||
long activePlaytime = player.getActivePlaytime().orElse(-1L);
|
||||
long registered = player.getRegistered().orElse(-1L);
|
||||
long lastSeen = player.getLastSeen().orElse(-1L);
|
||||
|
||||
@ -140,7 +140,7 @@ public class PlayersTableJSONCreator {
|
||||
|
||||
putDataEntry(dataJson, link.create(url, StringUtils.replace(StringEscapeUtils.escapeHtml4(name), "\\", "\\\\") /* Backslashes escaped to prevent json errors */), "name");
|
||||
putDataEntry(dataJson, activityIndex.getValue(), activityString, "index");
|
||||
putDataEntry(dataJson, playtime, numberFormatters.get(FormatType.TIME_MILLISECONDS).apply(playtime), "playtime");
|
||||
putDataEntry(dataJson, activePlaytime, numberFormatters.get(FormatType.TIME_MILLISECONDS).apply(activePlaytime), "activePlaytime");
|
||||
putDataEntry(dataJson, loginTimes, "sessions");
|
||||
putDataEntry(dataJson, registered, numberFormatters.get(FormatType.DATE_YEAR).apply(registered), "registered");
|
||||
putDataEntry(dataJson, lastSeen, numberFormatters.get(FormatType.DATE_YEAR).apply(lastSeen), "seen");
|
||||
@ -189,7 +189,7 @@ public class PlayersTableJSONCreator {
|
||||
|
||||
columnHeaders.add(makeColumnHeader(Icon.called("user") + " " + locale.get(HtmlLang.LABEL_NAME), "name"));
|
||||
columnHeaders.add(makeFColumnHeader(Icon.called("check") + " " + locale.get(HtmlLang.LABEL_ACTIVITY_INDEX), "index"));
|
||||
columnHeaders.add(makeFColumnHeader(Icon.called("clock").of(Family.REGULAR) + " " + locale.get(HtmlLang.LABEL_PLAYTIME), "playtime"));
|
||||
columnHeaders.add(makeFColumnHeader(Icon.called("clock").of(Family.REGULAR) + " " + locale.get(HtmlLang.LABEL_ACTIVE_PLAYTIME), "activePlaytime"));
|
||||
columnHeaders.add(makeColumnHeader(Icon.called("calendar-plus").of(Family.REGULAR) + " " + locale.get(HtmlLang.SIDE_SESSIONS), "sessions"));
|
||||
columnHeaders.add(makeFColumnHeader(Icon.called("user-plus") + " " + locale.get(HtmlLang.LABEL_REGISTERED), "registered"));
|
||||
columnHeaders.add(makeFColumnHeader(Icon.called("calendar-check").of(Family.REGULAR) + " " + locale.get(HtmlLang.LABEL_LAST_SEEN), "seen"));
|
||||
|
@ -71,6 +71,7 @@ public enum HtmlLang implements Lang {
|
||||
LABEL_PLAYERS_ONLINE("Players Online"),
|
||||
LABEL_TOTAL_PLAYTIME("Total Playtime"),
|
||||
LABEL_PLAYTIME("Playtime"),
|
||||
LABEL_ACTIVE_PLAYTIME("Active Playtime"),
|
||||
LABEL_LAST_PEAK("Last Peak"),
|
||||
LABEL_BEST_PEAK("Best Peak"),
|
||||
LABEL_AVG_PLAYTIME("Average Playtime"),
|
||||
|
@ -75,7 +75,7 @@ public class NetworkTablePlayersQuery implements Query<List<TablePlayer>> {
|
||||
String selectSessionData = SELECT + "s." + SessionsTable.USER_UUID + ',' +
|
||||
"MAX(" + SessionsTable.SESSION_END + ") as last_seen," +
|
||||
"COUNT(1) as count," +
|
||||
"SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + ") as playtime" +
|
||||
"SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + '-' + SessionsTable.AFK_TIME + ") as active_playtime" +
|
||||
FROM + SessionsTable.TABLE_NAME + " s" +
|
||||
GROUP_BY + "s." + SessionsTable.USER_UUID;
|
||||
|
||||
@ -91,7 +91,7 @@ public class NetworkTablePlayersQuery implements Query<List<TablePlayer>> {
|
||||
"geoloc." + GeoInfoTable.GEOLOCATION + ',' +
|
||||
"ses.last_seen," +
|
||||
"ses.count," +
|
||||
"ses.playtime," +
|
||||
"ses.active_playtime," +
|
||||
"act.activity_index" +
|
||||
FROM + UsersTable.TABLE_NAME + " u" +
|
||||
LEFT_JOIN + '(' + selectBanned + ") ban on ban." + UserInfoTable.USER_UUID + "=u." + UsersTable.USER_UUID +
|
||||
@ -119,7 +119,7 @@ public class NetworkTablePlayersQuery implements Query<List<TablePlayer>> {
|
||||
.registered(set.getLong(UsersTable.REGISTERED))
|
||||
.lastSeen(set.getLong("last_seen"))
|
||||
.sessionCount(set.getInt("count"))
|
||||
.playtime(set.getLong("playtime"))
|
||||
.activePlaytime(set.getLong("active_playtime"))
|
||||
.activityIndex(new ActivityIndex(set.getDouble("activity_index"), date));
|
||||
if (set.getString("banned") != null) {
|
||||
player.banned();
|
||||
|
@ -88,7 +88,7 @@ public class QueryTablePlayersQuery implements Query<List<TablePlayer>> {
|
||||
String selectSessionData = SELECT + "s." + SessionsTable.USER_UUID + ',' +
|
||||
"MAX(" + SessionsTable.SESSION_END + ") as last_seen," +
|
||||
"COUNT(1) as count," +
|
||||
"SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + ") as playtime" +
|
||||
"SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + '-' + SessionsTable.AFK_TIME + ") as active_playtime" +
|
||||
FROM + SessionsTable.TABLE_NAME + " s" +
|
||||
WHERE + "s." + SessionsTable.SESSION_START + ">=?" +
|
||||
AND + "s." + SessionsTable.SESSION_END + "<=?" +
|
||||
@ -104,7 +104,7 @@ public class QueryTablePlayersQuery implements Query<List<TablePlayer>> {
|
||||
"geoloc." + GeoInfoTable.GEOLOCATION + ',' +
|
||||
"ses.last_seen," +
|
||||
"ses.count," +
|
||||
"ses.playtime," +
|
||||
"ses.active_playtime," +
|
||||
"act.activity_index" +
|
||||
FROM + UsersTable.TABLE_NAME + " u" +
|
||||
INNER_JOIN + UserInfoTable.TABLE_NAME + " on u." + UsersTable.USER_UUID + "=" + UserInfoTable.TABLE_NAME + '.' + UserInfoTable.USER_UUID +
|
||||
@ -134,7 +134,7 @@ public class QueryTablePlayersQuery implements Query<List<TablePlayer>> {
|
||||
.registered(set.getLong(UsersTable.REGISTERED))
|
||||
.lastSeen(set.getLong("last_seen"))
|
||||
.sessionCount(set.getInt("count"))
|
||||
.playtime(set.getLong("playtime"))
|
||||
.activePlaytime(set.getLong("active_playtime"))
|
||||
.activityIndex(new ActivityIndex(set.getDouble("activity_index"), beforeDate));
|
||||
if (set.getBoolean(UserInfoTable.BANNED)) {
|
||||
player.banned();
|
||||
|
@ -85,7 +85,7 @@ public class ServerTablePlayersQuery implements Query<List<TablePlayer>> {
|
||||
String selectSessionData = SELECT + "s." + SessionsTable.USER_UUID + ',' +
|
||||
"MAX(" + SessionsTable.SESSION_END + ") as last_seen," +
|
||||
"COUNT(1) as count," +
|
||||
"SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + ") as playtime" +
|
||||
"SUM(" + SessionsTable.SESSION_END + '-' + SessionsTable.SESSION_START + '-' + SessionsTable.AFK_TIME + ") as active_playtime" +
|
||||
FROM + SessionsTable.TABLE_NAME + " s" +
|
||||
WHERE + "s." + SessionsTable.SERVER_UUID + "=?" +
|
||||
GROUP_BY + "s." + SessionsTable.USER_UUID;
|
||||
@ -98,7 +98,7 @@ public class ServerTablePlayersQuery implements Query<List<TablePlayer>> {
|
||||
"geoloc." + GeoInfoTable.GEOLOCATION + ',' +
|
||||
"ses.last_seen," +
|
||||
"ses.count," +
|
||||
"ses.playtime," +
|
||||
"ses.active_playtime," +
|
||||
"act.activity_index" +
|
||||
FROM + UsersTable.TABLE_NAME + " u" +
|
||||
INNER_JOIN + UserInfoTable.TABLE_NAME + " on u." + UsersTable.USER_UUID + "=" + UserInfoTable.TABLE_NAME + '.' + UserInfoTable.USER_UUID +
|
||||
@ -128,7 +128,7 @@ public class ServerTablePlayersQuery implements Query<List<TablePlayer>> {
|
||||
.registered(set.getLong(UsersTable.REGISTERED))
|
||||
.lastSeen(set.getLong("last_seen"))
|
||||
.sessionCount(set.getInt("count"))
|
||||
.playtime(set.getLong("playtime"))
|
||||
.activePlaytime(set.getLong("active_playtime"))
|
||||
.activityIndex(new ActivityIndex(set.getDouble("activity_index"), date));
|
||||
if (set.getBoolean(UserInfoTable.BANNED)) {
|
||||
player.banned();
|
||||
|
@ -280,8 +280,8 @@ public interface SessionQueriesTest extends DatabaseTestPreparer {
|
||||
.stream().filter(player -> playerUUID.equals(player.getPlayerUUID())).findAny()
|
||||
.orElseThrow(AssertionError::new);
|
||||
|
||||
long expected = SessionsMutator.forContainer(playerContainer).toPlaytime();
|
||||
long got = tablePlayer.getPlaytime().orElseThrow(AssertionError::new);
|
||||
long expected = SessionsMutator.forContainer(playerContainer).toActivePlaytime();
|
||||
long got = tablePlayer.getActivePlaytime().orElseThrow(AssertionError::new);
|
||||
assertEquals(expected, got);
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,7 @@ public class RandomData {
|
||||
Session session = new Session(uuids[0], serverUUID, RandomData.randomTime(), pickAtRandom(worlds), randomGameMode());
|
||||
session.endSession(RandomData.randomTimeAfter(session.getDate()));
|
||||
session.setWorldTimes(RandomData.randomWorldTimes(worlds));
|
||||
session.addAFKTime(RandomData.randomLong(1, session.getLength()));
|
||||
if (uuids.length >= 2) {
|
||||
session.setPlayerKills(RandomData.randomKills(uuids[0], pickAtRandom(Arrays.copyOfRange(uuids, 1, uuids.length))));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user