Skip to content

Commit

Permalink
Merge pull request #23 from Saetch/18-add-webui
Browse files Browse the repository at this point in the history
added  functionality to count values
  • Loading branch information
Saetch authored Jun 15, 2024
2 parents 5d46b56 + 6ee15c8 commit 5c85c54
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Cluster/Master/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,50 @@ static int Main(String[] args){
}

});
app.MapGet("/countValues", async () =>
{
try {
var result = await GetAllNodes(new HttpClient());
List<XYValues> allValues = new List<XYValues>();
List<Task<List<XYValues>>> tasks = new List<Task<List<XYValues>>>();
foreach(NodeResponse node in result){
tasks.Add(GetAllValuesFromNode(node, new HttpClient()));
}
await Task.WhenAll(tasks);
foreach(Task<List<XYValues>> task in tasks){
allValues.AddRange(task.Result);
}
Console.WriteLine("Returning result for count: " + allValues.Count);

return Results.Ok(allValues.Count);

} catch (Exception e) {
return Results.BadRequest(e.Message);
}

});
app.MapGet("/countSavedValues", async () =>
{
try {
var result = await GetAllNodes(new HttpClient());
List<XYValues> allValues = new List<XYValues>();
List<Task<List<XYValues>>> tasks = new List<Task<List<XYValues>>>();
foreach(NodeResponse node in result){
tasks.Add(GetAllValuesFromNode(node, new HttpClient()));
}
await Task.WhenAll(tasks);
foreach(Task<List<XYValues>> task in tasks){
allValues.AddRange(task.Result);
}
Console.WriteLine("Returning result for count: " + allValues.Count);

return Results.Ok(allValues.Count);

} catch (Exception e) {
return Results.BadRequest(e.Message);
}

});
app.Run();


Expand Down

0 comments on commit 5c85c54

Please sign in to comment.