Exemplo n.º 1
0
        public IEnumerable <(int Year, TimeIdentifier TimeIdentifier)> GetTimePeriodRange(
            IQueryable <Observation> observations)
        {
            var timePeriods = GetDistinctObservationTimePeriods(observations).ToList();

            var start = timePeriods.First();
            var end   = timePeriods.Last();

            return(TimePeriodUtil.GetTimePeriodRange(start, end));
        }
Exemplo n.º 2
0
        private async Task <int> GetMaximumTableCellCount(ObservationQueryContext queryContext)
        {
            var filterItemIds = queryContext.Filters;
            var countsOfFilterItemsByFilter = filterItemIds == null
                ? new List <int>()
                : (await _filterItemRepository.CountFilterItemsByFilter(filterItemIds))
                                              .Select(pair =>
            {
                var(_, count) = pair;
                return(count);
            })
                                              .ToList();

            // TODO Accessing time periods for the Subject by altering the Importer to store them would improve accuracy
            // here rather than assuming the Subject has all time periods between the start and end range.

            return(TableBuilderUtils.MaximumTableCellCount(
                       countOfIndicators: queryContext.Indicators.Count(),
                       countOfLocations: queryContext.LocationIds.Count,
                       countOfTimePeriods: TimePeriodUtil.Range(queryContext.TimePeriod).Count,
                       countsOfFilterItemsByFilter: countsOfFilterItemsByFilter
                       ));
        }