Fixed: Calculate movie availability comparing UTC dates

pull/10263/head
Bogdan 4 months ago committed by Qstick
parent 04c5e6c2a6
commit 44c7c71226

@ -7,12 +7,12 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
{
public class AvailabilitySpecification : IDecisionEngineSpecification
{
private readonly IConfigService _settingsService;
private readonly IConfigService _configService;
private readonly Logger _logger;
public AvailabilitySpecification(IConfigService settingsService, Logger logger)
public AvailabilitySpecification(IConfigService configService, Logger logger)
{
_settingsService = settingsService;
_configService = configService;
_logger = logger;
}
@ -21,18 +21,17 @@ namespace NzbDrone.Core.DecisionEngine.Specifications.RssSync
public Decision IsSatisfiedBy(RemoteMovie subject, SearchCriteriaBase searchCriteria)
{
if (searchCriteria != null)
{
if (searchCriteria.UserInvokedSearch)
if (searchCriteria is { UserInvokedSearch: true })
{
_logger.Debug("Skipping availability check during search");
return Decision.Accept();
}
}
if (!subject.Movie.IsAvailable(_settingsService.AvailabilityDelay))
var availabilityDelay = _configService.AvailabilityDelay;
if (!subject.Movie.IsAvailable(availabilityDelay))
{
return Decision.Reject("Movie {0} will only be considered available {1} days after {2}", subject.Movie, _settingsService.AvailabilityDelay, subject.Movie.MinimumAvailability.ToString());
return Decision.Reject("Movie {0} will only be considered available {1} days after {2}", subject.Movie, availabilityDelay, subject.Movie.MinimumAvailability.ToString());
}
return Decision.Accept();

@ -81,7 +81,7 @@ namespace NzbDrone.Core.Movies
// This more complex sequence handles the delay
DateTime minimumAvailabilityDate;
if ((MinimumAvailability == MovieStatusType.TBA) || (MinimumAvailability == MovieStatusType.Announced))
if (MinimumAvailability is MovieStatusType.TBA or MovieStatusType.Announced)
{
minimumAvailabilityDate = DateTime.MinValue;
}
@ -105,16 +105,16 @@ namespace NzbDrone.Core.Movies
}
else
{
minimumAvailabilityDate = MovieMetadata.Value.InCinemas.HasValue ? MovieMetadata.Value.InCinemas.Value.AddDays(90) : DateTime.MaxValue;
minimumAvailabilityDate = MovieMetadata.Value.InCinemas?.AddDays(90) ?? DateTime.MaxValue;
}
}
if (minimumAvailabilityDate == DateTime.MinValue || minimumAvailabilityDate == DateTime.MaxValue)
{
return DateTime.Now >= minimumAvailabilityDate;
return DateTime.UtcNow >= minimumAvailabilityDate;
}
return DateTime.Now >= minimumAvailabilityDate.AddDays((double)delay);
return DateTime.UtcNow >= minimumAvailabilityDate.AddDays(delay);
}
public override string ToString()

Loading…
Cancel
Save