mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-02-02 21:41:28 +01:00
Server Preference Pie to Player page
This commit is contained in:
parent
e276252893
commit
5f55b9684c
@ -28,6 +28,8 @@ import com.djrapitops.plan.system.cache.SessionCache;
|
|||||||
import com.djrapitops.plan.system.database.DBSystem;
|
import com.djrapitops.plan.system.database.DBSystem;
|
||||||
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
import com.djrapitops.plan.system.settings.config.PlanConfig;
|
||||||
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
import com.djrapitops.plan.system.settings.paths.TimeSettings;
|
||||||
|
import com.djrapitops.plan.system.settings.theme.Theme;
|
||||||
|
import com.djrapitops.plan.system.settings.theme.ThemeVal;
|
||||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||||
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
import com.djrapitops.plan.utilities.html.graphs.Graphs;
|
||||||
@ -43,6 +45,7 @@ import java.util.stream.Collectors;
|
|||||||
public class PlayerJSONParser {
|
public class PlayerJSONParser {
|
||||||
|
|
||||||
private final PlanConfig config;
|
private final PlanConfig config;
|
||||||
|
private final Theme theme;
|
||||||
private final DBSystem dbSystem;
|
private final DBSystem dbSystem;
|
||||||
private final Graphs graphs;
|
private final Graphs graphs;
|
||||||
private final Formatters formatters;
|
private final Formatters formatters;
|
||||||
@ -54,11 +57,13 @@ public class PlayerJSONParser {
|
|||||||
@Inject
|
@Inject
|
||||||
public PlayerJSONParser(
|
public PlayerJSONParser(
|
||||||
PlanConfig config,
|
PlanConfig config,
|
||||||
|
Theme theme,
|
||||||
DBSystem dbSystem,
|
DBSystem dbSystem,
|
||||||
Formatters formatters,
|
Formatters formatters,
|
||||||
Graphs graphs
|
Graphs graphs
|
||||||
) {
|
) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
this.theme = theme;
|
||||||
this.dbSystem = dbSystem;
|
this.dbSystem = dbSystem;
|
||||||
|
|
||||||
this.formatters = formatters;
|
this.formatters = formatters;
|
||||||
@ -72,8 +77,13 @@ public class PlayerJSONParser {
|
|||||||
Database db = dbSystem.getDatabase();
|
Database db = dbSystem.getDatabase();
|
||||||
|
|
||||||
Map<UUID, String> serverNames = db.query(ServerQueries.fetchServerNames());
|
Map<UUID, String> serverNames = db.query(ServerQueries.fetchServerNames());
|
||||||
|
String[] pieColors = Arrays.stream(theme.getValue(ThemeVal.GRAPH_WORLD_PIE).split(","))
|
||||||
|
.map(color -> color.trim().replace("\"", ""))
|
||||||
|
.toArray(String[]::new);
|
||||||
|
|
||||||
PlayerContainer player = db.query(new PlayerContainerQuery(playerUUID));
|
PlayerContainer player = db.query(new PlayerContainerQuery(playerUUID));
|
||||||
SessionsMutator sessionsMutator = SessionsMutator.forContainer(player);
|
SessionsMutator sessionsMutator = SessionsMutator.forContainer(player);
|
||||||
|
Map<UUID, WorldTimes> worldTimesPerServer = PerServerMutator.forContainer(player).worldTimesPerServer();
|
||||||
|
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
data.put("info", createInfoJSONMap(player, serverNames));
|
data.put("info", createInfoJSONMap(player, serverNames));
|
||||||
@ -94,6 +104,8 @@ public class PlayerJSONParser {
|
|||||||
data.put("world_pie_series", worldPie.getSlices());
|
data.put("world_pie_series", worldPie.getSlices());
|
||||||
data.put("gm_series", worldPie.toHighChartsDrillDownMaps());
|
data.put("gm_series", worldPie.toHighChartsDrillDownMaps());
|
||||||
data.put("calendar_series", graphs.calendar().playerCalendar(player).getEntries());
|
data.put("calendar_series", graphs.calendar().playerCalendar(player).getEntries());
|
||||||
|
data.put("server_pie_series", graphs.pie().serverPreferencePie(serverNames, worldTimesPerServer).getSlices());
|
||||||
|
data.put("server_pie_colors", pieColors);
|
||||||
data.put("first_day", 1); // Monday
|
data.put("first_day", 1); // Monday
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -207,9 +219,9 @@ public class PlayerJSONParser {
|
|||||||
killData.put("deaths_30d", deaths30d);
|
killData.put("deaths_30d", deaths30d);
|
||||||
killData.put("deaths_7d", deaths7d);
|
killData.put("deaths_7d", deaths7d);
|
||||||
|
|
||||||
long mobDeaths = deaths - playerDeaths;
|
int mobDeaths = deaths - playerDeaths;
|
||||||
long mobDeaths30d = deaths30d - playerDeaths30d;
|
int mobDeaths30d = deaths30d - playerDeaths30d;
|
||||||
long mobDeaths7d = deaths7d - playerDeaths7d;
|
int mobDeaths7d = deaths7d - playerDeaths7d;
|
||||||
|
|
||||||
killData.put("mob_deaths_total", mobDeaths);
|
killData.put("mob_deaths_total", mobDeaths);
|
||||||
killData.put("mob_deaths_30d", mobDeaths30d);
|
killData.put("mob_deaths_30d", mobDeaths30d);
|
||||||
|
@ -985,7 +985,7 @@
|
|||||||
class="fa fa-fw fa-network-wired col-teal"></i>
|
class="fa fa-fw fa-network-wired col-teal"></i>
|
||||||
Server Playtime</h6>
|
Server Playtime</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="chart-pie"></div>
|
<div class="chart-pie" id="serverPie"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -1316,14 +1316,22 @@
|
|||||||
name: 'Relative Activity',
|
name: 'Relative Activity',
|
||||||
color: '#222',
|
color: '#222',
|
||||||
data: json.punchcard_series
|
data: json.punchcard_series
|
||||||
|
},
|
||||||
|
serverPie: {
|
||||||
|
name: 'Server Playtime',
|
||||||
|
colorByPoint: true,
|
||||||
|
colors: json.server_pie_colors,
|
||||||
|
data: json.server_pie_series
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
punchCard("punchCard", series.punchCard);
|
punchCard("punchCard", series.punchCard);
|
||||||
worldPie("worldPie", series.worldPie, series.worldPieGMs);
|
worldPie("worldPie", series.worldPie, series.worldPieGMs);
|
||||||
|
serverPie('serverPie', series.serverPie);
|
||||||
sessionCalendar("#sessionCalendar", json.calendar_series, json.first_day);
|
sessionCalendar("#sessionCalendar", json.calendar_series, json.first_day);
|
||||||
} else if (error) {
|
} else if (error) {
|
||||||
$('#punchCard').text("Failed to load graph data: " + error);
|
$('#punchCard').text("Failed to load graph data: " + error);
|
||||||
$('#worldPie').text("Failed to load graph data: " + error);
|
$('#worldPie').text("Failed to load graph data: " + error);
|
||||||
|
$('#serverPie').text("Failed to load graph data: " + error);
|
||||||
$('#sessionCalendar').text("Failed to load calendar data: " + error)
|
$('#sessionCalendar').text("Failed to load calendar data: " + error)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user