public async Task <ProjectionRegistryStatus> GetStatusAsync() { _logger.LogTrace("GetStatusAsync"); var states = await _entityStore.LoadItemsAsync <ProjectionInitializationStatus>().ConfigureAwait(false); var enumerable = states as ProjectionInitializationStatus[] ?? states.ToArray(); var temp = new ProjectionRegistryStatus() { Projectors = enumerable, Status = ProjectionInitializationStatus.StatusNew }; if (!enumerable.Any()) { return(temp); } if (enumerable.All(x => x.Status == ProjectionInitializationStatus.StatusReady)) { temp.Status = ProjectionInitializationStatus.StatusReady; } else { if (enumerable.Any(x => x.Status == ProjectionInitializationStatus.StatusPending)) { temp.Status = ProjectionInitializationStatus.StatusPending; } else { temp.Status = ProjectionInitializationStatus.StatusNew; } } temp.Pending = temp.Projectors.Count(x => x.Status == ProjectionInitializationStatus.StatusPending); temp.Ready = temp.Projectors.Count(x => x.Status == ProjectionInitializationStatus.StatusReady); temp.Total = temp.Projectors.Length; return(temp); }
public async Task <ProjectionRegistryStatus> GetStatusAsync() { _logger.LogTrace("GetStatusAsync"); var states = await _entityStore.LoadItemsAsync <ProjectionInitializationStatus>(); var temp = new ProjectionRegistryStatus() { Projectors = states, Status = ProjectionInitializationStatus.StatusNew }; if (states.Length == 0) { return(temp); } if (states.All(x => x.Status == ProjectionInitializationStatus.StatusReady)) { temp.Status = ProjectionInitializationStatus.StatusReady; } else { if (states.Any(x => x.Status == ProjectionInitializationStatus.StatusPending)) { temp.Status = ProjectionInitializationStatus.StatusPending; } else { temp.Status = ProjectionInitializationStatus.StatusNew; } } temp.Pending = temp.Projectors.Count(x => x.Status == ProjectionInitializationStatus.StatusPending); temp.Ready = temp.Projectors.Count(x => x.Status == ProjectionInitializationStatus.StatusReady); temp.Total = temp.Projectors.Length; return(temp); }