mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-13 08:42:57 -07:00
Fix bug with TV requests in which requesting a seasion would treat request as single episode
This commit is contained in:
parent
c5e396a9e8
commit
b7e5e3dfb4
2 changed files with 14 additions and 3 deletions
|
@ -609,6 +609,7 @@ namespace Ombi.Core.Engine
|
||||||
RequestDate = DateTime.UtcNow,
|
RequestDate = DateTime.UtcNow,
|
||||||
RequestId = model.Id,
|
RequestId = model.Id,
|
||||||
RequestType = RequestType.TvShow,
|
RequestType = RequestType.TvShow,
|
||||||
|
EpisodeCount = model.SeasonRequests.Select(m => m.Episodes.Count).Sum(),
|
||||||
});
|
});
|
||||||
|
|
||||||
return new RequestEngineResult { Result = true };
|
return new RequestEngineResult { Result = true };
|
||||||
|
@ -632,7 +633,12 @@ namespace Ombi.Core.Engine
|
||||||
|
|
||||||
IQueryable<RequestLog> log = _requestLog.GetAll().Where(x => x.UserId == user.Id && x.RequestType == RequestType.TvShow);
|
IQueryable<RequestLog> log = _requestLog.GetAll().Where(x => x.UserId == user.Id && x.RequestType == RequestType.TvShow);
|
||||||
|
|
||||||
int count = limit - await log.CountAsync(x => x.RequestDate >= DateTime.UtcNow.AddDays(-7));
|
// Needed, due to a bug which would cause all episode counts to be 0
|
||||||
|
int zeroEpisodeCount = await log.Where(x => x.EpisodeCount == 0).Select(x => x.EpisodeCount).CountAsync();
|
||||||
|
|
||||||
|
int episodeCount = await log.Where(x => x.EpisodeCount != 0).Select(x => x.EpisodeCount).SumAsync();
|
||||||
|
|
||||||
|
int count = limit - (zeroEpisodeCount + episodeCount);
|
||||||
|
|
||||||
DateTime oldestRequestedAt = await log.Where(x => x.RequestDate >= DateTime.UtcNow.AddDays(-7))
|
DateTime oldestRequestedAt = await log.Where(x => x.RequestDate >= DateTime.UtcNow.AddDays(-7))
|
||||||
.OrderBy(x => x.RequestDate)
|
.OrderBy(x => x.RequestDate)
|
||||||
|
|
|
@ -88,8 +88,13 @@ namespace Ombi.Core.Rule.Rules.Request
|
||||||
|
|
||||||
// Count how many requests in the past 7 days
|
// Count how many requests in the past 7 days
|
||||||
var tv = tvLogs.Where(x => x.RequestDate >= DateTime.UtcNow.AddDays(-7));
|
var tv = tvLogs.Where(x => x.RequestDate >= DateTime.UtcNow.AddDays(-7));
|
||||||
var count = await tv.Select(x => x.EpisodeCount).CountAsync();
|
|
||||||
count += requestCount; // Add the amount of requests in
|
// Needed, due to a bug which would cause all episode counts to be 0
|
||||||
|
var zeroEpisodeCount = await tv.Where(x => x.EpisodeCount == 0).Select(x => x.EpisodeCount).CountAsync();
|
||||||
|
|
||||||
|
var episodeCount = await tv.Where(x => x.EpisodeCount != 0).Select(x => x.EpisodeCount).SumAsync();
|
||||||
|
|
||||||
|
var count = requestCount + episodeCount + zeroEpisodeCount; // Add the amount of requests in
|
||||||
if (count > episodeLimit)
|
if (count > episodeLimit)
|
||||||
{
|
{
|
||||||
return Fail("You have exceeded your Episode request quota!");
|
return Fail("You have exceeded your Episode request quota!");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue