mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-14 12:11:23 +01:00
Extract method in FiltersJSONResolver#getResponse
This commit is contained in:
parent
ae416cc49f
commit
bf835c3b2e
@ -80,26 +80,28 @@ public class FiltersJSONResolver implements Resolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Response getResponse() {
|
private Response getResponse() {
|
||||||
List<DateObj<Integer>> data = dbSystem.getDatabase().query(TPSQueries.fetchViewPreviewGraphData(serverInfo.getServerUUID()));
|
|
||||||
Long earliestStart = dbSystem.getDatabase().query(SessionQueries.earliestSessionStart());
|
|
||||||
data.add(0, new DateObj<>(earliestStart, 1));
|
|
||||||
|
|
||||||
boolean displayGaps = true;
|
|
||||||
List<Double[]> viewPoints = graphs.line().lineGraph(Lists.map(data, Point::fromDateObj), displayGaps).getPoints()
|
|
||||||
.stream().map(point -> {
|
|
||||||
if (point.getY() == null) point.setY(0.0);
|
|
||||||
return point.toArray();
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
return Response.builder()
|
return Response.builder()
|
||||||
.setMimeType(MimeType.JSON)
|
.setMimeType(MimeType.JSON)
|
||||||
.setJSONContent(new FilterResponseJSON(
|
.setJSONContent(new FilterResponseJSON(
|
||||||
filters.getFilters(),
|
filters.getFilters(),
|
||||||
new ViewJSON(formatters),
|
new ViewJSON(formatters),
|
||||||
viewPoints
|
fetchViewGraphPoints()
|
||||||
)).build();
|
)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Double[]> fetchViewGraphPoints() {
|
||||||
|
List<DateObj<Integer>> data = dbSystem.getDatabase().query(TPSQueries.fetchViewPreviewGraphData(serverInfo.getServerUUID()));
|
||||||
|
Long earliestStart = dbSystem.getDatabase().query(SessionQueries.earliestSessionStart());
|
||||||
|
data.add(0, new DateObj<>(earliestStart, 1));
|
||||||
|
|
||||||
|
boolean displayGaps = true;
|
||||||
|
return graphs.line().lineGraph(Lists.map(data, Point::fromDateObj), displayGaps).getPoints()
|
||||||
|
.stream().map(point -> {
|
||||||
|
if (point.getY() == null) point.setY(0.0);
|
||||||
|
return point.toArray();
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON serialization class.
|
* JSON serialization class.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user