Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
            }));
        }
Ejemplo n.º 3
0
        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());
                }
            }
        }