From ecbdd630a382e01c0b092d4f81d5cf82d7e0fcd0 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Wed, 30 Aug 2017 11:33:46 +0300 Subject: [PATCH] Fixed WorldPie Drilldown (Was missing a module) --- .../plan/database/tables/WorldTimesTable.java | 41 +++++++++++++++++++ .../info/parsing/InspectPageParser.java | 11 ++++- .../html/graphs/WorldPieCreator.java | 6 ++- Plan/src/main/resources/html/player.html | 14 ++++++- 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java index 18291ed3c..b60e31eff 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/WorldTimesTable.java @@ -203,4 +203,45 @@ public class WorldTimesTable extends UserIDTable { close(set, statement); } } + + public WorldTimes getWorldTimesOfUser(UUID uuid) throws SQLException { + PreparedStatement statement = null; + ResultSet set = null; + try { + String worldIDColumn = worldTable + "." + worldTable.getColumnID(); + String worldNameColumn = worldTable + "." + worldTable.getColumnWorldName() + " as world_name"; + String sessionIDColumn = sessionsTable + "." + sessionsTable.getColumnID(); + statement = prepareStatement("SELECT " + + "SUM(" + columnSurvival + ") as survival, " + + "SUM(" + columnCreative + ") as creative, " + + "SUM(" + columnAdventure + ") as adventure, " + + "SUM(" + columnSpectator + ") as spectator, " + + worldNameColumn + + " FROM " + tableName + + " JOIN " + worldTable + " on " + worldIDColumn + "=" + columnWorldId + + " WHERE " + columnUserID + "=" + usersTable.statementSelectID + ); + statement.setString(1, uuid.toString()); + set = statement.executeQuery(); + String[] gms = GMTimes.getGMKeyArray(); + + WorldTimes worldTimes = new WorldTimes(new HashMap<>()); + while (set.next()) { + String worldName = set.getString("world_name"); + + Map gmMap = new HashMap<>(); + gmMap.put(gms[0], set.getLong("survival")); + gmMap.put(gms[1], set.getLong("creative")); + gmMap.put(gms[2], set.getLong("adventure")); + gmMap.put(gms[3], set.getLong("spectator")); + GMTimes gmTimes = new GMTimes(gmMap); + + worldTimes.setGMTimesForWorld(worldName, gmTimes); + } + return worldTimes; + } finally { + endTransaction(statement); + close(set, statement); + } + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java index 338f38813..c2af2c5f9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java +++ b/Plan/src/main/java/com/djrapitops/plan/systems/info/parsing/InspectPageParser.java @@ -25,6 +25,7 @@ import main.java.com.djrapitops.plan.utilities.file.FileUtil; import main.java.com.djrapitops.plan.utilities.html.HtmlStructure; import main.java.com.djrapitops.plan.utilities.html.HtmlUtils; import main.java.com.djrapitops.plan.utilities.html.graphs.PunchCardGraphCreator; +import main.java.com.djrapitops.plan.utilities.html.graphs.WorldPieCreator; import main.java.com.djrapitops.plan.utilities.html.tables.ActionsTableCreator; import java.io.FileNotFoundException; @@ -139,7 +140,15 @@ public class InspectPageParser { addValue("sessionCount", sessionCount); addValue("playtimeTotal", FormatUtils.formatTimeAmount(playTime)); - String puchCardData = PunchCardGraphCreator.createDataSeries(allSessions); + String punchCardData = PunchCardGraphCreator.createDataSeries(allSessions); + String[] worldPieData = WorldPieCreator.createSeriesData(db.getWorldTimesTable().getWorldTimesOfUser(uuid)); + + addValue("worldPieSeries", worldPieData[0]); + addValue("gmSeries", worldPieData[1]); + + + addValue("punchCardData", punchCardData); + List sessionsInLengthOrder = allSessions.stream() .sorted(new SessionLengthComparator()) .collect(Collectors.toList()); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java index 8ca52a201..33c9267d8 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/WorldPieCreator.java @@ -73,10 +73,14 @@ public class WorldPieCreator { int smallSize = gmTimes.size(); int j = 0; for (Map.Entry entry : gmTimes.entrySet()) { + Long time = entry.getValue(); + if (time == 0) { + continue; + } drilldownBuilder.append("['") .append(entry.getKey()) .append("',") - .append(entry.getValue()) + .append(time) .append("]"); if (j < smallSize - 1) { diff --git a/Plan/src/main/resources/html/player.html b/Plan/src/main/resources/html/player.html index b62e887af..e2edc27dd 100644 --- a/Plan/src/main/resources/html/player.html +++ b/Plan/src/main/resources/html/player.html @@ -122,7 +122,7 @@ -
+
@@ -174,6 +174,7 @@
+ @@ -181,6 +182,14 @@ +