[backend/core] Refactor home timeline heuristic helper function

This commit is contained in:
Laura Hausmann 2024-04-20 02:14:15 +02:00
parent 0784425f6d
commit d866d360d9
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -241,15 +241,14 @@ public static class QueryableExtensions
// Determined empirically in 2023. Ask zotan for the spreadsheet if you're curious. // Determined empirically in 2023. Ask zotan for the spreadsheet if you're curious.
const int cutoff = 250; const int cutoff = 250;
if (heuristic < cutoff) return heuristic < cutoff
return query.Where(note => db.Users ? query.Where(note => db.Users
.First(p => p == user) .First(p => p == user)
.Following .Following
.Select(p => p.Id) .Select(p => p.Id)
.Concat(new[] { user.Id }) .Concat(new[] { user.Id })
.Contains(note.UserId)); .Contains(note.UserId))
: query.Where(note => note.User == user || note.User.IsFollowedBy(user));
return query.Where(note => note.User == user || note.User.IsFollowedBy(user));
} }
//TODO: move this into another class where it makes more sense //TODO: move this into another class where it makes more sense