Fixed WorldPie Drilldown (Was missing a module)

This commit is contained in:
Rsl1122 2017-08-30 11:33:46 +03:00
parent 3952268e71
commit ecbdd630a3
4 changed files with 69 additions and 3 deletions

View File

@ -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<String, Long> 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);
}
}
}

View File

@ -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<Session> sessionsInLengthOrder = allSessions.stream()
.sorted(new SessionLengthComparator())
.collect(Collectors.toList());

View File

@ -73,10 +73,14 @@ public class WorldPieCreator {
int smallSize = gmTimes.size();
int j = 0;
for (Map.Entry<String, Long> 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) {

View File

@ -122,7 +122,7 @@
</div>
</div>
</div>
<div id="tab-performance" class="tab">
<div id="tab-overview" class="tab">
<div class="row">
<div class="column"> <!--First row (horizontal)-->
<div class="column">
@ -174,6 +174,7 @@
</div>
<script src="https://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js"></script>
<script src="https://code.highcharts.com/maps/modules/map.js"></script>
<script src="https://code.highcharts.com/mapdata/custom/world.js"></script>
<script src="./js/punchCard.js"></script>
@ -181,6 +182,14 @@
<script src="./js/worldPie.js"></script>
<script src="./js/pluginsTabExpand.js"></script>
<script src="./js/sessionTabExpand.js"></script>
<script>
var worldSeries = {
name:'World Playtime',
colorByPoint:true,
data: ${worldPieSeries}
};
var gmSeries = ${gmSeries};
</script>
<script>
var navButtons = document.getElementsByClassName("nav-button");
var tabs = document.getElementsByClassName("tab");
@ -196,6 +205,9 @@
tabs[i].style.width = "" + 100 / navButtons.length + "%";
}
x.style.opacity = "1";
worldPie('worldPie', worldSeries, gmSeries);
openFunc(slideIndex)();
function openFunc(i) {