Skip to content

Commit

Permalink
fix: search all group names
Browse files Browse the repository at this point in the history
  • Loading branch information
revam committed Oct 31, 2024
1 parent 62c49b1 commit 6c2cebf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Shoko.Server/Filters/FilterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public static Filterable ToFilterable(this SVR_AnimeSeries series)
NamesDelegate = () =>
{
var titles = series.Titles.Select(t => t.Title).ToHashSet();
var group = series.AnimeGroup;
if (group is not null)
foreach (var group in series.AllGroupsAbove)
titles.Add(group.GroupName);

return titles;
Expand Down Expand Up @@ -180,6 +179,8 @@ public static Filterable ToFilterable(this SVR_AnimeGroup group)
NamesDelegate = () =>
{
var result = new HashSet<string>() { group.GroupName };
foreach (var grp in group.AllGroupsAbove)
result.Add(grp.GroupName);
result.UnionWith(series.SelectMany(a => a.Titles.Select(t => t.Title)));
return result;
},
Expand Down
24 changes: 24 additions & 0 deletions Shoko.Server/Models/SVR_AnimeGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ public string SortName

public SVR_AnimeGroup? Parent => AnimeGroupParentID.HasValue ? RepoFactory.AnimeGroup.GetByID(AnimeGroupParentID.Value) : null;

public List<SVR_AnimeGroup> AllGroupsAbove
{
get
{
var allGroupsAbove = new List<SVR_AnimeGroup>();
var groupID = AnimeGroupParentID;
while (groupID.HasValue && groupID.Value != 0)
{
var grp = RepoFactory.AnimeGroup.GetByID(groupID.Value);
if (grp != null)
{
allGroupsAbove.Add(grp);
groupID = grp.AnimeGroupParentID;
}
else
{
groupID = 0;
}
}

return allGroupsAbove;
}
}

public List<SVR_AniDB_Anime> Anime =>
RepoFactory.AnimeSeries.GetByGroupID(AnimeGroupID).Select(s => s.AniDB_Anime).WhereNotNull().ToList();

Expand Down

0 comments on commit 6c2cebf

Please sign in to comment.