BB.Caching.Redis.Analytics.BitwiseAnalytics.GetMinKeysForRange C# (CSharp) Method

GetMinKeysForRange() public static method

Gets the fewest number of keys required to cover the date range supplied.
public static GetMinKeysForRange ( IDatabase database, string category, string action, System.DateTime start, System.DateTime end, TimeInterval timeInterval = TimeInterval.FifteenMinutes ) : RedisKey[]
database IDatabase /// The database where the query will be performed. This is passed so that we can reuse the same database to /// perform multiple bitwise operations. Doing this with the same connection will guarantee that performance /// is good. ///
category string /// Typically the object that was interacted with (e.g. button) ///
action string /// The type of interaction (e.g. click) ///
start System.DateTime /// The starting DateTime, inclusive. ///
end System.DateTime /// The ending DateTime, exclusive. ///
timeInterval TimeInterval /// The accuracy at which we want the data. For example, setting this to TimeInterval.OneDay means there won't /// be any keys at the fifteen minute or one hour levels, so if the DateTime is for the /// middle of a day, it'll include the entire day. ///
return RedisKey[]
        public static RedisKey[] GetMinKeysForRange(
            IDatabase database,
            string category,
            string action,
            DateTime start,
            DateTime end,
            TimeInterval timeInterval = TimeInterval.FifteenMinutes)
        {
            Tuple<TimeInterval, string, DateTime>[] requiredKeys = DateTimeUtil.MinKeysForRange(start, end, timeInterval);
            RedisKey[] keys = new RedisKey[requiredKeys.Length];
            int keyIndex = 0;

            foreach (var tup in requiredKeys)
            {
                switch (tup.Item1)
                {
                    case TimeInterval.FifteenMinutes:
                    {
                        keys[keyIndex] = GetFifteenMinutes(category, action, tup.Item3);
                        break;
                    }

                    case TimeInterval.OneHour:
                    {
                        keys[keyIndex] = GetHour(database, category, action, tup.Item3);
                        break;
                    }

                    case TimeInterval.OneDay:
                    {
                        keys[keyIndex] = GetDay(database, category, action, tup.Item3);
                        break;
                    }

                    case TimeInterval.Week:
                    {
                        keys[keyIndex] = GetWeek(database, category, action, tup.Item3);
                        break;
                    }

                    case TimeInterval.OneMonth:
                    {
                        keys[keyIndex] = GetMonth(database, category, action, tup.Item3);
                        break;
                    }

                    case TimeInterval.Quarter:
                    {
                        keys[keyIndex] = GetQuarter(database, category, action, tup.Item3);
                        break;
                    }
                }

                keyIndex += 1;
            }

            return keys;
        }