Skip to content

Commit

Permalink
Merge pull request #292 from bcgov/feature/GRAD2-2325
Browse files Browse the repository at this point in the history
GRAD2-2325: mincode is added in the payload of snapshot DTO.
  • Loading branch information
infstar authored Oct 18, 2023
2 parents 1f6461c + 28dc682 commit 959d8bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ public class SnapshotResponse {
private String graduatedDate; // yyyyMM
private BigDecimal gpa;
private String honourFlag;
private String schoolOfRecord;

public SnapshotResponse(String pen, String graduatedDate, BigDecimal gpa, String honourFlag) {
public SnapshotResponse(String pen, String graduatedDate, BigDecimal gpa, String honourFlag, String schoolOfRecord) {
this.pen = pen;
this.graduatedDate = graduatedDate;
this.gpa = gpa;
this.honourFlag = honourFlag;
this.schoolOfRecord = schoolOfRecord;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
@Repository
public interface SnapshotRepository extends JpaRepository<SnapshotEntity, SnapshotID> {

@Query(value="select distinct trim(s.mincode) as schoolOfRecord\n" +
"from snapshot s\n" +
"where s.grad_year = :gradYear", nativeQuery=true)
@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)
List<String> 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))\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))\n" +
"from SnapshotEntity s\n" +
"where s.gradYear = :gradYear")
List<SnapshotResponse> 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))\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))\n" +
"from SnapshotEntity s\n" +
"where s.gradYear = :gradYear\n" +
"and s.schoolOfRecord = :schoolOfRecord")
Expand Down

0 comments on commit 959d8bb

Please sign in to comment.