From d866d360d9b48f246d9a734ac6ecdf2e5a884644 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sat, 20 Apr 2024 02:14:15 +0200 Subject: [PATCH] [backend/core] Refactor home timeline heuristic helper function --- .../Core/Extensions/QueryableExtensions.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs index 6bb28bc9..85a5e521 100644 --- a/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs @@ -241,15 +241,14 @@ public static class QueryableExtensions // Determined empirically in 2023. Ask zotan for the spreadsheet if you're curious. const int cutoff = 250; - if (heuristic < cutoff) - return query.Where(note => db.Users - .First(p => p == user) - .Following - .Select(p => p.Id) - .Concat(new[] { user.Id }) - .Contains(note.UserId)); - - return query.Where(note => note.User == user || note.User.IsFollowedBy(user)); + return heuristic < cutoff + ? query.Where(note => db.Users + .First(p => p == user) + .Following + .Select(p => p.Id) + .Concat(new[] { user.Id }) + .Contains(note.UserId)) + : query.Where(note => note.User == user || note.User.IsFollowedBy(user)); } //TODO: move this into another class where it makes more sense