Skip to content

Commit 4ad99e6

Browse files
authored
Merge pull request #2140 from bcgov/hotfix/ALCS-2560-fix-modi-recon-pills
ALCS-2560 Change the search to APP/NOI File number
2 parents fecb6f8 + ee70e11 commit 4ad99e6

File tree

4 files changed

+56
-39
lines changed

4 files changed

+56
-39
lines changed

services/apps/alcs/src/alcs/application-decision/application-decision-condition/application-decision-condition.service.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable } from '@nestjs/common';
22
import { InjectRepository } from '@nestjs/typeorm';
3-
import { FindOptionsWhere, In, IsNull, Repository } from 'typeorm';
3+
import { FindOptionsRelations, FindOptionsWhere, In, IsNull, Repository } from 'typeorm';
44
import { ServiceValidationException } from '../../../../../../libs/common/src/exceptions/base.exception';
55
import { ApplicationDecisionConditionToComponentLot } from '../application-condition-to-component-lot/application-decision-condition-to-component-lot.entity';
66
import { ApplicationDecisionConditionComponentPlanNumber } from '../application-decision-component-to-condition/application-decision-component-to-condition-plan-number.entity';
@@ -32,6 +32,15 @@ export class ApplicationDecisionConditionService {
3232
assignee: true,
3333
};
3434

35+
private DEFAULT_APP_RELATIONS: FindOptionsRelations<ApplicationModification> = {
36+
application: {
37+
type: true,
38+
region: true,
39+
localGovernment: true,
40+
decisionMeetings: true,
41+
},
42+
};
43+
3544
constructor(
3645
@InjectRepository(ApplicationDecisionCondition)
3746
private repository: Repository<ApplicationDecisionCondition>,
@@ -109,19 +118,15 @@ export class ApplicationDecisionConditionService {
109118
const condition = this.mapper.map(c, ApplicationDecisionCondition, ApplicationDecisionConditionHomeDto);
110119
const decision = this.mapper.map(c.decision, ApplicationDecision, ApplicationDecisionHomeDto);
111120
const application = this.mapper.map(c.decision.application, Application, ApplicationHomeDto);
121+
112122
const appModifications = await this.modificationRepository.find({
113-
where: {
114-
modifiesDecisions: {
115-
uuid: c.decision?.uuid,
116-
},
117-
},
123+
where: { application: { fileNumber: condition?.decision?.application.fileNumber } },
124+
relations: this.DEFAULT_APP_RELATIONS,
118125
});
126+
119127
const appReconsiderations = await this.reconsiderationRepository.find({
120-
where: {
121-
reconsidersDecisions: {
122-
uuid: c.decision?.uuid,
123-
},
124-
},
128+
where: { application: { fileNumber: condition?.decision?.application.fileNumber } },
129+
relations: this.DEFAULT_APP_RELATIONS,
125130
});
126131

127132
return {

services/apps/alcs/src/alcs/home/home.controller.ts

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ApiOAuth2 } from '@nestjs/swagger';
33
import { Mapper } from 'automapper-core';
44
import { InjectMapper } from 'automapper-nestjs';
55
import * as config from 'config';
6-
import { In, Not, Repository } from 'typeorm';
6+
import { FindOptionsRelations, In, Not, Repository } from 'typeorm';
77
import { ANY_AUTH_ROLE } from '../../common/authorization/roles';
88
import { RolesGuard } from '../../common/authorization/roles-guard.service';
99
import { UserRoles } from '../../common/authorization/roles.decorator';
@@ -49,6 +49,22 @@ import { InjectRepository } from '@nestjs/typeorm';
4949

5050
const HIDDEN_CARD_STATUSES = [CARD_STATUS.CANCELLED, CARD_STATUS.DECISION_RELEASED];
5151

52+
const DEFAULT_APP_RELATIONS: FindOptionsRelations<ApplicationModification> = {
53+
application: {
54+
type: true,
55+
region: true,
56+
localGovernment: true,
57+
decisionMeetings: true,
58+
},
59+
};
60+
61+
const DEFAULT_NOI_RELATIONS: FindOptionsRelations<NoticeOfIntentModification> = {
62+
noticeOfIntent: {
63+
region: true,
64+
localGovernment: true,
65+
},
66+
};
67+
5268
@ApiOAuth2(config.get<string[]>('KEYCLOAK.SCOPES'))
5369
@Controller('home')
5470
@UseGuards(RolesGuard)
@@ -308,20 +324,17 @@ export class HomeController {
308324
if (!condition.conditionCard?.card) {
309325
continue;
310326
}
327+
311328
const appModifications = await this.modificationApplicationRepository.find({
312-
where: {
313-
modifiesDecisions: {
314-
uuid: condition.decision?.uuid,
315-
},
316-
},
329+
where: { application: { fileNumber: condition.decision.application.fileNumber } },
330+
relations: DEFAULT_APP_RELATIONS,
317331
});
332+
318333
const appReconsiderations = await this.reconsiderationApplicationRepository.find({
319-
where: {
320-
reconsidersDecisions: {
321-
uuid: condition.decision?.uuid,
322-
},
323-
},
334+
where: { application: { fileNumber: condition.decision.application.fileNumber } },
335+
relations: DEFAULT_APP_RELATIONS,
324336
});
337+
325338
for (const subtask of condition.conditionCard?.card?.subtasks) {
326339
result.push({
327340
isCondition: true,
@@ -349,9 +362,6 @@ export class HomeController {
349362
}
350363

351364
private async mapNoticeOfIntentConditionsToDtos(noticeOfIntestConditions: NoticeOfIntentDecisionCondition[]) {
352-
const noticeOfIntents = noticeOfIntestConditions.map((c) => c.decision.noticeOfIntent);
353-
const uuids = noticeOfIntents.map((noi) => noi.uuid);
354-
const timeMap = await this.noticeOfIntentService.getTimes(uuids);
355365
const holidays = await this.holidayService.fetchAllHolidays();
356366
const result: HomepageSubtaskDTO[] = [];
357367

@@ -371,11 +381,8 @@ export class HomeController {
371381
continue;
372382
}
373383
const noiModifications = await this.modificationNoticeOfIntentRepository.find({
374-
where: {
375-
modifiesDecisions: {
376-
uuid: condition.decision?.uuid,
377-
},
378-
},
384+
where: { noticeOfIntent: { fileNumber: condition.decision.noticeOfIntent.fileNumber } },
385+
relations: DEFAULT_NOI_RELATIONS,
379386
});
380387
for (const subtask of condition.conditionCard?.card?.subtasks) {
381388
result.push({

services/apps/alcs/src/alcs/notice-of-intent-decision/notice-of-intent-decision-condition/notice-of-intent-decision-condition.dto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class NoticeOfIntentHomeDto {
116116
@AutoMap(() => NoticeOfIntentTypeDto)
117117
type: NoticeOfIntentTypeDto;
118118

119-
activeDays: number;
119+
activeDays?: number;
120120
paused: boolean;
121121
pausedDays: number;
122122
}
@@ -126,7 +126,7 @@ export class NoticeOfIntentDecisionHomeDto {
126126
uuid: string;
127127

128128
@AutoMap()
129-
application: NoticeOfIntentHomeDto;
129+
noticeOfIntent: NoticeOfIntentHomeDto;
130130
}
131131

132132
export class NoticeOfIntentDecisionConditionHomeDto {

services/apps/alcs/src/alcs/notice-of-intent-decision/notice-of-intent-decision-condition/notice-of-intent-decision-condition.service.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable } from '@nestjs/common';
22
import { InjectRepository } from '@nestjs/typeorm';
3-
import { FindOptionsWhere, In, IsNull, Repository } from 'typeorm';
3+
import { FindOptionsRelations, FindOptionsWhere, In, IsNull, Repository } from 'typeorm';
44
import { ServiceValidationException } from '../../../../../../libs/common/src/exceptions/base.exception';
55
import { NoticeOfIntentDecisionComponent } from '../notice-of-intent-decision-component/notice-of-intent-decision-component.entity';
66
import { NoticeOfIntentDecisionConditionType } from './notice-of-intent-decision-condition-code.entity';
@@ -29,6 +29,14 @@ export class NoticeOfIntentDecisionConditionService {
2929
assignee: true,
3030
};
3131

32+
private DEFAULT_NOI_RELATIONS: FindOptionsRelations<NoticeOfIntentModification> = {
33+
noticeOfIntent: {
34+
type: true,
35+
region: true,
36+
localGovernment: true,
37+
},
38+
};
39+
3240
constructor(
3341
@InjectRepository(NoticeOfIntentDecisionCondition)
3442
private repository: Repository<NoticeOfIntentDecisionCondition>,
@@ -132,11 +140,8 @@ export class NoticeOfIntentDecisionConditionService {
132140
const decision = this.mapper.map(c.decision, NoticeOfIntentDecision, NoticeOfIntentDecisionHomeDto);
133141
const noticeOfIntent = this.mapper.map(c.decision.noticeOfIntent, NoticeOfIntent, NoticeOfIntentHomeDto);
134142
const appModifications = await this.modificationRepository.find({
135-
where: {
136-
modifiesDecisions: {
137-
uuid: c.decision?.uuid,
138-
},
139-
},
143+
where: { noticeOfIntent: { fileNumber: condition?.decision?.noticeOfIntent.fileNumber } },
144+
relations: this.DEFAULT_NOI_RELATIONS,
140145
});
141146

142147
return {
@@ -147,7 +152,7 @@ export class NoticeOfIntentDecisionConditionService {
147152
noticeOfIntent: {
148153
...noticeOfIntent,
149154
activeDays: undefined,
150-
pausedDays: timeMap.get(noticeOfIntent.uuid)?.pausedDays ?? null,
155+
pausedDays: timeMap.get(noticeOfIntent.uuid)!.pausedDays || 0,
151156
paused: timeMap.get(noticeOfIntent.uuid)?.pausedDays !== null,
152157
},
153158
},

0 commit comments

Comments
 (0)