mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Fixed GraphTest
SessionTables to Analysis page
This commit is contained in:
parent
a7b01a05c3
commit
64cac023f7
10
Plan/pom.xml
10
Plan/pom.xml
@ -7,14 +7,6 @@
|
||||
<version>4.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>plan-repo</id>
|
||||
<url>http://repo.fuzzlemann.de/artifactory/libs-release/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>plan-snapshot-repo</id>
|
||||
<url>http://repo.fuzzlemann.de/artifactory/libs-snapshot/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
@ -78,7 +70,7 @@
|
||||
<dependency>
|
||||
<groupId>com.djrapitops</groupId>
|
||||
<artifactId>PlanPluginBridge</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<version>4.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- Testing -->
|
||||
|
@ -4,8 +4,12 @@
|
||||
*/
|
||||
package main.java.com.djrapitops.plan.utilities.html.tables;
|
||||
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.Session;
|
||||
import main.java.com.djrapitops.plan.data.analysis.JoinInfoPart;
|
||||
import main.java.com.djrapitops.plan.data.time.GMTimes;
|
||||
import main.java.com.djrapitops.plan.data.time.WorldTimes;
|
||||
import main.java.com.djrapitops.plan.systems.cache.DataCache;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.SessionStartComparator;
|
||||
import main.java.com.djrapitops.plan.utilities.html.Html;
|
||||
@ -42,26 +46,31 @@ public class SessionsTableCreator {
|
||||
|
||||
int i = 0;
|
||||
Set<String> recentLoginsNames = new HashSet<>();
|
||||
|
||||
DataCache dataCache = Plan.getInstance().getDataCache();
|
||||
|
||||
for (Session session : allSessions) {
|
||||
if (i >= 50) {
|
||||
break;
|
||||
}
|
||||
|
||||
UUID uuid = uuidByID.get(session.getSessionID());
|
||||
// TODO Name cache
|
||||
String name = "TODO";
|
||||
|
||||
String name = dataCache.getName(uuid);
|
||||
String start = FormatUtils.formatTimeStamp(session.getSessionStart());
|
||||
String length = session.getSessionEnd() != -1 ? FormatUtils.formatTimeAmount(session.getLength()) : "Online";
|
||||
// getLongestWorldPlayed()
|
||||
String world = getLongestWorldPlayed(session);
|
||||
|
||||
String inspectUrl = HtmlUtils.getRelativeInspectUrl(name);
|
||||
sessionTableBuilder.append(Html.TABLELINE_4.parse(
|
||||
inspectUrl
|
||||
|
||||
Html.LINK.parse(inspectUrl, name),
|
||||
start,
|
||||
length,
|
||||
world
|
||||
));
|
||||
|
||||
if (recentLoginsNames.size() < 20 && !recentLoginsNames.contains(name)) {
|
||||
recentLoginsBuilder.append(Html.TABLELINE_2.parse(inspectUrl, start));
|
||||
recentLoginsBuilder.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, name), start));
|
||||
recentLoginsNames.add(name);
|
||||
}
|
||||
|
||||
@ -69,4 +78,23 @@ public class SessionsTableCreator {
|
||||
}
|
||||
return new String[]{sessionTableBuilder.toString(), recentLoginsBuilder.toString()};
|
||||
}
|
||||
|
||||
private static String getLongestWorldPlayed(Session session) {
|
||||
WorldTimes worldTimes = session.getWorldTimes();
|
||||
long total = worldTimes.getTotal();
|
||||
long longest = 0;
|
||||
String theWorld = "-";
|
||||
for (Map.Entry<String, GMTimes> entry : worldTimes.getWorldTimes().entrySet()) {
|
||||
String world = entry.getKey();
|
||||
long time = entry.getValue().getTotal();
|
||||
if (time > longest) {
|
||||
longest = time;
|
||||
theWorld = world;
|
||||
}
|
||||
}
|
||||
|
||||
double percentage = longest * 1.0 / total;
|
||||
|
||||
return theWorld + " (" + FormatUtils.cutDecimals(percentage) + "%)";
|
||||
}
|
||||
}
|
@ -53,7 +53,7 @@
|
||||
</a>
|
||||
</div>
|
||||
<div id="limiter" class="main-limiter">
|
||||
<div id="main" class="main-wrapper">
|
||||
<div id="main" class="main-wrapper" style="width: 800%;">
|
||||
<div id="tab-information" class="tab">
|
||||
<div class="row">
|
||||
<div class="column">
|
||||
|
@ -54,7 +54,7 @@ public class GraphTest {
|
||||
assertEquals("[[0,0.0],[9,9.0]]", WorldLoadGraphCreator.buildSeriesDataStringChunks(tpsList));
|
||||
assertEquals("[[0,0.0],[9,9.0]]", WorldLoadGraphCreator.buildSeriesDataStringEntities(tpsList));
|
||||
assertEquals("[{'code':'1','value':1},{'code':'2','value':2},{'code':'3','value':3},{'code':'4','value':4},{'code':'5','value':5},{'code':'6','value':6},{'code':'7','value':7},{'code':'8','value':8},{'code':'9','value':9}]", WorldMapCreator.createDataSeries(geoList));
|
||||
assertEquals("[[{name:'WORLD',y:0,drilldown: 'WORLD'}], {name:'WORLD', id:'WORLD',data: []}]", Arrays.toString(WorldPieCreator.createSeriesData(worldTimes)));
|
||||
assertEquals("[[{name:'WORLD',y:0,drilldown: 'WORLD'}], [{name:'WORLD', id:'WORLD',data: []}]]", Arrays.toString(WorldPieCreator.createSeriesData(worldTimes)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user