Exemplo n.º 1
0
        private static IEnumerable <(ValueCounts, IGrouping <string, GroupingSetsResult <DateTime> >)> ProcessLinearBuckets(
            IEnumerable <GroupingSetsResult <DateTime> > queryResult)
        {
            foreach (var group in TimeUtilities.GroupByLabel(queryResult))
            {
                var counts = ValueCounts.Compute(group);
                if (counts.SuppressedRowRatio > SuppressedRatioThreshold)
                {
                    break;
                }

                yield return(counts, group);
            }
        }
Exemplo n.º 2
0
        private static IEnumerable <(ValueCounts, IGrouping <string, GroupingSetsResult <int> >)> ProcessCyclicalBuckets(
            IEnumerable <GroupingSetsResult <int> > queryResult)
        {
            // Always skip years because they are never cyclical
            var skip = true;

            foreach (var group in TimeUtilities.GroupByLabel(queryResult.OrderBy(r => r.GroupingIndex)))
            {
                if (skip)
                {
                    var distinctValueCount = group.Count(row => row.HasValue);

                    // If we haven't completed at least two full cycles of the current time period,
                    // skip the next time period.
                    // Once we have a cycle, we include all the remaining time periods (ie. we stop skipping).
                    skip = (group.Key, distinctValueCount) switch
                    {
                        // Quarters cycle every year
                        ("year", var count)when count > 2 => false,

                        // Months cycle every four quarters
                        ("quarter", var count)when count > 8 => false,

                        // Days cycle every month
                        ("month", var count)when count > 2 => false,

                        // Weekdays cycle every 7 days
                        ("day", var count)when count > 14 => false,

                        // Hours cycle every weekday
                        ("weekday", var count)when count > 2 => false,

                        // Minutes cycle every hour
                        ("hour", var count)when count > 2 => false,

                        // Seconds cycle every Minute
                        ("minute", var count)when count > 2 => false,

                        ("second", var count)when count > 2 => false,
                        _ => true,
                    };
                }