From c7106dbfb9aa35e3e9d147ae193def3cea855fbf Mon Sep 17 00:00:00 2001 From: Anna Zabolotskaya Date: Sat, 9 Mar 2024 16:59:44 +0100 Subject: [PATCH] reduce amount of returned data --- FunctionApp/SharePoint/ListData.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/FunctionApp/SharePoint/ListData.cs b/FunctionApp/SharePoint/ListData.cs index 35dcad8..465b719 100644 --- a/FunctionApp/SharePoint/ListData.cs +++ b/FunctionApp/SharePoint/ListData.cs @@ -60,7 +60,7 @@ public async Task GetEmployees( return new OkObjectResult(await list.GetListItems(new List { new("select", "id"), - new("expand", "fields(select=Title,CompanyLookupId,CSCS)"), + new("expand", "fields(select=Title,CSCS)"), new("filter", $"fields/CompanyLookupId eq '{companyId}'"), new("orderby", "fields/Title") })); @@ -82,7 +82,7 @@ public async Task GetSignedInCompanies( var listItems = await list.GetListItems(new List { new("select", "id"), - new("expand", "fields(select=Title,CurrentStatus,Company,CompanyLookupId,CSCS)"), + new("expand", "fields(select=Company,CompanyLookupId)"), new("filter", $"fields/Site eq '{siteName}' and fields/CurrentStatus eq 'In'"), new("orderby", "fields/Company") }); @@ -103,14 +103,16 @@ public async Task GetSignedInEmployees( var graph = _graphProvider.Create(); var list = await graph.GetListAsync(_settings.SiteUrl, _settings.RegisterListName); - return new OkObjectResult(await list.GetListItems(new List + var listItems = await list.GetListItems(new List { new("select", "id"), - new("expand", "fields(select=Title,CurrentStatus,Company,CompanyLookupId,CSCS)"), + new("expand", "fields(select=Title)"), new("filter", $"fields/Site eq '{siteName}' and fields/CompanyLookupId eq '{companyId}' and fields/CurrentStatus eq 'In'"), new("orderby", "fields/Title") - })); + }); + + return new OkObjectResult(listItems.DistinctBy(i => i.Fields.AdditionalData["Title"])); } } }