public static RedisKey GetQuarter(IDatabase database, string category, string action, DateTime dateTime)
{
// get the key
string quarter = BitwiseAnalytics.DateTimeUtil.QuarterNumber(dateTime);
RedisKey key = EventKey(category, action, quarter);
// return it if there's already data for this quarter
bool quarterExists = BitwiseAnalytics.Exists(database, key);
if (quarterExists)
{
return key;
}
// no data for the month, so we need to create it from the days
string[] monthsInQuarter = BitwiseAnalytics.DateTimeUtil.MonthsInQuarter(dateTime);
// make sure each day exists
foreach (string month in monthsInQuarter)
{
GetMonth(database, category, action, DateTime.ParseExact(month, "yyyyMM", CultureInfo.InvariantCulture));
}
// combine the days to form one month
BitwiseAnalytics.BitwiseOr(
database,
key,
monthsInQuarter.Select(x => EventKey(category, action, x)).ToArray());
return key;
}