mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -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,
|
||||
RequestId = model.Id,
|
||||
RequestType = RequestType.TvShow,
|
||||
EpisodeCount = model.SeasonRequests.Select(m => m.Episodes.Count).Sum(),
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
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))
|
||||
.OrderBy(x => x.RequestDate)
|
||||
|
|
|
@ -88,8 +88,13 @@ namespace Ombi.Core.Rule.Rules.Request
|
|||
|
||||
// Count how many requests in the past 7 days
|
||||
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)
|
||||
{
|
||||
return Fail("You have exceeded your Episode request quota!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue