mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-23 00:21:43 +01:00
Session accordion to network page
This commit is contained in:
parent
14e295e75d
commit
db674a7ec5
@ -331,6 +331,27 @@ public class SessionQueries {
|
||||
};
|
||||
}
|
||||
|
||||
private static Query<Long> fetchLatestSessionStartLimit(int limit) {
|
||||
String sql = SELECT + SessionsTable.SESSION_START + FROM + SessionsTable.TABLE_NAME +
|
||||
ORDER_BY_SESSION_START_DESC + " LIMIT ?";
|
||||
|
||||
return new QueryStatement<Long>(sql, limit) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setInt(1, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long processResults(ResultSet set) throws SQLException {
|
||||
Long last = null;
|
||||
while (set.next()) {
|
||||
last = set.getLong(SessionsTable.SESSION_START);
|
||||
}
|
||||
return last;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<List<Session>> fetchLatestSessionsOfServer(UUID serverUUID, int limit) {
|
||||
String sql = SELECT_SESSIONS_STATEMENT +
|
||||
WHERE + "s." + SessionsTable.SERVER_UUID + "=?" +
|
||||
@ -354,6 +375,27 @@ public class SessionQueries {
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<List<Session>> fetchLatestSessions(int limit) {
|
||||
String sql = SELECT_SESSIONS_STATEMENT +
|
||||
WHERE + "s." + SessionsTable.SESSION_START + ">=?" +
|
||||
ORDER_BY_SESSION_START_DESC;
|
||||
|
||||
return db -> {
|
||||
Long start = db.query(fetchLatestSessionStartLimit(limit));
|
||||
return db.query(new QueryStatement<List<Session>>(sql) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setLong(1, start != null ? start : 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Session> processResults(ResultSet set) throws SQLException {
|
||||
return extractDataFromSessionSelectStatement(set);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
public static Query<Long> sessionCount(long after, long before, UUID serverUUID) {
|
||||
String sql = SELECT + "COUNT(1) as count" +
|
||||
FROM + SessionsTable.TABLE_NAME +
|
||||
|
@ -94,6 +94,17 @@ public class JSONFactory {
|
||||
return new SessionsMutator(sessions).toPlayerNameJSONMaps(graphs, config.getWorldAliasSettings(), formatters);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> serverSessionsAsJSONMap() {
|
||||
Database db = dbSystem.getDatabase();
|
||||
List<Session> sessions = db.query(SessionQueries.fetchLatestSessions(
|
||||
config.get(DisplaySettings.SESSIONS_PER_PAGE)
|
||||
));
|
||||
List<Map<String, Object>> sessionMaps = new SessionsMutator(sessions).toPlayerNameJSONMaps(graphs, config.getWorldAliasSettings(), formatters);
|
||||
//
|
||||
sessionMaps.forEach(map -> map.put("network_server", map.get("server_name")));
|
||||
return sessionMaps;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> serverPlayerKillsAsJSONMap(UUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
List<PlayerKill> kills = db.query(KillQueries.fetchPlayerKillsOnServer(serverUUID, 100));
|
||||
|
@ -54,8 +54,12 @@ public class SessionsJSONHandler implements PageHandler {
|
||||
|
||||
@Override
|
||||
public Response getResponse(Request request, RequestTarget target) throws WebException {
|
||||
UUID serverUUID = identifiers.getServerUUID(target);
|
||||
return new JSONResponse(Collections.singletonMap("sessions", jsonFactory.serverSessionsAsJSONMap(serverUUID)));
|
||||
if (target.getParameter("server").isPresent()) {
|
||||
UUID serverUUID = identifiers.getServerUUID(target);
|
||||
return new JSONResponse(Collections.singletonMap("sessions", jsonFactory.serverSessionsAsJSONMap(serverUUID)));
|
||||
}
|
||||
// Assume network
|
||||
return new JSONResponse(Collections.singletonMap("sessions", jsonFactory.serverSessionsAsJSONMap()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,7 +69,7 @@ function createAccordionTitle(i, session) {
|
||||
+ session.name + (session.first_session ? ' <i title="Registered (First session)" class="far fa-calendar-plus"></i>' : '') + '</td>'
|
||||
+ '<td>' + session.start + '</td>'
|
||||
+ '<td>' + session.length + '</td>'
|
||||
+ '<td>' + session.most_used_world + '</td></tr>'
|
||||
+ '<td>' + (session.network_server ? session.network_server : session.most_used_world) + '</td></tr>'
|
||||
}
|
||||
|
||||
function createAccordionBody(i, session) {
|
||||
@ -87,7 +87,8 @@ function createAccordionBody(i, session) {
|
||||
createKillsTable(session.player_kills) +
|
||||
'</div><div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">' +
|
||||
'<div id="worldpie_' + i + '" class="chart-pie"></div>' +
|
||||
'<a target="_blank" href="/player/' + session.player_name + '"><button type="button" class="float-right btn bg-blue waves-effect\"><i class="fa fa-user"></i><span> Player Page</span></button></a>' +
|
||||
'<a href="/player/' + session.player_name + '" class="float-right btn bg-blue"><i class="fa fa-user"></i><span> Player Page</span></a>' +
|
||||
(session.network_server ? '<a href="/server/' + session.server_name + '" class="float-right btn bg-light-green mr-2"><i class="fa fa-server"></i><span> Server Page</span></a>' : '') +
|
||||
'</div>' +
|
||||
'</div></td></tr>'
|
||||
}
|
||||
|
@ -365,7 +365,7 @@
|
||||
</div> <!-- /.container-fluid -->
|
||||
</div> <!-- End of Servers Overview tab -->
|
||||
<!-- Begin Sessions Tab -->
|
||||
<div class="tab">
|
||||
<div class="tab" id="sessions-overview">
|
||||
<div class="container-fluid mt-4">
|
||||
<!-- Page Heading -->
|
||||
<div class="d-sm-flex align-items-center justify-content-between mb-4">
|
||||
@ -394,242 +394,6 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr aria-controls="session_t_1" aria-expanded="true"
|
||||
class="clickable collapsed bg-teal" data-target="#session_t_1"
|
||||
data-toggle="collapse">
|
||||
<td>Rsl1122</td>
|
||||
<td>Oct 28 2018, 10:05</td>
|
||||
<td>3s</td>
|
||||
<td>BungeeCord</td>
|
||||
</tr>
|
||||
<tr class="collapse" data-parent="#tableAccordion" id="session_t_1">
|
||||
<td colspan="4">
|
||||
<div class="collapse row" data-parent="#tableAccordion"
|
||||
id="session_t_1">
|
||||
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
|
||||
<p><i class="col-teal far fa-fw fa-clock"></i> Session Ended<span
|
||||
class="float-right"><b>Oct 28 2018, 10:05</b></span>
|
||||
</p>
|
||||
<p><i class="col-green far fa-fw fa-clock"></i> Session
|
||||
Length<span class="float-right"><b>3s</b></span></p>
|
||||
<p><i class="col-green fa fa-fw fa-server"></i> Server<span
|
||||
class="float-right"><b>BungeeCord</b></span></p><br>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
|
||||
<a href="../player/Rsl1122" target="_blank">
|
||||
<button
|
||||
class="float-right btn bg-blue waves-effect"
|
||||
href="../player/Rsl1122"
|
||||
type="button"><i
|
||||
class="fa fa-fw fa-user"></i> Inspect
|
||||
Page
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr aria-controls="session_t_2" aria-expanded="true"
|
||||
class="clickable collapsed bg-teal" data-target="#session_t_2"
|
||||
data-toggle="collapse">
|
||||
<td>Rsl1122</td>
|
||||
<td>Oct 28 2018, 9:05</td>
|
||||
<td>45s</td>
|
||||
<td>Server 1</td>
|
||||
</tr>
|
||||
<tr class="collapse" data-parent="#tableAccordion" id="session_t_2">
|
||||
<td colspan="4">
|
||||
<div class="row collapse" data-parent="#tableAccordion"
|
||||
id="session_t_2">
|
||||
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
|
||||
<p><i class="col-teal far fa-fw fa-clock"></i> Session Ended<span
|
||||
class="float-right"><b>Oct 28 2018, 10:05</b></span>
|
||||
</p>
|
||||
<p><i class="col-green far fa-fw fa-clock"></i> Session
|
||||
Length<span class="float-right"><b>3s</b></span></p>
|
||||
<p><i class="col-grey far fa-fw fa-clock"></i> AFK<span
|
||||
class="float-right"><b>-</b></span></p>
|
||||
<p><i class="col-green fa fa-fw fa-server"></i> Server<span
|
||||
class="float-right"><b>Server 1</b></span></p><br>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
|
||||
<div class="dashboard-donut-chart"
|
||||
data-highcharts-chart="16" id="worldPieSession15407139399600"
|
||||
style="overflow: hidden;">
|
||||
<div class="highcharts-container "
|
||||
dir="ltr"
|
||||
id="highcharts-otzrxhx-11604"
|
||||
style="position: relative; overflow: hidden; width: 426px; height: 265px; text-align: left; line-height: normal; z-index: 0; left: 0px; top: 0px;">
|
||||
<svg
|
||||
class="highcharts-root " height="265"
|
||||
style="font-family:"Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif;font-size:12px;"
|
||||
version="1.1" viewBox="0 0 426 265"
|
||||
width="426" xmlns="http://www.w3.org/2000/svg">
|
||||
<desc>Created with Highstock 7.0.3</desc>
|
||||
<defs>
|
||||
<clipPath id="highcharts-otzrxhx-11606">
|
||||
<rect fill="none" height="166" width="406"
|
||||
x="0" y="0"></rect>
|
||||
</clipPath>
|
||||
</defs>
|
||||
<rect class="highcharts-background"
|
||||
fill="#ffffff" height="265" rx="0"
|
||||
ry="0" width="426" x="0" y="0">
|
||||
</rect>
|
||||
<rect class="highcharts-plot-background"
|
||||
fill="none" height="166"
|
||||
width="406" x="10" y="43"></rect>
|
||||
<g class="highcharts-pane-group"
|
||||
data-z-index="0"></g>
|
||||
<rect class="highcharts-plot-border" data-z-index="1"
|
||||
fill="none" height="166" width="406" x="10"
|
||||
y="43"></rect>
|
||||
<g class="highcharts-series-group"
|
||||
data-z-index="3">
|
||||
<g class="highcharts-series highcharts-series-0 highcharts-pie-series highcharts-tracker "
|
||||
data-z-index="0.1"
|
||||
style="cursor:pointer;"
|
||||
transform="translate(10,43) scale(1 1)">
|
||||
<path class="highcharts-halo highcharts-color-0 "
|
||||
d="M 202.98513185613027 10.000001514121266 A 73 73 0 1 1 202.8986044645208 10.000070418216254 M 202.89999344445886 11.000069453583151 A 72 72 0 1 0 202.98533552933395 11.00000149337987 "
|
||||
data-z-index="-1"
|
||||
fill="#0099C6"
|
||||
fill-opacity="0.25"
|
||||
style="cursor:auto;"
|
||||
visibility="hidden"></path>
|
||||
<path class="highcharts-point highcharts-color-0 highcharts-drilldown-point "
|
||||
d="M 202.98513185613027 10.000001514121266 A 73 73 0 1 1 202.8986044645208 10.000070418216254 M 203 83 A 0 0 0 1 0 203 83 "
|
||||
fill="rgb(0,153,198)"
|
||||
stroke="#ffffff" stroke-linejoin="round"
|
||||
stroke-width="1"
|
||||
style="cursor:pointer;"
|
||||
transform="translate(0,0)"></path>
|
||||
</g>
|
||||
<g class="highcharts-markers highcharts-series-0 highcharts-pie-series "
|
||||
data-z-index="0.1"
|
||||
transform="translate(10,43) scale(1 1)">
|
||||
</g>
|
||||
</g>
|
||||
<text class="highcharts-title" data-z-index="4"
|
||||
style="color:#333333;font-size:18px;fill:#333333;"
|
||||
text-anchor="middle"
|
||||
x="213"
|
||||
y="24"></text>
|
||||
<text class="highcharts-subtitle"
|
||||
data-z-index="4"
|
||||
style="color:#666666;fill:#666666;"
|
||||
text-anchor="middle"
|
||||
x="213" y="24">
|
||||
<tspan>Click the slices to view used
|
||||
GameMode
|
||||
</tspan>
|
||||
</text>
|
||||
<g class="highcharts-legend" data-z-index="7"
|
||||
transform="translate(178,221)">
|
||||
<rect class="highcharts-legend-box"
|
||||
fill="none" height="29"
|
||||
rx="0" ry="0" visibility="visible" width="70"
|
||||
x="0" y="0"></rect>
|
||||
<g data-z-index="1">
|
||||
<g>
|
||||
<g class="highcharts-legend-item highcharts-pie-series highcharts-color-0"
|
||||
data-z-index="1"
|
||||
transform="translate(8,3)">
|
||||
<text
|
||||
data-z-index="2"
|
||||
style="color:#333333;cursor:pointer;font-size:12px;font-weight:bold;fill:#333333;"
|
||||
text-anchor="start"
|
||||
x="21" y="15">
|
||||
<tspan>world</tspan>
|
||||
</text>
|
||||
<rect class="highcharts-point"
|
||||
data-z-index="3" fill="#0099C6"
|
||||
height="12" rx="6"
|
||||
ry="6" width="12"
|
||||
x="2"
|
||||
y="4"></rect>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<text class="highcharts-credits" data-z-index="8"
|
||||
style="cursor:pointer;color:#999999;font-size:9px;fill:#999999;"
|
||||
text-anchor="end"
|
||||
x="416"
|
||||
y="260">Highcharts.com
|
||||
</text>
|
||||
<g class="highcharts-label highcharts-tooltip highcharts-color-0"
|
||||
data-z-index="8"
|
||||
opacity="0"
|
||||
style="pointer-events:none;white-space:nowrap;"
|
||||
transform="translate(101,-9999)"
|
||||
visibility="visible">
|
||||
<path class="highcharts-label-box highcharts-tooltip-box highcharts-shadow"
|
||||
d="M 3.5 0.5 L 130.5 0.5 C 133.5 0.5 133.5 0.5 133.5 3.5 L 133.5 31.5 C 133.5 34.5 133.5 34.5 130.5 34.5 L 3.5 34.5 C 0.5 34.5 0.5 34.5 0.5 31.5 L 0.5 3.5 C 0.5 0.5 0.5 0.5 3.5 0.5"
|
||||
fill="none"
|
||||
stroke="#000000"
|
||||
stroke-opacity="0.049999999999999996"
|
||||
stroke-width="5"
|
||||
transform="translate(1, 1)"></path>
|
||||
<path class="highcharts-label-box highcharts-tooltip-box highcharts-shadow"
|
||||
d="M 3.5 0.5 L 130.5 0.5 C 133.5 0.5 133.5 0.5 133.5 3.5 L 133.5 31.5 C 133.5 34.5 133.5 34.5 130.5 34.5 L 3.5 34.5 C 0.5 34.5 0.5 34.5 0.5 31.5 L 0.5 3.5 C 0.5 0.5 0.5 0.5 3.5 0.5"
|
||||
fill="none"
|
||||
stroke="#000000"
|
||||
stroke-opacity="0.09999999999999999"
|
||||
stroke-width="3"
|
||||
transform="translate(1, 1)"></path>
|
||||
<path class="highcharts-label-box highcharts-tooltip-box highcharts-shadow"
|
||||
d="M 3.5 0.5 L 130.5 0.5 C 133.5 0.5 133.5 0.5 133.5 3.5 L 133.5 31.5 C 133.5 34.5 133.5 34.5 130.5 34.5 L 3.5 34.5 C 0.5 34.5 0.5 34.5 0.5 31.5 L 0.5 3.5 C 0.5 0.5 0.5 0.5 3.5 0.5"
|
||||
fill="none"
|
||||
stroke="#000000" stroke-opacity="0.15"
|
||||
stroke-width="1"
|
||||
transform="translate(1, 1)"></path>
|
||||
<path class="highcharts-label-box highcharts-tooltip-box"
|
||||
d="M 3.5 0.5 L 130.5 0.5 C 133.5 0.5 133.5 0.5 133.5 3.5 L 133.5 31.5 C 133.5 34.5 133.5 34.5 130.5 34.5 L 3.5 34.5 C 0.5 34.5 0.5 34.5 0.5 31.5 L 0.5 3.5 C 0.5 0.5 0.5 0.5 3.5 0.5"
|
||||
fill="rgba(247,247,247,0.85)"
|
||||
stroke="#0099C6" stroke-width="1">
|
||||
</path>
|
||||
<text data-z-index="1"
|
||||
style="font-size:12px;color:#333333;cursor:default;fill:#333333;"
|
||||
x="8"
|
||||
y="20">
|
||||
<tspan style="font-weight:bold">world:
|
||||
</tspan>
|
||||
<tspan dx="0"> 3s (100.00%)</tspan>
|
||||
</text>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<script>var worldPieSession15407139399600series = {
|
||||
name: 'World Playtime',
|
||||
colorByPoint: true,
|
||||
data: [{
|
||||
name: 'world',
|
||||
y: 3947,
|
||||
color: "#0099C6",
|
||||
drilldown: 'world'
|
||||
}]
|
||||
};
|
||||
var worldPieSession15407139399600gmseries = [{
|
||||
name: 'world',
|
||||
id: 'world',
|
||||
colors: gmPieColors,
|
||||
data: [['SURVIVAL', 0], ['SPECTATOR', 0], ['CREATIVE', 3947], ['ADVENTURE', 0]]
|
||||
}];</script>
|
||||
<a href="../player/Rsl1122" target="_blank">
|
||||
<button
|
||||
class="float-right btn bg-blue waves-effect"
|
||||
href="../player/Rsl1122"
|
||||
type="button"><i
|
||||
class="fa fa-fw fa-user"></i> Inspect
|
||||
Page
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -642,7 +406,7 @@
|
||||
class="fa fa-fw fa-network-wired col-teal"></i>
|
||||
Server Playtime</h6>
|
||||
</div>
|
||||
<div class="chart-pie"></div>
|
||||
<div class="chart-pie" id="serverPie"></div>
|
||||
</div>
|
||||
<!-- Insights -->
|
||||
<div class="card shadow mb-4">
|
||||
@ -651,19 +415,16 @@
|
||||
class="far fa-fw fa-life-ring col-red"></i>
|
||||
Insights for 30 Days</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-body" id="data_insights">
|
||||
<p><i class="far fa-fw fa-clock col-teal"></i> Most Active Time<span
|
||||
class="float-right"><b>Friday
|
||||
19:24</b></span></p>
|
||||
class="float-right"><b id="data_most_active_time"></b></span></p>
|
||||
<p><i class="far fa-fw fa-clock col-teal"></i> Least Active Time<span
|
||||
class="float-right"><b>Monday
|
||||
1:24</b></span></p>
|
||||
class="float-right"><b id="data_least_active_time"></b></span></p>
|
||||
<p><i class="far fa-fw fa-clock col-teal"></i> Total Playtime<span
|
||||
class="float-right">5d
|
||||
44h 32m 4s</span></p>
|
||||
class="float-right" id="data_total_playtime"></span></p>
|
||||
<p><i class="far fa-fw fa-clock col-grey"></i> AFK Time<span
|
||||
class="float-right">(54.86%) 2d
|
||||
54h 43m 2s</span></p>
|
||||
class="float-right"><span id="data_afk_time"></span> (<span
|
||||
id="data_afk_time_perc"></span>)</span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1114,6 +875,7 @@
|
||||
jsonRequest("../v1/network/overview", loadNetworkOverviewValues);
|
||||
jsonRequest("../v1/network/servers", loadServerBoxes);
|
||||
jsonRequest("../v1/network/playerbaseOverview", loadPlayerbaseOverviewValues);
|
||||
jsonRequest("../v1/sessions", loadSessionAccordion);
|
||||
setLoadingText('Rendering graphs..');
|
||||
|
||||
var v = {
|
||||
|
Loading…
Reference in New Issue
Block a user