Skip to content

Commit

Permalink
reduce amount of returned data
Browse files Browse the repository at this point in the history
  • Loading branch information
xxyziggy committed Mar 9, 2024
1 parent 3bde648 commit c7106db
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions FunctionApp/SharePoint/ListData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public async Task<IActionResult> GetEmployees(
return new OkObjectResult(await list.GetListItems(new List<QueryOption>
{
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")
}));
Expand All @@ -82,7 +82,7 @@ public async Task<IActionResult> GetSignedInCompanies(
var listItems = await list.GetListItems(new List<QueryOption>
{
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")
});
Expand All @@ -103,14 +103,16 @@ public async Task<IActionResult> GetSignedInEmployees(
var graph = _graphProvider.Create();
var list = await graph.GetListAsync(_settings.SiteUrl, _settings.RegisterListName);

return new OkObjectResult(await list.GetListItems(new List<QueryOption>
var listItems = await list.GetListItems(new List<QueryOption>
{
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"]));
}
}
}

0 comments on commit c7106db

Please sign in to comment.