Skip to content

Commit

Permalink
Merge pull request #1648 from bcgov/main
Browse files Browse the repository at this point in the history
back-merge main into develop
  • Loading branch information
mhuseinov authored May 9, 2024
2 parents c8df85b + 7374e44 commit 3b03b82
Show file tree
Hide file tree
Showing 32 changed files with 146 additions and 167 deletions.
12 changes: 6 additions & 6 deletions alcs-frontend/src/app/features/board/board.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,18 +390,18 @@ export class BoardComponent implements OnInit, OnDestroy {

private mapPlanningReferralToCard(referral: PlanningReferralDto): CardData {
return {
status: referral.card.status.code,
status: referral.card!.status.code,
typeLabel: 'Planning Review',
title: `${referral.planningReview.fileNumber} (${referral.planningReview.documentName})`,
titleTooltip: referral.planningReview.type.label,
assignee: referral.card.assignee,
id: referral.card.uuid,
assignee: referral.card!.assignee,
id: referral.card!.uuid,
labels: [referral.planningReview.type],
cardType: CardType.PLAN,
paused: false,
highPriority: referral.card.highPriority,
cardUuid: referral.card.uuid,
dateReceived: referral.card.createdAt,
highPriority: referral.card!.highPriority,
cardUuid: referral.card!.uuid,
dateReceived: referral.card!.createdAt,
dueDate: referral.dueDate ? new Date(referral.dueDate) : undefined,
decisionMeetings: referral.planningReview.meetings,
showDueDate: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class CreatePlanningReviewDialogComponent implements OnInit, OnDestroy {
this.dialogRef.close(true);
if (res) {
await this.router.navigate(this.activatedRoute.snapshot.url, {
queryParams: res.card.uuid && res.card.type ? { card: res.card.uuid, type: res.card.type } : {},
queryParams: res.card && res.card.uuid && res.card.type ? { card: res.card.uuid, type: res.card.type } : {},
relativeTo: this.activatedRoute,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class PlanningReviewDialogComponent extends CardDialogComponent implement
...this.data.planningReview.type,
borderColor: this.data.planningReview.type.backgroundColor,
};
this.populateCardData(this.data.card);
this.populateCardData(this.data.card!);

this.selectedRegion = this.data.planningReview.region.code;
this.cardTitle = `${this.data.planningReview.fileNumber} (${this.data.planningReview.documentName})`;
Expand All @@ -64,16 +64,16 @@ export class PlanningReviewDialogComponent extends CardDialogComponent implement
}

private async reload() {
const planningReferral = await this.planningReferralService.fetchByCardUuid(this.planningReferral.card.uuid);
const planningReferral = await this.planningReferralService.fetchByCardUuid(this.planningReferral.card!.uuid);
if (planningReferral) {
await this.populateCardData(planningReferral.card);
await this.populateCardData(planningReferral.card!);
}
}

async onBoardSelected(board: BoardWithFavourite) {
this.selectedBoard = board.code;
try {
await this.boardService.changeBoard(this.planningReferral.card.uuid, board.code);
await this.boardService.changeBoard(this.planningReferral.card!.uuid, board.code);
const loadedBoard = await this.boardService.fetchBoardDetail(board.code);
if (loadedBoard) {
this.boardStatuses = loadedBoard.statuses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ export class AssignedComponent implements OnInit {

this.planningReferrals = [
...planningReferrals
.filter((r) => r.card.highPriority)
.filter((r) => r.card!.highPriority)
.map((r) => this.mapPlanningReferral(r))
.sort((a, b) => a.date! - b.date!),
...planningReferrals
.filter((r) => !r.card.highPriority)
.filter((r) => !r.card!.highPriority)
.map((r) => this.mapPlanningReferral(r))
.sort((a, b) => a.date! - b.date!),
];
Expand Down Expand Up @@ -133,16 +133,17 @@ export class AssignedComponent implements OnInit {
this.applications.length +
this.planningReferrals.length +
this.noticeOfIntents.length +
this.notifications.length;
this.notifications.length +
this.inquiries.length;
}

private mapPlanningReferral(p: PlanningReferralDto): AssignedToMeFile {
return {
title: `${p.planningReview.fileNumber} (${p.planningReview.documentName})`,
type: p.card.type,
date: p.card.createdAt,
card: p.card,
highPriority: p.card.highPriority,
type: p.card!.type,
date: p.card!.createdAt,
card: p.card!,
highPriority: p.card!.highPriority,
labels: [p.planningReview.type],
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ export class SubtaskComponent implements OnInit, OnDestroy {

if (this.showAppAndNonApp) {
this.totalSubtaskCount =
this.applicationSubtasks.length + this.planningReviewSubtasks.length + this.notificationSubtasks.length;
this.applicationSubtasks.length +
this.planningReviewSubtasks.length +
this.notificationSubtasks.length +
this.inquirySubtasks.length;
}

if (this.showAppAndNonApp && this.showNoi) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class DecisionDocumentUploadDialogComponent implements OnInit {
async onSubmit() {
const file = this.pendingFile;
if (file) {
const renamedFile = new File([file], this.name.value + this.extension ?? file.name);
const renamedFile = new File([file], this.name.value + this.extension ?? file.name, { type: file.type });
this.isSaving = true;
if (this.data.existingDocument) {
await this.decisionService.deleteFile(this.data.decisionUuid, this.data.existingDocument.uuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class DecisionDocumentUploadDialogComponent implements OnInit {
async onSubmit() {
const file = this.pendingFile;
if (file) {
const renamedFile = new File([file], this.name.value + this.extension ?? file.name);
const renamedFile = new File([file], this.name.value + this.extension ?? file.name, { type: file.type });
this.isSaving = true;
if (this.data.existingDocument) {
await this.decisionService.deleteFile(this.data.decisionUuid, this.data.existingDocument.uuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ export class HeaderComponent implements OnChanges {
async setupLinkedCards() {
if ('referrals' in this.planningReview) {
for (const [index, referral] of this.planningReview.referrals.entries()) {
this.linkedCards.push({
...referral.card,
displayName: `Referral #${this.planningReview.referrals.length - index}`,
});
if (referral.card) {
this.linkedCards.push({
...referral.card,
displayName: `Referral #${this.planningReview.referrals.length - index}`,
});
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class InquirySearchTableComponent {
itemsPerPage = 20;
total = 0;
sortDirection: SortDirection = 'desc';
sortField = 'fileId';
sortField = 'dateSubmitted';
isLoading = false;

constructor(private router: Router) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
</td>
</ng-container>

<ng-container matColumnDef="dateSubmitted">
<th *matHeaderCellDef mat-header-cell mat-sort-header>Date Submitted to ALC</th>
<td *matCellDef="let element" mat-cell>
{{ element.dateSubmitted | date | emptyColumn }}
</td>
</ng-container>

<ng-container matColumnDef="type">
<th *matHeaderCellDef mat-header-cell mat-sort-header>Type</th>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TableChange } from '../search.interface';

interface SearchResult {
fileNumber: string;
dateSubmitted: number;
applicant: string;
localGovernmentName?: string;
referenceId: string;
Expand Down Expand Up @@ -36,13 +37,13 @@ export class PlanningReviewSearchTableComponent {

@Output() tableChange = new EventEmitter<TableChange>();

displayedColumns = ['fileId', 'type', 'applicant', 'government', 'status'];
displayedColumns = ['fileId', 'dateSubmitted', 'type', 'applicant', 'government', 'status'];
dataSource: PlanningReviewSearchResultDto[] = [];

itemsPerPage = 20;
total = 0;
sortDirection: SortDirection = 'desc';
sortField = 'fileId';
sortField = 'dateSubmitted';
isLoading = false;

constructor(private router: Router) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export interface PlanningReferralDto {
responseDescription?: string;
submissionDate: number;
planningReview: PlanningReviewDto;
card: CardDto;
card?: CardDto;
}

export interface UpdatePlanningReviewDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export class SearchBarComponent implements AfterViewInit {
break;
case 'COV':
case 'PLAN':
await this.router.navigateByUrl(
`/board/${result.boardCode}?card=${result.referenceId}&type=${result.type}`,
);
await this.router.navigate(['planning-review', result.referenceId]);
break;
default:
this.toastService.showErrorToast(`Unable to navigate to ${result.referenceId}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _map_data(row):
"planning_review_uuid": row["planning_review_uuid"],
"document_uuid": row["document_uuid"],
"type_code": row["type_code"],
"visibility_flags": row["visibility_flags"],
"visibility_flags": '{""}',
"oats_document_id": row["oats_document_id"],
"oats_planning_review_id": row["oats_planning_review_id"],
"audit_created_by": OATS_ETL_USER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ with oats_documents_to_map as (
select otm.planning_review_uuid,
otm.document_uuid,
otm.code as type_code,
(
case
when is_public = 'Y'
and is_app_lg = 'Y' then '{P, A, C, G}'::text []
when is_public = 'Y' then '{P}'::text []
when is_app_lg = 'Y' then '{A, C, G}'::text []
else '{}'::text []
end
) as visibility_flags,
oats_document_id,
oats_planning_review_id,
otm."description"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
add_timezone_and_keep_date_part,
OatsToAlcsDecisionOutcomes,
AlcsPlanningReviewOutcomes,
to_alcs_format,
get_now_with_offset,
)
from db import inject_conn_pool
from psycopg2.extras import RealDictCursor, execute_batch
Expand Down Expand Up @@ -39,6 +41,8 @@ def process_planning_review_decisions(conn=None, batch_size=BATCH_UPLOAD_SIZE):
failed_inserts_count = 0
successful_inserts_count = 0
last_planning_decision_id = 0
last_file_number = 0
last_decision_date = ""

with open(
"planning_review/sql/decisions/planning_review_decisions_insert.sql",
Expand All @@ -47,10 +51,16 @@ def process_planning_review_decisions(conn=None, batch_size=BATCH_UPLOAD_SIZE):
) as sql_file:
query = sql_file.read()
while True:
query_condition = ""
if last_decision_date:
query_condition = f"WHERE pr.file_number::bigint >= {last_file_number} AND opd.decision_date >= '{last_decision_date}' AND opd.planning_decision_id > {last_planning_decision_id} ORDER BY pr.file_number::bigint, opd.decision_date, opd.planning_decision_id;"
else:
query_condition = f"WHERE pr.file_number::bigint >= {last_file_number} AND opd.planning_decision_id > {last_planning_decision_id} ORDER BY pr.file_number::bigint, opd.decision_date, opd.planning_decision_id;"

cursor.execute(
f"""
{query}
WHERE opd.planning_decision_id > {last_planning_decision_id} ORDER BY opd.planning_decision_id;
{query_condition}
"""
)

Expand All @@ -64,9 +74,18 @@ def process_planning_review_decisions(conn=None, batch_size=BATCH_UPLOAD_SIZE):
successful_inserts_count = successful_inserts_count + len(
inserted_data
)
last_planning_decision_id = dict(inserted_data[-1])[
"planning_decision_id"
]
last_record = dict(inserted_data[-1])
last_planning_decision_id = last_record["planning_decision_id"]
last_inserted_row = next(
(
row
for row in rows
if row["uuid"] == last_record["review_uuid"]
),
None,
)
last_file_number = last_inserted_row["file_number"]
last_decision_date = last_inserted_row["decision_date"]

logger.debug(
f"Retrieved/updated items count: {len(inserted_data)}; total successfully inserted planning referral so far {successful_inserts_count}; last updated planning_decision_id: {last_planning_decision_id}"
Expand Down Expand Up @@ -106,7 +125,8 @@ def _insert_base_fields(conn, batch_size, cursor, rows):
outcome_code,
resolution_number,
resolution_year,
date
date,
created_at
)
VALUES (
%(review_uuid)s,
Expand All @@ -116,13 +136,16 @@ def _insert_base_fields(conn, batch_size, cursor, rows):
%(outcome_code)s,
%(resolution_number)s,
%(resolution_year)s,
%(date)s
%(date)s,
%(created_at)s
)
ON CONFLICT DO NOTHING;
"""


def _prepare_oats_planning_review_data(row_data_list):
mapped_data_list = []
insert_index = 0
for row in row_data_list:
mapped_data_list.append(
{
Expand All @@ -134,8 +157,11 @@ def _prepare_oats_planning_review_data(row_data_list):
"outcome_code": _map_outcome_code(row),
"resolution_number": row["resolution_number"],
"resolution_year": _map_resolution_year(row),
"created_at": to_alcs_format(get_now_with_offset(insert_index)),
"file_number": row["file_number"],
}
)
insert_index += 1

return mapped_data_list

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ SELECT
opd.planning_acceptance_code,
pr."uuid",
opd.resolution_number,
opd.planning_decision_id
opd.planning_decision_id,
pr.file_number::bigint
FROM
oats.oats_planning_decisions opd
JOIN alcs.planning_review pr ON opd.planning_review_id::TEXT = pr.file_number
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class DecisionMeetingController {
(meeting) => meeting.uuid === planningReferral.planningReview.uuid,
);

if (!meetingDate) {
if (!meetingDate || !planningReferral.card) {
return [];
}

Expand All @@ -201,10 +201,10 @@ export class DecisionMeetingController {
meetingDate: new Date(meetingDate.next_meeting).getTime(),
fileNumber: planningReferral.planningReview.fileNumber,
applicant: planningReferral.planningReview.documentName,
boardCode: planningReferral.card!.board.code,
boardCode: planningReferral.card.board.code,
type: CARD_TYPE.PLAN,
assignee: this.mapper.map(
planningReferral.card!.assignee,
planningReferral.card.assignee,
User,
UserDto,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ export class NoticeOfIntentSubmissionStatusService {
async saveSubmissionToSubmissionStatus(
submissionStatus: NoticeOfIntentSubmissionToSubmissionStatus,
) {
console.log('save', submissionStatus);
return await this.statusesRepository.save(submissionStatus);
}
}
Loading

0 comments on commit 3b03b82

Please sign in to comment.