Skip to content

Commit

Permalink
Support searching LegacyID for PRs and INQs
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Haselhan committed May 22, 2024
1 parent 2a74e1a commit 3e85693
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 4 deletions.
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

0 comments on commit 3e85693

Please sign in to comment.