Skip to content

Commit

Permalink
Merge pull request #1709 from bcgov/feature/ALCS-959
Browse files Browse the repository at this point in the history
Add sorting to lots of queries
  • Loading branch information
dhaselhan authored May 27, 2024
2 parents 4ead5bb + 60b2bd9 commit 6d8f332
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 23 deletions.
14 changes: 12 additions & 2 deletions services/apps/alcs/src/alcs/card/card.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CONFIG_TOKEN } from '@app/common/config/config.module';
import { ServiceValidationException } from '@app/common/exceptions/base.exception';
import { Mapper } from 'automapper-core';
import { InjectMapper } from 'automapper-nestjs';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Mapper } from 'automapper-core';
import { InjectMapper } from 'automapper-nestjs';
import { IConfig } from 'config';
import { FindOptionsRelations, Not, Repository } from 'typeorm';
import { User } from '../../user/user.entity';
Expand Down Expand Up @@ -66,6 +66,11 @@ export class CardService {
assignee: true,
},
},
order: {
subtasks: {
createdAt: 'ASC',
},
},
});
}

Expand All @@ -80,6 +85,11 @@ export class CardService {
assignee: true,
},
},
order: {
subtasks: {
createdAt: 'ASC',
},
},
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ describe('ApplicationParcelService', () => {
isDraft: false,
},
},
order: { auditCreatedAt: 'ASC' },
order: {
auditCreatedAt: 'ASC',
owners: {
firstName: 'ASC',
},
},
relations: {
certificateOfTitle: { document: true },
owners: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export class ApplicationParcelService {
async fetchByApplicationFileId(fileId: string) {
return this.parcelRepository.find({
where: { applicationSubmission: { fileNumber: fileId, isDraft: false } },
order: { auditCreatedAt: 'ASC' },
order: {
auditCreatedAt: 'ASC',
owners: {
firstName: 'ASC',
},
},
relations: {
ownershipType: true,
certificateOfTitle: { document: true },
Expand All @@ -38,7 +43,12 @@ export class ApplicationParcelService {
async fetchByApplicationSubmissionUuid(uuid: string) {
return this.parcelRepository.find({
where: { applicationSubmission: { uuid } },
order: { auditCreatedAt: 'ASC' },
order: {
auditCreatedAt: 'ASC',
owners: {
firstName: 'ASC',
},
},
relations: {
ownershipType: true,
certificateOfTitle: { document: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ export class ApplicationSubmissionService {
order: {
auditUpdatedAt: 'DESC',
owners: {
firstName: 'ASC',
parcels: {
purchasedDate: 'ASC',
},
Expand Down Expand Up @@ -478,6 +479,7 @@ export class ApplicationSubmissionService {
order: {
auditUpdatedAt: 'DESC',
owners: {
firstName: 'ASC',
parcels: {
purchasedDate: 'ASC',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { forwardRef, Inject, Injectable } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Any, Repository } from 'typeorm';
import { OwnerType } from '../../../common/owner-type/owner-type.entity';
import { User } from '../../../user/user.entity';
import { ApplicationSubmission } from '../application-submission.entity';
import { ApplicationSubmissionService } from '../application-submission.service';
import {
CovenantTransfereeCreateDto,
CovenantTransfereeUpdateDto,
Expand All @@ -18,8 +17,6 @@ export class CovenantTransfereeService {
private repository: Repository<CovenantTransferee>,
@InjectRepository(OwnerType)
private typeRepository: Repository<OwnerType>,
@Inject(forwardRef(() => ApplicationSubmissionService))
private applicationSubmissionService: ApplicationSubmissionService,
) {}

async fetchBySubmissionUuid(uuid: string) {
Expand All @@ -30,6 +27,9 @@ export class CovenantTransfereeService {
relations: {
type: true,
},
order: {
firstName: 'ASC',
},
});
}

Expand All @@ -41,6 +41,9 @@ export class CovenantTransfereeService {
isDraft: false,
},
},
order: {
firstName: 'ASC',
},
relations: {
type: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ describe('NoticeOfIntentParcelService', () => {
isDraft: false,
},
},
order: { auditCreatedAt: 'ASC' },
order: {
auditCreatedAt: 'ASC',
owners: {
firstName: 'ASC',
},
},
relations: {
certificateOfTitle: { document: true },
owners: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export class NoticeOfIntentParcelService {
where: {
noticeOfIntentSubmission: { fileNumber: fileId, isDraft: false },
},
order: { auditCreatedAt: 'ASC' },
order: {
auditCreatedAt: 'ASC',
owners: {
firstName: 'ASC',
},
},
relations: {
ownershipType: true,
certificateOfTitle: { document: true },
Expand All @@ -41,7 +46,12 @@ export class NoticeOfIntentParcelService {
async fetchByApplicationSubmissionUuid(uuid: string) {
return this.parcelRepository.find({
where: { noticeOfIntentSubmission: { uuid } },
order: { auditCreatedAt: 'ASC' },
order: {
auditCreatedAt: 'ASC',
owners: {
firstName: 'ASC',
},
},
relations: {
ownershipType: true,
certificateOfTitle: { document: true },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BaseServiceException } from '@app/common/exceptions/base.exception';
import { Mapper } from 'automapper-core';
import { InjectMapper } from 'automapper-nestjs';
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Mapper } from 'automapper-core';
import { InjectMapper } from 'automapper-nestjs';
import * as dayjs from 'dayjs';
import {
FindOptionsRelations,
Expand Down Expand Up @@ -69,6 +69,11 @@ export class NotificationSubmissionService {
fileNumber,
},
relations: this.DEFAULT_RELATIONS,
order: {
transferees: {
firstName: 'ASC',
},
},
});
}

Expand Down Expand Up @@ -212,6 +217,9 @@ export class NotificationSubmissionService {
where: whereClauses,
order: {
auditUpdatedAt: 'DESC',
transferees: {
firstName: 'ASC',
},
},
relations: this.DEFAULT_RELATIONS,
});
Expand All @@ -226,6 +234,11 @@ export class NotificationSubmissionService {
where: {
uuid,
},
order: {
transferees: {
firstName: 'ASC',
},
},
relations: {
...this.DEFAULT_RELATIONS,
},
Expand All @@ -245,6 +258,9 @@ export class NotificationSubmissionService {
...this.DEFAULT_RELATIONS,
},
order: {
transferees: {
firstName: 'ASC',
},
auditUpdatedAt: 'DESC',
},
});
Expand Down Expand Up @@ -393,15 +409,6 @@ export class NotificationSubmissionService {
);
}

private loadBarebonesSubmission(uuid: string) {
//Load submission without relations to prevent save from crazy cascading
return this.notificationSubmissionRepository.findOneOrFail({
where: {
uuid,
},
});
}

async sendAndRecordLTSAPackage(
submission: NotificationSubmission,
document: NotificationDocument,
Expand Down

0 comments on commit 6d8f332

Please sign in to comment.