public void CanGetEventStats() { // capture start date before generating data to make sure that our time range for stats includes all items var startDate = DateTime.UtcNow.SubtractDays(60); const int eventCount = 100; RemoveData(); CreateData(eventCount, false); _client.Refresh(d => d.Force()); _statsClient.DisplayStats(); var result = _stats.GetOccurrenceStats(startDate, DateTime.UtcNow, null, userFilter: "project:" + TestConstants.ProjectId); Assert.Equal(eventCount, result.Total); Assert.Equal(eventCount, result.Timeline.Sum(t => t.Total)); Assert.Equal(_stackRepository.Count(), result.Unique); Assert.Equal(_stackRepository.Count(), result.Timeline.Sum(t => t.New)); var stacks = _stackRepository.GetByOrganizationId(TestConstants.OrganizationId, new PagingOptions().WithLimit(100)); foreach (var stack in stacks) { result = _stats.GetOccurrenceStats(startDate, DateTime.UtcNow, null, userFilter: "stack:" + stack.Id); Console.WriteLine("{0} - {1} : {2}", stack.Id, stack.TotalOccurrences, result.Total); //Assert.Equal(stack.TotalOccurrences, result.Total); //Assert.Equal(stack.TotalOccurrences, result.Timeline.Sum(t => t.Total)); } }
public void CanCreateUpdateRemove() { _repository.RemoveAll(); Assert.Equal(0, _repository.Count()); var stack = StackData.GenerateStack(projectId: TestConstants.ProjectId, organizationId: TestConstants.OrganizationId); Assert.Null(stack.Id); _repository.Add(stack); Assert.NotNull(stack.Id); _client.Refresh(); stack = _repository.GetById(stack.Id); Assert.NotNull(stack); stack.Description = "New Description"; _repository.Save(stack); _repository.Remove(stack.Id); }
public void CanStackEvents() { _dataHelper.ResetProjectData(TestConstants.ProjectId); TimeSpan timeOffset = _projectRepository.GetDefaultTimeOffset(TestConstants.ProjectId); DateTime startDate = DateTime.UtcNow.Add(timeOffset).Date.AddDays(-120); DateTime endDate = DateTime.UtcNow.Add(timeOffset).Date; const int count = 25; var events = EventData.GenerateEvents(count, organizationId: TestConstants.OrganizationId, startDate: startDate, endDate: endDate, projectId: TestConstants.ProjectId, timeZoneOffset: timeOffset).ToList(); _eventPipeline.Run(events); long stackCount = _stackRepository.Count(); var info = _eventStatsHelper.GetProjectEventStats(TestConstants.ProjectId, timeOffset, startDate, endDate); Assert.Equal(count, info.Total); Assert.InRange(info.UniqueTotal, 1, count); Assert.Equal(stackCount, info.NewTotal); Assert.True(info.Stats.Count > 40); Assert.Equal(count, info.Stats.Sum(ds => ds.Total)); Assert.Equal(stackCount, info.Stats.Sum(ds => ds.NewTotal)); }