public static async Task<RedisKey> GetHourAsync(
IDatabase database, string category, string action, DateTime dateTime)
{
// get the key
string hour = BitwiseAnalytics.DateTimeUtil.OneHour(dateTime);
RedisKey key = EventKey(category, action, hour);
// return it if there's already data for this hour
bool hourExists = await BitwiseAnalytics.ExistsAsync(database, key);
if (hourExists)
{
return key;
}
// no data for the hour, so we need to create it from the 15 minute intervals
string[] fifteenMinutesInHour = BitwiseAnalytics.DateTimeUtil.FifteenMinutesInHour(dateTime);
await BitwiseAnalytics.BitwiseOrAsync(
database,
key,
fifteenMinutesInHour.Select(x => EventKey(category, action, x)).ToArray());
return key;
}