Skip to content

Commit

Permalink
Fix GetInstances async postprocess (#110)
Browse files Browse the repository at this point in the history
* Make InstanceRepository.GetInstancesFromQuery async and await postProcess function call.

* Check process.currentTask on InstanceRepository.GetInstancesFromQuery

---------

Co-authored-by: Henrik Linde <[email protected]>
  • Loading branch information
henrili and Henrik Linde authored Aug 9, 2024
1 parent 812906e commit ad6047a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Services/Storage/Implementation/InstanceRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task<Instance> GetOne(int instanceOwnerPartyId, Guid instanceGuid)
return null;
}

public Task<InstanceQueryResponse> GetInstancesFromQuery(Dictionary<string, StringValues> queryParams, string continuationToken, int size)
public async Task<InstanceQueryResponse> GetInstancesFromQuery(Dictionary<string, StringValues> queryParams, string continuationToken, int size)
{
List<string> validQueryParams = new List<string>
{
Expand Down Expand Up @@ -199,16 +199,20 @@ public Task<InstanceQueryResponse> GetInstancesFromQuery(Dictionary<string, Stri
{
RemoveForDateTime(instances, $"{nameof(Instance.Process)}.{nameof(Instance.Process.Ended)}", queryParams.GetValueOrDefault("process.ended"));
}
if (queryParams.ContainsKey("process.currentTask"))
{
instances.RemoveAll(i => !queryParams["process.currentTask"].Contains(i.Process.CurrentTask.ElementId));
}

instances.RemoveAll(i => i.Status.IsHardDeleted == true);

instances.ForEach(async i => await PostProcess(i));
await Task.WhenAll(instances.Select(async i => await PostProcess(i)));

return Task.FromResult(new InstanceQueryResponse
return new InstanceQueryResponse
{
Instances = instances,
Count = instances.Count,
});
};
}

public async Task<Instance> Update(Instance instance)
Expand Down

0 comments on commit ad6047a

Please sign in to comment.