diff options
| author | Jake Mannens <jake@asger.xyz> | 2023-08-28 23:37:48 +1000 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2025-08-20 00:48:43 +1000 |
| commit | 2051c758477b68fea0f2d10b75d0d54430ab096a (patch) | |
| tree | 16159a8ac40a480a9d8ad386d319be1c52c37145 /Pages/Component | |
| parent | 4d99476480a6c73a21ab29e74676403a1f4072fd (diff) | |
Massive DB performance improvement when filtering NSFW content
Diffstat (limited to 'Pages/Component')
| -rw-r--r-- | Pages/Component/TagSelectDialog.razor | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Pages/Component/TagSelectDialog.razor b/Pages/Component/TagSelectDialog.razor index 3c30305..e6e78a4 100644 --- a/Pages/Component/TagSelectDialog.razor +++ b/Pages/Component/TagSelectDialog.razor @@ -84,14 +84,20 @@ var selected = SelectedTags.Select(td => td.Guid); + int[] nsfwTags = Array.Empty<int>(); + if(!userService.ShowNsfw) + nsfwTags = tagService.TagsThatImply(HBContext.NsfwTag) + .Select(td => td.ObjectId) + .ToArray(); + tagDefinitions = db.TagDefinitions + .Include(td => td.ImplicitTags) .Where(td => td.Source == TagSource.UserTag) .OrderBy(td => td.Name) .AsEnumerable() - .Where(td => userService.ShowNsfw || !tagService - .GetAllTags(td) - .Select(e => e.tagDefinition.Guid) - .Contains(HBContext.NsfwTag)) + .Where(td => userService.ShowNsfw || !td.ImplicitTags + .IntersectBy(nsfwTags, td => td.ObjectId) + .Any()) .Select(td => new Tuple<TagDefinition, bool>( td, selected.Contains(td.Guid)).ToValueTuple()) |
