New: Add hour as interval unit for indexer limits

This commit is contained in:
Bogdan
2023-09-05 05:23:20 +03:00
parent d44b946d30
commit 96413f99c7
3 changed files with 61 additions and 22 deletions
@@ -7,20 +7,33 @@ namespace NzbDrone.Core.Indexers
{
public IndexerCommonSettingsValidator()
{
RuleFor(c => c.QueryLimit).GreaterThan(0).When(c => c.QueryLimit.HasValue).WithMessage("Should be greater than zero");
RuleFor(c => c.QueryLimit)
.GreaterThan(0)
.When(c => c.QueryLimit.HasValue)
.WithMessage("Should be greater than zero");
RuleFor(c => c.GrabLimit).GreaterThan(0).When(c => c.GrabLimit.HasValue).WithMessage("Should be greater than zero");
RuleFor(c => c.GrabLimit)
.GreaterThan(0)
.When(c => c.GrabLimit.HasValue)
.WithMessage("Should be greater than zero");
}
}
public class IndexerBaseSettings
{
private static readonly IndexerCommonSettingsValidator Validator = new ();
[FieldDefinition(1, Type = FieldType.Number, Label = "Query Limit", HelpText = "The number of queries within a rolling 24 hour period Prowlarr will allow to the site", Advanced = true)]
[FieldDefinition(1, Type = FieldType.Number, Label = "Query Limit", HelpText = "The number of max queries as specified by the respective unit that Prowlarr will allow to the site", Advanced = true)]
public int? QueryLimit { get; set; }
[FieldDefinition(2, Type = FieldType.Number, Label = "Grab Limit", HelpText = "The number of grabs within a rolling 24 hour period Prowlarr will allow to the site", Advanced = true)]
[FieldDefinition(2, Type = FieldType.Number, Label = "Grab Limit", HelpText = "The number of max grabs as specified by the respective unit that Prowlarr will allow to the site", Advanced = true)]
public int? GrabLimit { get; set; }
[FieldDefinition(3, Type = FieldType.Select, SelectOptions = typeof(IndexerLimitsUnit), Label = "Limits Unit", HelpText = "The unit of time for counting limits per indexer", Advanced = true)]
public int LimitsUnit { get; set; } = (int)IndexerLimitsUnit.Day;
}
public enum IndexerLimitsUnit
{
Day = 0,
Hour = 1
}
}