From f987366563279262df5c468e7c8f8713883b98eb Mon Sep 17 00:00:00 2001 From: Jinil Sung Date: Fri, 20 Oct 2023 11:52:54 -0700 Subject: [PATCH] GRAD2-2325: Changes to add a studentGrade field in snapshot response. GRAD2-2325: Changes to add a studentGrade field in snapshot response. --- .../educ/api/trax/model/dto/SnapshotResponse.java | 4 +++- .../educ/api/trax/repository/SnapshotRepository.java | 12 +++++------- 2 files changed, 8 insertions(+), 8 deletions(-) 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")