public async Task GetAllRepositoriesStatistics_Test()
        {
            //Arrange
            var startDate = DateTime.Now.AddMonths(-1);
            var endDate   = DateTime.Now;

            //Act
            var result = await _service.GetAllRepositoriesStatisticsAsync(startDate, endDate);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Get(DateTimeOffset startDate, DateTimeOffset endDate)
        {
            return(await _cache.GetOrCreateAsync("statistic" + startDate.DateTime.ToShortDateString() + "/" + endDate.DateTime.ToShortDateString(),
                                                 async cacheEntry => {
                cacheEntry.SlidingExpiration = TimeSpan.FromSeconds(TIMEOUT_SECONDS);

                var statistics = await _gitStatisticsService.GetAllRepositoriesStatisticsAsync(startDate, endDate);
                var result = _mapper.Map <IEnumerable <RepositoryStatisticsContract> >(statistics);

                return Ok(result);
            }));
        }
Exemplo n.º 3
0
        public void UpdateMonth()
        {
            var dtFrom = DateTimeOffset.Now.AddDays(-30);
            var dtTill = DateTimeOffset.Now;

            var client = GetClient();
            var result = _gitStatisticsService.GetAllRepositoriesStatisticsAsync(dtFrom, dtTill).Result;

            var storeDto = result.SelectMany(o => o.Statistics.Select(i => new PersonStatisticsStoreDto
            {
                Date           = o.Date,
                RepositoryName = o.RepositoryName,
                WebUI          = o.WebUI,
                Email          = i.Email,
                Name           = i.Name,
                CommitDate     = i.CommitDate,
                Message        = i.Message,
                Added          = i.Added,
                Deleted        = i.Deleted,
                Sha            = i.Sha,
                Total          = i.Total
            }
                                                                      )).ToList();

            var response = client.DeleteByQuery <PersonStatisticsStoreDto>(q => q
                                                                           .Query(q => q
                                                                                  .DateRange(r => r
                                                                                             .Field(f => f.CommitDate)
                                                                                             .GreaterThanOrEquals(dtFrom.Date)
                                                                                             .LessThanOrEquals(dtTill.Date)
                                                                                             )));

            foreach (var a in storeDto.ToList())
            {
                var indexResponse = client.IndexDocument(a);
                if (!indexResponse.IsValid)
                {
                    _logger.LogError("Not valid document :(");
                    _logger.LogError(indexResponse.OriginalException.ToString());
                    _logger.LogError(indexResponse.DebugInformation.ToString());
                }
            }
        }