private (byte[] Hash, int Count) GetContainerMonthsHash(IContainer container, DateTimeOffset beforeMoment) { var beforeMomentMonth = _contentMonthProvider.GetContentMonth(beforeMoment); var persistedMonthHashAndCounts = _contentsMonthHashRepository.GetMonthHashAndCounts(_containerName) .OrderBy(x => x.Month) .ToList(); var persistedPastMonthHashAndCounts = persistedMonthHashAndCounts .Where(x => x.Month < beforeMomentMonth) .ToList(); var lastPersistedPastMonth = persistedPastMonthHashAndCounts.Select(x => (DateTimeOffset?)x.Month).LastOrDefault(); var nextContentIdentifiers = GetChronologicallyOrderedContentIdentifiers(null, beforeMoment, lastPersistedPastMonth?.AddMonths(1).AddTicks(-1)); var nextMonthHashAndCounts = _contentsMonthHashProvider.GetMonthHashAndCounts(nextContentIdentifiers).ToList(); AddMissingMonthHashAndCounts(nextMonthHashAndCounts); var allMonthHashAndCounts = persistedPastMonthHashAndCounts.Concat(nextMonthHashAndCounts); return(_hashProvider.GetHashAndCount(allMonthHashAndCounts.Select(x => (x.Hash, x.Count)))); }
public IEnumerable <IMonthHashAndCount> GetMonthHashAndCounts(IEnumerable <IContentIdentifier> contentIdentifiers) { return (contentIdentifiers .Where(x => !_contentIdentifierGenerator.IsSystemContent(x)) .GroupBy(x => _contentMonthProvider.GetContentMonth(x.ModifiedMoment)) .Select(x => new { Month = x.Key, HashAndCount = _hashProvider.GetHashAndCount( x.OrderBy(y => y.ModifiedMoment) .ThenBy(y => y.Guid) .Select(y => Encoding.Unicode.GetBytes(y.Hash)) ), LastModifiedMoment = x.Max(y => y.ModifiedMoment) }) .OrderBy(x => x.Month) .Select(x => _monthHashAndCountFactory(x.Month, x.HashAndCount.Hash, x.HashAndCount.Count, x.LastModifiedMoment))); }
public void AddContent(string contentsContainerName, string contentName, DateTimeOffset contentDate, CancellationToken cancellationToken) { AddContents(contentsContainerName, new[] { contentName }, _contentMonthProvider.GetContentMonth(contentDate), null, false, cancellationToken); }