Skip to content

Commit

Permalink
feat: Filter out product positions from GetPersonnelAllocation (#686)
Browse files Browse the repository at this point in the history
- [x] New feature
- [ ] Bug fix
- [ ] High impact

**Description of work:**
We don't want product positions (instances) to show up in the list over
all allocations in Personnel Allocation, and therefore we need to filter
out all these positions.



[AB#55286](https://statoil-proview.visualstudio.com/787035c2-8cf2-4d73-a83e-bb0e6d937eec/_workitems/edit/55286)

[AB#53017](https://statoil-proview.visualstudio.com/787035c2-8cf2-4d73-a83e-bb0e6d937eec/_workitems/edit/53017)

**Testing:**
- [x] Can be tested
- [ ] Automatic tests created / updated
- [x] Local tests are passing

Can be tested with using endpoint:

https://resources-api-pr-686.fusion-dev.net/departments/{departmentString}/resources/personnel/{personId}?api-version=1.0

Change departmentString with the department you want to check and change
personId to a person you want to check. Example "PDP PRD PMC PCA PCA4".
There should be several persons with product positions assigned to them,
but these should not be shown when searching for them here.

Should get all other positions for personnel.

**Checklist:**
- [x] Considered automated tests
- [ ] ~~Considered updating specification / documentation~~
- [x] Considered work items 
- [x] Considered security
- [x] Performed developer testing
- [x] Checklist finalized / ready for review
  • Loading branch information
aleklundeq authored Sep 2, 2024
1 parent 5e20d0f commit 3fb6778
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Handler : IRequestHandler<GetPersonnelAllocation, QueryInternalPers
private readonly IHttpClientFactory httpClientFactory;
private readonly IMediator mediator;
private readonly IFusionProfileResolver profileResolver;

public Handler(ILogger<Handler> logger, ResourcesDbContext db, IHttpClientFactory httpClientFactory, IMediator mediator, IFusionProfileResolver profileResolver)
{
this.logger = logger;
Expand Down Expand Up @@ -64,12 +64,18 @@ public Handler(ILogger<Handler> logger, ResourcesDbContext db, IHttpClientFactor

personWithAllocations.Absence = absence.Select(a => new QueryPersonAbsenceBasic(a)).ToList();

personWithAllocations.PositionInstances = personWithAllocations.PositionInstances
.Where(instance => instance.BasePosition != null
&& instance.BasePosition.ProjectType != null
&& !instance.BasePosition.ProjectType.Equals("Product"))
.ToList();

if (!request.includeCurrentAllocations)
return personWithAllocations;

personWithAllocations.PositionInstances = personWithAllocations.PositionInstances
.Where(instance => instance.AppliesTo >= DateTime.Now && instance.AppliesFrom <= DateTime.Now)
.ToList();
.Where(instance => instance.AppliesTo >= DateTime.Now && instance.AppliesFrom <= DateTime.Now)
.ToList();

personWithAllocations.Absence = personWithAllocations.Absence
.Where(instance => (instance.AppliesTo == null || instance.AppliesTo >= DateTime.Now) && instance.AppliesFrom <= DateTime.Now)
Expand Down

0 comments on commit 3fb6778

Please sign in to comment.