From 5881a790ecb3329a853a9c5ec3998742004c07a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20H=C3=A5land?= <144004233+BouVid@users.noreply.github.com> Date: Mon, 30 Oct 2023 08:26:01 +0100 Subject: [PATCH] (fix)functions: Lineorg client bug (#600) - [ ] ~~New feature~~ - [x] Bug fix - [ ] ~~High impact~~ **Description of work:** API call to the lineorg-api got faulty query due to Linq aggregate not working as intended, fixed with workaround. **Testing:** - [ ] ~~Can be tested~~ - [ ] ~~Automatic tests created / updated~~ - [ ] ~~Local tests are passing~~ **Checklist:** - [ ] ~~Considered automated tests~~ - [ ] ~~Considered updating specification / documentation~~ - [ ] ~~Considered work items~~ - [ ] ~~Considered security~~ - [ ] ~~Performed developer testing~~ - [ ] ~~Checklist finalized / ready for review~~ --- .../ApiClients/LineOrgApiClient.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/backend/function/Fusion.Resources.Functions/ApiClients/LineOrgApiClient.cs b/src/backend/function/Fusion.Resources.Functions/ApiClients/LineOrgApiClient.cs index f2c308419..93ab96cb5 100644 --- a/src/backend/function/Fusion.Resources.Functions/ApiClients/LineOrgApiClient.cs +++ b/src/backend/function/Fusion.Resources.Functions/ApiClients/LineOrgApiClient.cs @@ -29,12 +29,17 @@ public async Task> GetOrgUnitDepartmentsAsync() public async Task> GetResourceOwnersFromFullDepartment(List fullDepartments) { + var list = fullDepartments + .Select(l => $"'{l}'") + .ToList() + .Aggregate((a, b) => $"{a}, {b}"); var queryString = $"/lineorg/persons?$filter=fullDepartment in " + - $"({fullDepartments.Aggregate((a, b) => $"'{a}', '{b}'")}) " + + $"({list}) " + $"and isResourceOwner eq 'true'"; var resourceOwners = await lineOrgClient.GetAsJsonAsync(queryString); return resourceOwners.Value; + } internal class DepartmentRef