mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-30 19:40:05 -07:00
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:
parent
847873c307
commit
364b9f11af
7 changed files with 87 additions and 20 deletions
18
src/Ombi.Helpers/DateTimeExtensions.cs
Normal file
18
src/Ombi.Helpers/DateTimeExtensions.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue