public async Task <IActionResult> GetMergeRequests(DateTime startDate, DateTime endDate) { var dtos = await _gitLabService.GetMergeRequestsStatistics(startDate, endDate); var result = _mapper.Map <IEnumerable <UserMergeRequestsStatisicsContract> >(dtos); return(Ok(result)); }
public async Task <IActionResult> GetMergeRequests(DateTime startDate, DateTime endDate) { return(await _cache.GetOrCreateAsync("statistic" + startDate.ToShortDateString() + "/" + endDate.ToShortDateString(), async cacheEntry => { cacheEntry.SlidingExpiration = TimeSpan.FromSeconds(TIMEOUT_SECONDS); var dtos = await _gitLabService.GetMergeRequestsStatistics(startDate, endDate); var result = _mapper.Map <IEnumerable <UserMergeRequestsStatisicsContract> >(dtos); return Ok(result); })); }
public void Update() { var dtFrom = DateTimeOffset.Now.AddDays(-30).Date; var dtTill = DateTimeOffset.Now.Date; var result = _gitLabService.GetMergeRequestsStatistics(dtFrom, dtTill).Result; var items = GetStoreItems(result).ToList(); var resultComments = _gitLabService.GetMergeRequestsCommentsStatistics(dtFrom, dtTill).Result; items = items.Concat(GetStoreCommentItems(resultComments)).ToList(); var settings = new ConnectionSettings(new Uri(_elasticConfig.ElasticSearchUrl)).DefaultIndex(INDEX_NAME); var client = new ElasticClient(settings); var response = client.DeleteByQuery <DateAndIdItemStore>(q => q .Query(q => q .DateRange(r => r .Field(f => f.Dt) .GreaterThanOrEquals(dtFrom) .LessThanOrEquals(dtTill) ) ) ); foreach (var a in items) { var indexResponse = client.IndexDocument(a); if (!indexResponse.IsValid) { _logger.LogError("Not valid document :("); _logger.LogError(indexResponse.OriginalException.ToString()); _logger.LogError(indexResponse.DebugInformation.ToString()); } } }