public static RedisKey GetDay(IDatabase database, string category, string action, DateTime dateTime)
{
// get the key
string day = BitwiseAnalytics.DateTimeUtil.OneDay(dateTime);
RedisKey key = EventKey(category, action, day);
// return it if there's already data for this day
bool dayExists = BitwiseAnalytics.Exists(database, key);
if (dayExists)
{
return key;
}
// no data for the day, so we need to create it from the hours
string[] hoursInDay = BitwiseAnalytics.DateTimeUtil.HoursInDay(dateTime);
// make sure each hour exists
foreach (string hour in hoursInDay)
{
GetHour(database, category, action, DateTime.ParseExact(hour, "yyyyMMddHH", CultureInfo.InvariantCulture));
}
// combine the hours to form one day
BitwiseAnalytics.BitwiseOr(
database,
key,
hoursInDay.Select(x => EventKey(category, action, x)).ToArray());
return key;
}