[backend/core] Move FilterByFollowingAndOwn back into QueryableExtensions
This commit is contained in:
parent
a0aa632bf4
commit
c290c546f4
2 changed files with 11 additions and 31 deletions
|
@ -259,6 +259,17 @@ public static class QueryableExtensions
|
|||
return query.Where(note => note.Visibility == visibility);
|
||||
}
|
||||
|
||||
public static IQueryable<Note> FilterByFollowingAndOwn(
|
||||
this IQueryable<Note> query, User user, DatabaseContext db
|
||||
)
|
||||
{
|
||||
return query.Where(note => db.Followings
|
||||
.Where(p => p.Follower == user)
|
||||
.Select(p => p.FolloweeId)
|
||||
.Concat(new[] { user.Id })
|
||||
.Contains(note.UserId));
|
||||
}
|
||||
|
||||
public static IQueryable<Note> FilterByUser(this IQueryable<Note> query, User user)
|
||||
{
|
||||
return query.Where(note => note.User == user);
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using Iceshrimp.Backend.Core.Database;
|
||||
using Iceshrimp.Backend.Core.Database.Tables;
|
||||
using Iceshrimp.Backend.Core.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Iceshrimp.Backend.Core.Extensions;
|
||||
|
||||
public static class QueryableTimelineExtensions
|
||||
{
|
||||
// Determined empirically in 2023. Ask zotan for the spreadsheet if you're curious.
|
||||
private const int Cutoff = 250;
|
||||
|
||||
public static IQueryable<Note> FilterByFollowingAndOwn(
|
||||
this IQueryable<Note> query, User user, DatabaseContext db
|
||||
)
|
||||
{
|
||||
return query.Where(note => db.Followings
|
||||
.Where(p => p.Follower == user)
|
||||
.Select(p => p.FolloweeId)
|
||||
.Concat(new[] { user.Id })
|
||||
.Contains(note.UserId));
|
||||
}
|
||||
|
||||
private static IQueryable<Note> FollowingAndOwnLowFreq(this IQueryable<Note> query, User user, DatabaseContext db)
|
||||
=> query.Where(note => db.Followings
|
||||
.Where(p => p.Follower == user)
|
||||
.Select(p => p.FolloweeId)
|
||||
.Concat(new[] { user.Id })
|
||||
.Contains(note.UserId));
|
||||
}
|
Loading…
Add table
Reference in a new issue