mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-08 17:37:34 +01:00
Ping table to Geolocations tab (network page)
This commit is contained in:
parent
cbce9ff5aa
commit
a3f00c7916
@ -244,4 +244,55 @@ public class PingQueries {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Query<Map<String, Ping>> fetchPingDataOfNetworkByGeolocation() {
|
||||||
|
String selectPingOfServer = SELECT +
|
||||||
|
PingTable.MAX_PING + ", " +
|
||||||
|
PingTable.MIN_PING + ", " +
|
||||||
|
PingTable.AVG_PING + ", " +
|
||||||
|
PingTable.USER_UUID + ", " +
|
||||||
|
PingTable.SERVER_UUID +
|
||||||
|
FROM + PingTable.TABLE_NAME;
|
||||||
|
|
||||||
|
String selectGeolocations = SELECT +
|
||||||
|
GeoInfoTable.USER_UUID + ", " +
|
||||||
|
GeoInfoTable.GEOLOCATION + ", " +
|
||||||
|
GeoInfoTable.LAST_USED +
|
||||||
|
FROM + GeoInfoTable.TABLE_NAME;
|
||||||
|
String selectLatestGeolocationDate = SELECT +
|
||||||
|
GeoInfoTable.USER_UUID + ", " +
|
||||||
|
"MAX(" + GeoInfoTable.LAST_USED + ") as m" +
|
||||||
|
FROM + GeoInfoTable.TABLE_NAME +
|
||||||
|
GROUP_BY + GeoInfoTable.USER_UUID;
|
||||||
|
|
||||||
|
String selectPingByGeolocation = SELECT + GeoInfoTable.GEOLOCATION +
|
||||||
|
", MIN(" + PingTable.MIN_PING + ") as minPing" +
|
||||||
|
", MAX(" + PingTable.MAX_PING + ") as maxPing" +
|
||||||
|
", AVG(" + PingTable.AVG_PING + ") as avgPing" +
|
||||||
|
FROM + "(" +
|
||||||
|
"(" + selectGeolocations + ") AS q1" +
|
||||||
|
INNER_JOIN + "(" + selectLatestGeolocationDate + ") AS q2 ON q1.uuid = q2.uuid" +
|
||||||
|
INNER_JOIN + '(' + selectPingOfServer + ") sp on sp." + PingTable.USER_UUID + "=q1.uuid)" +
|
||||||
|
WHERE + GeoInfoTable.LAST_USED + "=m" +
|
||||||
|
GROUP_BY + GeoInfoTable.GEOLOCATION;
|
||||||
|
|
||||||
|
return new QueryAllStatement<Map<String, Ping>>(selectPingByGeolocation) {
|
||||||
|
@Override
|
||||||
|
public Map<String, Ping> processResults(ResultSet set) throws SQLException {
|
||||||
|
// TreeMap to sort alphabetically
|
||||||
|
Map<String, Ping> pingByGeolocation = new TreeMap<>();
|
||||||
|
while (set.next()) {
|
||||||
|
Ping ping = new Ping(
|
||||||
|
0L,
|
||||||
|
null,
|
||||||
|
set.getInt("minPing"),
|
||||||
|
set.getInt("maxPing"),
|
||||||
|
set.getInt("avgPing")
|
||||||
|
);
|
||||||
|
pingByGeolocation.put(set.getString(GeoInfoTable.GEOLOCATION), ping);
|
||||||
|
}
|
||||||
|
return pingByGeolocation;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
@ -160,6 +160,15 @@ public class JSONFactory {
|
|||||||
|
|
||||||
public List<Map<String, Object>> pingPerGeolocation(UUID serverUUID) {
|
public List<Map<String, Object>> pingPerGeolocation(UUID serverUUID) {
|
||||||
Map<String, Ping> pingByGeolocation = dbSystem.getDatabase().query(PingQueries.fetchPingDataOfServerByGeolocation(serverUUID));
|
Map<String, Ping> pingByGeolocation = dbSystem.getDatabase().query(PingQueries.fetchPingDataOfServerByGeolocation(serverUUID));
|
||||||
|
return turnToTableEntries(pingByGeolocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, Object>> pingPerGeolocation() {
|
||||||
|
Map<String, Ping> pingByGeolocation = dbSystem.getDatabase().query(PingQueries.fetchPingDataOfNetworkByGeolocation());
|
||||||
|
return turnToTableEntries(pingByGeolocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Map<String, Object>> turnToTableEntries(Map<String, Ping> pingByGeolocation) {
|
||||||
List<Map<String, Object>> tableEntries = new ArrayList<>();
|
List<Map<String, Object>> tableEntries = new ArrayList<>();
|
||||||
for (Map.Entry<String, Ping> entry : pingByGeolocation.entrySet()) {
|
for (Map.Entry<String, Ping> entry : pingByGeolocation.entrySet()) {
|
||||||
String geolocation = entry.getKey();
|
String geolocation = entry.getKey();
|
||||||
@ -174,4 +183,5 @@ public class JSONFactory {
|
|||||||
}
|
}
|
||||||
return tableEntries;
|
return tableEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -35,10 +35,10 @@ import javax.inject.Singleton;
|
|||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class NeworkJSONHandler extends TreePageHandler {
|
public class NetworkJSONHandler extends TreePageHandler {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NeworkJSONHandler(
|
public NetworkJSONHandler(
|
||||||
ResponseFactory responseFactory,
|
ResponseFactory responseFactory,
|
||||||
JSONFactory jsonFactory,
|
JSONFactory jsonFactory,
|
||||||
NetworkOverviewJSONParser networkOverviewJSONParser,
|
NetworkOverviewJSONParser networkOverviewJSONParser,
|
||||||
@ -49,6 +49,7 @@ public class NeworkJSONHandler extends TreePageHandler {
|
|||||||
registerPage("overview", networkOverviewJSONParser);
|
registerPage("overview", networkOverviewJSONParser);
|
||||||
registerPage("playerbaseOverview", playerBaseOverviewJSONParser);
|
registerPage("playerbaseOverview", playerBaseOverviewJSONParser);
|
||||||
registerPage("servers", jsonFactory::serversAsJSONMaps);
|
registerPage("servers", jsonFactory::serversAsJSONMaps);
|
||||||
|
registerPage("pingTable", jsonFactory::pingPerGeolocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void registerPage(String identifier, NetworkTabJSONParser<T> tabJSONParser) {
|
private <T> void registerPage(String identifier, NetworkTabJSONParser<T> tabJSONParser) {
|
@ -54,7 +54,7 @@ public class RootJSONHandler extends TreePageHandler {
|
|||||||
PlayerBaseOverviewJSONParser playerBaseOverviewJSONParser,
|
PlayerBaseOverviewJSONParser playerBaseOverviewJSONParser,
|
||||||
PerformanceJSONParser performanceJSONParser,
|
PerformanceJSONParser performanceJSONParser,
|
||||||
PlayerJSONHandler playerJSONHandler,
|
PlayerJSONHandler playerJSONHandler,
|
||||||
NeworkJSONHandler neworkJSONHandler
|
NetworkJSONHandler networkJSONHandler
|
||||||
) {
|
) {
|
||||||
super(responseFactory);
|
super(responseFactory);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class RootJSONHandler extends TreePageHandler {
|
|||||||
registerPage("performanceOverview", performanceJSONParser);
|
registerPage("performanceOverview", performanceJSONParser);
|
||||||
|
|
||||||
registerPage("player", playerJSONHandler);
|
registerPage("player", playerJSONHandler);
|
||||||
registerPage("network", neworkJSONHandler);
|
registerPage("network", networkJSONHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> void registerPage(String identifier, ServerTabJSONParser<T> tabJSONParser) {
|
private <T> void registerPage(String identifier, ServerTabJSONParser<T> tabJSONParser) {
|
||||||
|
@ -607,7 +607,7 @@
|
|||||||
</div> <!-- /.container-fluid -->
|
</div> <!-- /.container-fluid -->
|
||||||
</div> <!-- End of Player List tab -->
|
</div> <!-- End of Player List tab -->
|
||||||
<!-- Begin Geolocations Tab -->
|
<!-- Begin Geolocations Tab -->
|
||||||
<div class="tab">
|
<div class="tab" id="geolocations">
|
||||||
<div class="container-fluid mt-4">
|
<div class="container-fluid mt-4">
|
||||||
<!-- Page Heading -->
|
<!-- Page Heading -->
|
||||||
<div class="d-sm-flex align-items-center justify-content-between mb-4">
|
<div class="d-sm-flex align-items-center justify-content-between mb-4">
|
||||||
@ -645,7 +645,7 @@
|
|||||||
Connection Information</h6>
|
Connection Information</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="scrollbar">
|
<div class="scrollbar">
|
||||||
<table class="table">
|
<table class="table" id="data_ping_table">
|
||||||
<thead class="bg-amber">
|
<thead class="bg-amber">
|
||||||
<tr>
|
<tr>
|
||||||
<th><i class=" fa fa-fw fa-globe"></i> Country</th>
|
<th><i class=" fa fa-fw fa-globe"></i> Country</th>
|
||||||
@ -654,14 +654,7 @@
|
|||||||
<th><i class=" fa fa-fw fa-signal"></i> Best Ping</th>
|
<th><i class=" fa fa-fw fa-signal"></i> Best Ping</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody></tbody>
|
||||||
<tr>
|
|
||||||
<td>Local Machine</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td>-</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -874,6 +867,7 @@
|
|||||||
|
|
||||||
<!-- Page level custom scripts -->
|
<!-- Page level custom scripts -->
|
||||||
<script src="js/sessionAccordion.js"></script>
|
<script src="js/sessionAccordion.js"></script>
|
||||||
|
<script src="js/pingTable.js"></script>
|
||||||
<script src="js/graphs.js"></script>
|
<script src="js/graphs.js"></script>
|
||||||
<script src="js/network-values.js"></script>
|
<script src="js/network-values.js"></script>
|
||||||
|
|
||||||
@ -1006,6 +1000,8 @@
|
|||||||
|
|
||||||
setLoadingText('Sorting out plugin tables..');
|
setLoadingText('Sorting out plugin tables..');
|
||||||
|
|
||||||
|
jsonRequest("../v1/network/pingTable", loadPingTable);
|
||||||
|
|
||||||
$('.server-name').text('${networkDisplayName}');
|
$('.server-name').text('${networkDisplayName}');
|
||||||
$('.player-plugin-table').DataTable({
|
$('.player-plugin-table').DataTable({
|
||||||
responsive: true
|
responsive: true
|
||||||
|
Loading…
Reference in New Issue
Block a user