Added average stats per site endpoint.
This commit is contained in:
parent
b4c6773713
commit
294bf679a6
@ -1,19 +1,5 @@
|
|||||||
package uk.co.neviyn.Observations.resources;
|
package uk.co.neviyn.Observations.resources;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import javax.ws.rs.Consumes;
|
|
||||||
import javax.ws.rs.GET;
|
|
||||||
import javax.ws.rs.POST;
|
|
||||||
import javax.ws.rs.Path;
|
|
||||||
import javax.ws.rs.PathParam;
|
|
||||||
import javax.ws.rs.Produces;
|
|
||||||
import javax.ws.rs.core.MediaType;
|
|
||||||
|
|
||||||
import io.dropwizard.hibernate.UnitOfWork;
|
import io.dropwizard.hibernate.UnitOfWork;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -30,6 +16,14 @@ import uk.co.neviyn.Observations.dao.ObservationDao;
|
|||||||
import uk.co.neviyn.Observations.dao.SiteDao;
|
import uk.co.neviyn.Observations.dao.SiteDao;
|
||||||
import uk.co.neviyn.Observations.dao.TutorDao;
|
import uk.co.neviyn.Observations.dao.TutorDao;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ -77,6 +71,17 @@ public class ObservationResource {
|
|||||||
@Path("/average/all/chartjs")
|
@Path("/average/all/chartjs")
|
||||||
@GET
|
@GET
|
||||||
public AverageStatsChartJs averageStatsChartJs(){
|
public AverageStatsChartJs averageStatsChartJs(){
|
||||||
return new AverageStatsChartJs(dao.averageStatsForAll());
|
return new AverageStatsChartJs(averageObservationScores());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Path("/average/{id}")
|
||||||
|
public List<AverageStats> averageObservationScoresForSite(@PathParam("id") long siteId) {
|
||||||
|
Site site = siteDao.get(siteId);
|
||||||
|
return dao.averageStatsForSite(site);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Path("/average/{id}/chartjs")
|
||||||
|
public AverageStatsChartJs averageObservationScoresForSiteChartJs(@PathParam("id") long siteId) {
|
||||||
|
return new AverageStatsChartJs(averageObservationScoresForSite(siteId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user