Skip to content

Commit

Permalink
#3981 - Model SDPR API - Query improvement (#4040)
Browse files Browse the repository at this point in the history
- Added conditions to query only applications with an applicationNumber;
- Added order clause,
  • Loading branch information
andrepestana-aot authored Dec 6, 2024
1 parent 37f57e7 commit ba003cf
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
CASSupplier,
SupplierStatus,
} from "@sims/sims-db";
import { DataSource, EntityManager, UpdateResult } from "typeorm";
import { DataSource, EntityManager, IsNull, Not, UpdateResult } from "typeorm";
import { LoggerService, InjectLogger } from "@sims/utilities/logger";
import { removeWhiteSpaces, transformAddressDetails } from "../../utilities";
import { CustomNamedError } from "@sims/utilities";
Expand Down Expand Up @@ -882,6 +882,8 @@ export class StudentService extends RecordDataModelService<Student> {

/**
* Gets student by SIN.
* The current assessment id should not be null to ensure the application has an application number and
* application status should be not `Overwritten` to ensure distinct application numbers.
* @param sin student's SIN.
* @returns student.
*/
Expand All @@ -900,7 +902,18 @@ export class StudentService extends RecordDataModelService<Student> {
user: true,
applications: true,
},
where: { sinValidation: { sin } },
where: {
sinValidation: { sin },
applications: {
currentAssessment: { id: Not(IsNull()) },
applicationStatus: Not(ApplicationStatus.Overwritten),
},
},
order: {
applications: {
id: "DESC",
},
},
loadEagerRelations: false,
});
}
Expand Down

0 comments on commit ba003cf

Please sign in to comment.