mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-09 09:57:35 +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);
|
return graphJSON.performanceGraphJSON(serverUUID);
|
||||||
case "uniqueAndNew":
|
case "uniqueAndNew":
|
||||||
return graphJSON.uniqueAndNewGraphJSON(serverUUID);
|
return graphJSON.uniqueAndNewGraphJSON(serverUUID);
|
||||||
|
case "serverCalendar":
|
||||||
|
return graphJSON.serverCalendarJSON(serverUUID);
|
||||||
default:
|
default:
|
||||||
throw new BadRequestException("unknown 'type' parameter: " + type);
|
throw new BadRequestException("unknown 'type' parameter: " + type);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class ServerCalendar {
|
|||||||
public String toCalendarSeries() {
|
public String toCalendarSeries() {
|
||||||
StringBuilder series = new StringBuilder("[");
|
StringBuilder series = new StringBuilder("[");
|
||||||
|
|
||||||
series.append("{title: 'badcode',start:0}");
|
series.append("{\"title\": \"badcode\",\"start\":0}");
|
||||||
appendSessionRelatedData(series);
|
appendSessionRelatedData(series);
|
||||||
appendRegistered(series);
|
appendRegistered(series);
|
||||||
|
|
||||||
@ -78,9 +78,9 @@ public class ServerCalendar {
|
|||||||
|
|
||||||
String day = entry.getKey();
|
String day = entry.getKey();
|
||||||
|
|
||||||
series.append(",{title: 'New: ").append(newPlayers)
|
series.append(",{\"title\": \"New: ").append(newPlayers)
|
||||||
.append("',start:'").append(day)
|
.append("\",\"start\":\"").append(day)
|
||||||
.append("',color: '").append(theme.getValue(ThemeVal.LIGHT_GREEN)).append("'")
|
.append("\",\"color\": \"").append(theme.getValue(ThemeVal.LIGHT_GREEN)).append('"')
|
||||||
.append("}");
|
.append("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,19 +106,19 @@ public class ServerCalendar {
|
|||||||
long playtime = dayMutator.toPlaytime();
|
long playtime = dayMutator.toPlaytime();
|
||||||
long uniquePlayers = entry.getValue();
|
long uniquePlayers = entry.getValue();
|
||||||
|
|
||||||
series.append(",{title: 'Playtime: ").append(timeAmountFormatter.apply(playtime))
|
series.append(",{\"title\": \"Playtime: ").append(timeAmountFormatter.apply(playtime))
|
||||||
.append("',start:'").append(day)
|
.append("\",\"start\":\"").append(day)
|
||||||
.append("',color: '").append(theme.getValue(ThemeVal.GREEN)).append("'")
|
.append("\",\"color\": \"").append(theme.getValue(ThemeVal.GREEN)).append('"')
|
||||||
.append("}");
|
.append("}");
|
||||||
|
|
||||||
series.append(",{title: 'Sessions: ").append(sessionCount)
|
series.append(",{\"title\": \"Sessions: ").append(sessionCount)
|
||||||
.append("',start:'").append(day)
|
.append("\",\"start\":\"").append(day)
|
||||||
.append("',color: '").append(theme.getValue(ThemeVal.TEAL)).append("'")
|
.append("\",\"color\": \"").append(theme.getValue(ThemeVal.TEAL)).append('"')
|
||||||
.append("}");
|
.append("}");
|
||||||
|
|
||||||
series.append(",{title: 'Unique: ").append(uniquePlayers)
|
series.append(",{\"title\": \"Unique: ").append(uniquePlayers)
|
||||||
.append("',start:'").append(day)
|
.append("\",\"start\":\"").append(day)
|
||||||
.append("'}");
|
.append("\"}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user