diff --git a/Cluster/Master/Program.cs b/Cluster/Master/Program.cs index 89d7671..4fb41a9 100644 --- a/Cluster/Master/Program.cs +++ b/Cluster/Master/Program.cs @@ -173,7 +173,50 @@ static int Main(String[] args){ } }); + app.MapGet("/countValues", async () => + { + try { + var result = await GetAllNodes(new HttpClient()); + List allValues = new List(); + List>> tasks = new List>>(); + foreach(NodeResponse node in result){ + tasks.Add(GetAllValuesFromNode(node, new HttpClient())); + } + await Task.WhenAll(tasks); + foreach(Task> 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 allValues = new List(); + List>> tasks = new List>>(); + foreach(NodeResponse node in result){ + tasks.Add(GetAllValuesFromNode(node, new HttpClient())); + } + await Task.WhenAll(tasks); + foreach(Task> 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();