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); _client.Refresh(); var result = _stats.GetOccurrenceStats(startDate, DateTime.UtcNow); 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, "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)); } }
private IHttpActionResult GetInternal(string systemFilter, string userFilter = null, string time = null, string offset = null) { var timeInfo = GetTimeInfo(time, offset); var processResult = QueryProcessor.Process(userFilter); if (!processResult.IsValid) { return(BadRequest(processResult.Message)); } if (String.IsNullOrEmpty(systemFilter)) { systemFilter = GetAssociatedOrganizationsFilter(_organizationRepository, processResult.UsesPremiumFeatures, HasOrganizationOrProjectFilter(userFilter)); } EventStatsResult result; try { result = _stats.GetOccurrenceStats(timeInfo.UtcRange.Start, timeInfo.UtcRange.End, systemFilter, processResult.ExpandedQuery, timeInfo.Offset); } catch (ApplicationException ex) { Log.Error().Exception(ex) .Property("Search Filter", new { SystemFilter = systemFilter, UserFilter = userFilter, Time = time, Offset = offset }) .Tag("Search") .Property("User", ExceptionlessUser) .ContextProperty("HttpActionContext", ActionContext) .Write(); return(BadRequest("An error has occurred. Please check your search filter.")); } return(Ok(result)); }
public async Task 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(); await CreateDataAsync(eventCount, false); _client.Refresh(d => d.Force()); _metricsClient.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 IHttpActionResult GetInternal(string systemFilter, string userFilter = null, string time = null, string offset = null) { // TODO: Handle UTC Retention Cutoff. var timeInfo = GetTimeInfo(time, offset); if (String.IsNullOrEmpty(systemFilter)) { systemFilter = GetAssociatedOrganizationsFilter(); } var result = _stats.GetOccurrenceStats(timeInfo.UtcRange.Start, timeInfo.UtcRange.End, systemFilter, userFilter, timeInfo.Offset); return(Ok(result)); }
public IHttpActionResult GetInternal(string systemFilter, string userFilter = null, string time = null, string offset = null) { var timeInfo = GetTimeInfo(time, offset); var validationResult = QueryValidator.Validate(userFilter); if (!validationResult.IsValid) { return(BadRequest(validationResult.Message)); } if (String.IsNullOrEmpty(systemFilter)) { systemFilter = GetAssociatedOrganizationsFilter(_organizationRepository, validationResult.UsesPremiumFeatures, HasOrganizationOrProjectFilter(userFilter)); } var result = _stats.GetOccurrenceStats(timeInfo.UtcRange.Start, timeInfo.UtcRange.End, systemFilter, userFilter, timeInfo.Offset); return(Ok(result)); }