mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-03 01:10:17 +01:00
Server calendar end point
This commit is contained in:
parent
05a8668fbf
commit
da3e5db913
@ -74,4 +74,19 @@ public class GraphJSONParser {
|
||||
'}';
|
||||
}
|
||||
|
||||
public String serverCalendarJSON(UUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
SessionsMutator sessionsMutator = new SessionsMutator(db.query(SessionQueries.fetchSessionsOfServerFlat(serverUUID)))
|
||||
.filterSessionsBetween(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(730L), System.currentTimeMillis());
|
||||
PlayersMutator playersMutator = new PlayersMutator(db.query(new ServerPlayerContainersQuery(serverUUID)))
|
||||
.filterRegisteredBetween(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(730L), System.currentTimeMillis());
|
||||
|
||||
return "{\"data\":" +
|
||||
graphs.calendar().serverCalendar(
|
||||
playersMutator,
|
||||
sessionsMutator.uniqueJoinsPerDay(timeZone),
|
||||
playersMutator.newPerDay(timeZone)
|
||||
).toCalendarSeries() +
|
||||
",\"firstDay\":" + 1 + '}';
|
||||
}
|
||||
}
|
@ -65,6 +65,8 @@ public class GraphsJSONHandler extends ServerParameterJSONHandler {
|
||||
return graphJSON.performanceGraphJSON(serverUUID);
|
||||
case "uniqueAndNew":
|
||||
return graphJSON.uniqueAndNewGraphJSON(serverUUID);
|
||||
case "serverCalendar":
|
||||
return graphJSON.serverCalendarJSON(serverUUID);
|
||||
default:
|
||||
throw new BadRequestException("unknown 'type' parameter: " + type);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class ServerCalendar {
|
||||
public String toCalendarSeries() {
|
||||
StringBuilder series = new StringBuilder("[");
|
||||
|
||||
series.append("{title: 'badcode',start:0}");
|
||||
series.append("{\"title\": \"badcode\",\"start\":0}");
|
||||
appendSessionRelatedData(series);
|
||||
appendRegistered(series);
|
||||
|
||||
@ -78,9 +78,9 @@ public class ServerCalendar {
|
||||
|
||||
String day = entry.getKey();
|
||||
|
||||
series.append(",{title: 'New: ").append(newPlayers)
|
||||
.append("',start:'").append(day)
|
||||
.append("',color: '").append(theme.getValue(ThemeVal.LIGHT_GREEN)).append("'")
|
||||
series.append(",{\"title\": \"New: ").append(newPlayers)
|
||||
.append("\",\"start\":\"").append(day)
|
||||
.append("\",\"color\": \"").append(theme.getValue(ThemeVal.LIGHT_GREEN)).append('"')
|
||||
.append("}");
|
||||
}
|
||||
|
||||
@ -106,19 +106,19 @@ public class ServerCalendar {
|
||||
long playtime = dayMutator.toPlaytime();
|
||||
long uniquePlayers = entry.getValue();
|
||||
|
||||
series.append(",{title: 'Playtime: ").append(timeAmountFormatter.apply(playtime))
|
||||
.append("',start:'").append(day)
|
||||
.append("',color: '").append(theme.getValue(ThemeVal.GREEN)).append("'")
|
||||
series.append(",{\"title\": \"Playtime: ").append(timeAmountFormatter.apply(playtime))
|
||||
.append("\",\"start\":\"").append(day)
|
||||
.append("\",\"color\": \"").append(theme.getValue(ThemeVal.GREEN)).append('"')
|
||||
.append("}");
|
||||
|
||||
series.append(",{title: 'Sessions: ").append(sessionCount)
|
||||
.append("',start:'").append(day)
|
||||
.append("',color: '").append(theme.getValue(ThemeVal.TEAL)).append("'")
|
||||
series.append(",{\"title\": \"Sessions: ").append(sessionCount)
|
||||
.append("\",\"start\":\"").append(day)
|
||||
.append("\",\"color\": \"").append(theme.getValue(ThemeVal.TEAL)).append('"')
|
||||
.append("}");
|
||||
|
||||
series.append(",{title: 'Unique: ").append(uniquePlayers)
|
||||
.append("',start:'").append(day)
|
||||
.append("'}");
|
||||
series.append(",{\"title\": \"Unique: ").append(uniquePlayers)
|
||||
.append("\",\"start\":\"").append(day)
|
||||
.append("\"}");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user