-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add import folder filters (#1184)
Add two new filters to filter by import folder IDs or names. Both are implemented as string sets because I didn't want to add a new filter category for number sets for the IDs. Fixes #958.
- Loading branch information
Showing
6 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
Shoko.Server/Filters/Selectors/StringSetSelectors/ImportFolderIDsSelector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System.Collections.Generic; | ||
using Shoko.Server.Filters.Interfaces; | ||
|
||
namespace Shoko.Server.Filters.Selectors.StringSetSelectors; | ||
|
||
public class ImportFolderIDsSelector : FilterExpression<IReadOnlySet<string>> | ||
{ | ||
public override bool TimeDependent => false; | ||
public override bool UserDependent => false; | ||
public override string HelpDescription => "This returns a set of the import folder IDs in a filterable"; | ||
public override FilterExpressionGroup Group => FilterExpressionGroup.Selector; | ||
|
||
public override IReadOnlySet<string> Evaluate(IFilterable filterable, IFilterableUserInfo userInfo) | ||
{ | ||
return filterable.ImportFolderIDs; | ||
} | ||
|
||
protected bool Equals(ImportFolderIDsSelector other) | ||
{ | ||
return base.Equals(other); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, obj)) | ||
{ | ||
return true; | ||
} | ||
|
||
if (obj.GetType() != this.GetType()) | ||
{ | ||
return false; | ||
} | ||
|
||
return Equals((ImportFolderIDsSelector)obj); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return GetType().FullName!.GetHashCode(); | ||
} | ||
|
||
public static bool operator ==(ImportFolderIDsSelector left, ImportFolderIDsSelector right) | ||
{ | ||
return Equals(left, right); | ||
} | ||
|
||
public static bool operator !=(ImportFolderIDsSelector left, ImportFolderIDsSelector right) | ||
{ | ||
return !Equals(left, right); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
Shoko.Server/Filters/Selectors/StringSetSelectors/ImportFolderNamesSelector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System.Collections.Generic; | ||
using Shoko.Server.Filters.Interfaces; | ||
|
||
namespace Shoko.Server.Filters.Selectors.StringSetSelectors; | ||
|
||
public class ImportFolderNamesSelector : FilterExpression<IReadOnlySet<string>> | ||
{ | ||
public override bool TimeDependent => false; | ||
public override bool UserDependent => false; | ||
public override string HelpDescription => "This returns a set of the import folder names in a filterable"; | ||
public override FilterExpressionGroup Group => FilterExpressionGroup.Selector; | ||
|
||
public override IReadOnlySet<string> Evaluate(IFilterable filterable, IFilterableUserInfo userInfo) | ||
{ | ||
return filterable.ImportFolderNames; | ||
} | ||
|
||
protected bool Equals(ImportFolderNamesSelector other) | ||
{ | ||
return base.Equals(other); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, obj)) | ||
{ | ||
return true; | ||
} | ||
|
||
if (obj.GetType() != this.GetType()) | ||
{ | ||
return false; | ||
} | ||
|
||
return Equals((ImportFolderNamesSelector)obj); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return GetType().FullName!.GetHashCode(); | ||
} | ||
|
||
public static bool operator ==(ImportFolderNamesSelector left, ImportFolderNamesSelector right) | ||
{ | ||
return Equals(left, right); | ||
} | ||
|
||
public static bool operator !=(ImportFolderNamesSelector left, ImportFolderNamesSelector right) | ||
{ | ||
return !Equals(left, right); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters