Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support searching LegacyID for PRs and INQs #1706

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('InquiryAdvancedSearchService', () => {
sortField: 'applicant',
sortDirection: 'ASC',
portalStatusCodes: [],
legacyId: 'legacyId',
};

let mockQuery: any = {};
Expand Down Expand Up @@ -112,7 +113,7 @@ describe('InquiryAdvancedSearchService', () => {
const result = await service.search(mockSearchDto, mockQueryRunner);

expect(result).toEqual({ data: [], total: 0 });
expect(mockInquiryRepository.find).toHaveBeenCalledTimes(3);
expect(mockInquiryRepository.find).toHaveBeenCalledTimes(4);
expect(mockInquiryRepository.createQueryBuilder).toHaveBeenCalledTimes(4);
expect(mockQuery.andWhere).toHaveBeenCalledTimes(4);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ export class InquiryAdvancedSearchService {
this.addFileTypeResults(searchDto, promises);
}

if (searchDto.legacyId) {
this.addLegacyIDResults(searchDto, promises);
}

const t0 = performance.now();
const finalResult = await processSearchPromises(promises);
const t1 = performance.now();
Expand Down Expand Up @@ -295,4 +299,19 @@ export class InquiryAdvancedSearchService {
}
promises.push(query.getMany());
}

private addLegacyIDResults(
searchDto: SearchRequestDto,
promises: Promise<{ fileNumber: string }[]>[],
) {
const promise = this.inquiryRepository.find({
where: {
legacyId: searchDto.legacyId,
},
select: {
fileNumber: true,
},
});
promises.push(promise);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('PlanningReviewAdvancedSearchService', () => {
pageSize: 10,
sortField: 'ownerName',
sortDirection: 'ASC',
legacyId: 'legacyId',
};

let mockQuery: any = {};
Expand Down Expand Up @@ -107,7 +108,7 @@ describe('PlanningReviewAdvancedSearchService', () => {
const result = await service.search(mockSearchDto, mockQueryRunner);

expect(result).toEqual({ data: [], total: 0 });
expect(mockPlanningReviewRepository.find).toHaveBeenCalledTimes(3);
expect(mockPlanningReviewRepository.find).toHaveBeenCalledTimes(4);
expect(
mockPlanningReviewRepository.createQueryBuilder,
).toHaveBeenCalledTimes(5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ export class PlanningReviewAdvancedSearchService {
this.addDecisionDateResults(searchDto, promises);
}

if (searchDto.legacyId) {
this.addLegacyIDResults(searchDto, promises);
}

const t0 = performance.now();
const finalResult = await processSearchPromises(promises);
const t1 = performance.now();
Expand Down Expand Up @@ -322,4 +326,19 @@ export class PlanningReviewAdvancedSearchService {
}
promises.push(query.getMany());
}

private addLegacyIDResults(
searchDto: SearchRequestDto,
promises: Promise<{ fileNumber: string }[]>[],
) {
const promise = this.planningReviewRepository.find({
where: {
legacyId: searchDto.legacyId,
},
select: {
fileNumber: true,
},
});
promises.push(promise);
}
}
3 changes: 1 addition & 2 deletions services/apps/alcs/src/alcs/search/search.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,7 @@ export class SearchController {
!searchDto.dateDecidedTo &&
!searchDto.resolutionNumber &&
!searchDto.resolutionYear &&
searchDto.portalStatusCodes.length === 0 &&
!isStringSetAndNotEmpty(searchDto.legacyId);
searchDto.portalStatusCodes.length === 0;

return {
searchApplications,
Expand Down