feat(request-limits): Request limits are no longer a rolling date. But reset at the start of the week or month depending on the preference

This commit is contained in:
tidusjar 2021-09-22 21:49:28 +01:00
parent 847873c307
commit 364b9f11af
7 changed files with 87 additions and 20 deletions

View file

@ -0,0 +1,18 @@
using System;
using System.Threading;
namespace Ombi.Helpers
{
public static class DateTimeExtensions
{
public static DateTime FirstDateInWeek(this DateTime dt)
{
while (dt.DayOfWeek != Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek)
{
dt = dt.AddDays(-1);
}
return dt;
}
}
}

View file

@ -32,7 +32,7 @@ namespace Ombi.Helpers
}
// Not in the cache, so add this Key into our MediaServiceCache
await UpdateLocalCache(cacheKey);
UpdateLocalCache(cacheKey);
return await _memoryCache.GetOrCreateAsync<T>(cacheKey, entry =>
{
@ -41,7 +41,7 @@ namespace Ombi.Helpers
});
}
private async Task UpdateLocalCache(string cacheKey)
private void UpdateLocalCache(string cacheKey)
{
var mediaServiceCache = _memoryCache.Get<List<string>>(CacheKey);
if (mediaServiceCache == null)