Skip to content

Commit

Permalink
Fix so that no expertise code in PLR record doesn't cause error (#1744)
Browse files Browse the repository at this point in the history
* Broken - Help Marty!

* Fix as ExpertiseCode may be null

* Catch PLR server errors with a default

* Improve responsiveness of Overview page

* Added comment

* Added sample test file for convenience

* Update to net5.0 to be compatible with prime-dotnet-webapi dependency

Co-authored-by: Alan Leung <Alan.Leung@nttdata.com>
Co-authored-by: Martin Pultz <mtpultz@gmail.com>
  • Loading branch information
3 people authored Nov 10, 2021
1 parent 3bb21d3 commit 006b9b9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import { map } from 'rxjs/operators';
import { forkJoin } from 'rxjs';
import { catchError, exhaustMap, map } from 'rxjs/operators';
import { forkJoin, of } from 'rxjs';

import { PermissionService } from '@auth/shared/services/permission.service';
import { ToastService } from '@core/services/toast.service';
Expand Down Expand Up @@ -75,14 +75,10 @@ export class EnrolleeOverviewComponent extends AdjudicationContainerComponent im
.subscribe((enrollee: HttpEnrollee) => this.enrollee = enrollee);

this.paperEnrolmentResource.getAdjudicationDocuments(+this.route.snapshot.params.id)
.subscribe(documents => {
this.documents = documents
});
.subscribe(documents => this.documents = documents);

this.enrolmentResource.getCurrentEnrolleeAbsence(+this.route.snapshot.params.id)
.subscribe((absence: EnrolleeAbsence) => {
this.absence = absence
});
.subscribe((absence: EnrolleeAbsence) => this.absence = absence);
}

private loadEnrollee(enrolleeId: number): void {
Expand All @@ -97,18 +93,25 @@ export class EnrolleeOverviewComponent extends AdjudicationContainerComponent im
}))
),
enrolleeNavigation: this.adjudicationResource.getAdjacentEnrolleeId(enrolleeId),
plrInfo: this.adjudicationResource.getPlrInfoByEnrolleeId(enrolleeId)
})
.subscribe(({ enrollee, enrolleeNavigation, plrInfo }) => {
this.enrollee = enrollee.enrollee;
this.enrollees = [enrollee.enrolleeView];
this.enrolment = enrollee.enrolment;
this.enrolleeNavigation = enrolleeNavigation;
this.plrInfo = plrInfo;
// hide the adjudication card if enrolment is editable and no 'reason for adjudication'
this.showAdjudication = !(enrollee.enrollee.currentStatus.statusCode === EnrolmentStatusEnum.EDITABLE
&& !enrollee.enrollee.currentStatus.enrolmentStatusReasons?.length);
});
}).pipe(
map(
({ enrollee, enrolleeNavigation }) => {
// Complete this first before attempting to get PLR info, so user can see information rendered sooner
this.enrollee = enrollee.enrollee;
this.enrollees = [enrollee.enrolleeView];
this.enrolment = enrollee.enrolment;
this.enrolleeNavigation = enrolleeNavigation;
// hide the adjudication card if enrolment is editable and no 'reason for adjudication'
this.showAdjudication = !(enrollee.enrollee.currentStatus.statusCode === EnrolmentStatusEnum.EDITABLE
&& !enrollee.enrollee.currentStatus.enrolmentStatusReasons?.length);
return enrolleeId;
}
),
exhaustMap((enrolleeId: number) => this.adjudicationResource.getPlrInfoByEnrolleeId(enrolleeId)
.pipe(
map((plrInfo: PlrInfo[]) => this.plrInfo = plrInfo),
catchError(_ => of([]))))
).subscribe();
}

private enrolmentAdapter(enrollee: HttpEnrollee): Enrolment {
Expand Down
4 changes: 3 additions & 1 deletion prime-dotnet-webapi/Services/PlrProviderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ public async Task<IEnumerable<PlrViewModel>> GetPlrDataByCollegeIdsAsync(IEnumer
.ProjectTo<PlrViewModel>(_mapper.ConfigurationProvider, new { plrRoleTypes, plrStatusReasons })
.ToListAsync();

// If a PlrViewModel has ExpertiseCodes, translate the codes to human-readable text
// PlrProvider's Expertise array does not play well with automapper ProjectTo, map manually before return
return plr.Select(p =>
{
p.Expertise = string.Join(", ", _context.Set<PlrExpertise>().Where(e => p.ExpertiseCode.Contains(e.Code)).Select(e => e.Name));
p.Expertise = string.Join(", ", _context.Set<PlrExpertise>().Where(e =>
(p.ExpertiseCode != null && p.ExpertiseCode.Contains(e.Code))).Select(e => e.Name));
return p;
});
}
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion utilities/PlrIntakeUtility/PlrIntakeUtility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
Expand Down

0 comments on commit 006b9b9

Please sign in to comment.