Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #59 from miguelEsteban/develop
Browse files Browse the repository at this point in the history
optimice get counts of jobs on state in GetStatistics
  • Loading branch information
imranmomin committed Oct 17, 2020
2 parents e3c6fe1 + 7a1d22f commit 0c8870c
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/DocumentDbMonitoringApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,7 @@ public StatisticsDto GetStatistics()

// get counts of jobs on state
string[] keys = { EnqueuedState.StateName, FailedState.StateName, ProcessingState.StateName, ScheduledState.StateName, SucceededState.StateName, AwaitingState.StateName };
List<IGrouping<string, string>> states = storage.Client.CreateDocumentQueryAsync<Documents.Job>(storage.CollectionUri, new FeedOptions { PartitionKey = new PartitionKey((int)DocumentTypes.Job) })
.Where(x => x.DocumentType == DocumentTypes.Job && x.StateName.IsDefined() && keys.Contains(x.StateName))
.Select(x => x.StateName)
.ToQueryResult()
.GroupBy(x => x)
.ToList();

foreach (IGrouping<string, string> state in states)
{
results.Add(state.Key.ToLower(), state.LongCount());
}
results = keys.Select(x => new { Key = x.ToLower(), Value = GetNumberOfJobsByStateName(x) }).Where(x => x.Value > 0).ToDictionary(i => i.Key, i => i.Value);

// get counts of servers
SqlQuerySpec sql = new SqlQuerySpec
Expand Down

0 comments on commit 0c8870c

Please sign in to comment.