diff --git a/backend/src/main/java/uk/co/neviyn/Observations/resources/ObservationResource.java b/backend/src/main/java/uk/co/neviyn/Observations/resources/ObservationResource.java index ae096bf..88a50bb 100644 --- a/backend/src/main/java/uk/co/neviyn/Observations/resources/ObservationResource.java +++ b/backend/src/main/java/uk/co/neviyn/Observations/resources/ObservationResource.java @@ -1,19 +1,5 @@ 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 lombok.RequiredArgsConstructor; 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.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 @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -77,6 +71,17 @@ public class ObservationResource { @Path("/average/all/chartjs") @GET public AverageStatsChartJs averageStatsChartJs(){ - return new AverageStatsChartJs(dao.averageStatsForAll()); + return new AverageStatsChartJs(averageObservationScores()); + } + + @Path("/average/{id}") + public List 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)); } }