🐛 Trying to fix discovery
This commit is contained in:
@@ -13,6 +13,6 @@ public class DiscoveryController(DiscoveryService discoveryService) : Controller
|
||||
[FromQuery] int offset = 0
|
||||
)
|
||||
{
|
||||
return discoveryService.GetPublicRealmsAsync(query, take, offset);
|
||||
return discoveryService.GetCommunityRealmAsync(query, take, offset);
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ namespace DysonNetwork.Sphere.Discovery;
|
||||
|
||||
public class DiscoveryService(AppDatabase appDatabase)
|
||||
{
|
||||
public Task<List<Realm.Realm>> GetPublicRealmsAsync(
|
||||
public Task<List<Realm.Realm>> GetCommunityRealmAsync(
|
||||
string? query,
|
||||
int take = 10,
|
||||
int offset = 0,
|
||||
@@ -12,19 +12,18 @@ public class DiscoveryService(AppDatabase appDatabase)
|
||||
)
|
||||
{
|
||||
var realmsQuery = appDatabase.Realms
|
||||
.Take(take)
|
||||
.Skip(offset)
|
||||
.Where(r => r.IsCommunity);
|
||||
.Where(r => r.IsCommunity)
|
||||
.OrderByDescending(r => r.CreatedAt)
|
||||
.AsQueryable();
|
||||
|
||||
if (!string.IsNullOrEmpty(query))
|
||||
realmsQuery = realmsQuery.Where(r =>
|
||||
EF.Functions.ILike(r.Name, $"%{query}%") ||
|
||||
EF.Functions.ILike(r.Description, $"%{query}%")
|
||||
);
|
||||
if (randomizer)
|
||||
realmsQuery = realmsQuery.OrderBy(r => EF.Functions.Random());
|
||||
else
|
||||
realmsQuery = realmsQuery.OrderByDescending(r => r.CreatedAt);
|
||||
realmsQuery = randomizer
|
||||
? realmsQuery.OrderBy(r => EF.Functions.Random())
|
||||
: realmsQuery.OrderByDescending(r => r.CreatedAt);
|
||||
|
||||
return realmsQuery.Skip(offset).Take(take).ToListAsync();
|
||||
}
|
||||
|
Reference in New Issue
Block a user