diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/model/dto/SnapshotResponse.java b/api/src/main/java/ca/bc/gov/educ/api/trax/model/dto/SnapshotResponse.java index 44864bd4..658be50a 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/trax/model/dto/SnapshotResponse.java +++ b/api/src/main/java/ca/bc/gov/educ/api/trax/model/dto/SnapshotResponse.java @@ -13,12 +13,14 @@ public class SnapshotResponse { private BigDecimal gpa; private String honourFlag; private String schoolOfRecord; + private String studentGrade; - public SnapshotResponse(String pen, String graduatedDate, BigDecimal gpa, String honourFlag, String schoolOfRecord) { + public SnapshotResponse(String pen, String graduatedDate, BigDecimal gpa, String honourFlag, String schoolOfRecord, String studentGrade) { this.pen = pen; this.graduatedDate = graduatedDate; this.gpa = gpa; this.honourFlag = honourFlag; this.schoolOfRecord = schoolOfRecord; + this.studentGrade = studentGrade; } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/trax/repository/SnapshotRepository.java b/api/src/main/java/ca/bc/gov/educ/api/trax/repository/SnapshotRepository.java index 2b6cbfbe..a819197f 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/trax/repository/SnapshotRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/api/trax/repository/SnapshotRepository.java @@ -15,19 +15,17 @@ @Repository public interface SnapshotRepository extends JpaRepository { - @Query(value="select s.mincode as schoolOfRecord from (\n" + - " select mincode, count(*) from SNAPSHOT\n" + - " where grad_year = :gradYear\n" + - " group by mincode\n" + - " order by 2 desc ) s", nativeQuery=true) + @Query(value="select distinct trim(s.mincode) as schoolOfRecord\n" + + "from snapshot s\n" + + "where s.grad_year = :gradYear", nativeQuery=true) List getSchools(@Param("gradYear") Integer gradYear); - @Query(value="select new ca.bc.gov.educ.api.trax.model.dto.SnapshotResponse(trim(s.pen), trim(s.graduatedDate), s.gpa, trim(s.honourFlag), trim(s.schoolOfRecord))\n" + + @Query(value="select new ca.bc.gov.educ.api.trax.model.dto.SnapshotResponse(trim(s.pen), trim(s.graduatedDate), s.gpa, trim(s.honourFlag), trim(s.schoolOfRecord), trim(s.studGrade))\n" + "from SnapshotEntity s\n" + "where s.gradYear = :gradYear") List getStudentsByGradYear(@Param("gradYear") Integer gradYear); - @Query(value="select new ca.bc.gov.educ.api.trax.model.dto.SnapshotResponse(trim(s.pen), trim(s.graduatedDate), s.gpa, trim(s.honourFlag), trim(s.schoolOfRecord))\n" + + @Query(value="select new ca.bc.gov.educ.api.trax.model.dto.SnapshotResponse(trim(s.pen), trim(s.graduatedDate), s.gpa, trim(s.honourFlag), trim(s.schoolOfRecord), trim(s.studGrade))\n" + "from SnapshotEntity s\n" + "where s.gradYear = :gradYear\n" + "and s.schoolOfRecord = :schoolOfRecord")