summaryrefslogtreecommitdiff
path: root/Pages/Component
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-08-28 23:37:48 +1000
committerJake Mannens <jake@asger.xyz>2023-08-28 23:40:01 +1000
commitc0bd2167f5f542b48a2187d392c1a0c7f93e903f (patch)
treec9f92c9d669958b62bd8ce269827c89dabb909a8 /Pages/Component
parent3d386ae5ed09e65775b5bd579b4a1f764fbf9c2c (diff)
Massive DB performance improvement when filtering NSFW content
Diffstat (limited to 'Pages/Component')
-rw-r--r--Pages/Component/TagSelectDialog.razor14
1 files changed, 10 insertions, 4 deletions
diff --git a/Pages/Component/TagSelectDialog.razor b/Pages/Component/TagSelectDialog.razor
index f21d570..9008cc8 100644
--- a/Pages/Component/TagSelectDialog.razor
+++ b/Pages/Component/TagSelectDialog.razor
@@ -76,14 +76,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())