♻️ Move most of models to the Shared package
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DysonNetwork.Sphere.Discovery;
|
||||
|
||||
public class DiscoveryService(AppDatabase appDatabase)
|
||||
{
|
||||
public Task<List<Realm.Realm>> GetPublicRealmsAsync(string? query,
|
||||
List<string>? tags,
|
||||
public Task<List<Shared.Models.Realm>> GetPublicRealmsAsync(string? query,
|
||||
int take = 10,
|
||||
int offset = 0,
|
||||
bool randomizer = false
|
||||
@ -20,13 +20,10 @@ public class DiscoveryService(AppDatabase appDatabase)
|
||||
realmsQuery = realmsQuery.Where(r => r.Name.Contains(query) || r.Description.Contains(query));
|
||||
}
|
||||
|
||||
if (tags is { Count: > 0 })
|
||||
realmsQuery = realmsQuery.Where(r => r.RealmTags.Any(rt => tags.Contains(rt.Tag.Name)));
|
||||
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