💄 Optimize discovery search
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace DysonNetwork.Sphere.Discovery;
|
namespace DysonNetwork.Sphere.Discovery;
|
||||||
|
|
||||||
public class DiscoveryService(AppDatabase appDatabase)
|
public class DiscoveryService(AppDatabase appDatabase)
|
||||||
@@ -16,10 +17,10 @@ public class DiscoveryService(AppDatabase appDatabase)
|
|||||||
.Where(r => r.IsCommunity);
|
.Where(r => r.IsCommunity);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(query))
|
if (!string.IsNullOrEmpty(query))
|
||||||
{
|
realmsQuery = realmsQuery.Where(r =>
|
||||||
realmsQuery = realmsQuery.Where(r => r.Name.Contains(query) || r.Description.Contains(query));
|
EF.Functions.ILike(r.Name, $"%{query}%") ||
|
||||||
}
|
EF.Functions.ILike(r.Description, $"%{query}%")
|
||||||
|
);
|
||||||
if (tags is { Count: > 0 })
|
if (tags is { Count: > 0 })
|
||||||
realmsQuery = realmsQuery.Where(r => r.RealmTags.Any(rt => tags.Contains(rt.Tag.Name)));
|
realmsQuery = realmsQuery.Where(r => r.RealmTags.Any(rt => tags.Contains(rt.Tag.Name)));
|
||||||
if (randomizer)
|
if (randomizer)
|
||||||
@@ -29,4 +30,4 @@ public class DiscoveryService(AppDatabase appDatabase)
|
|||||||
|
|
||||||
return realmsQuery.Skip(offset).Take(take).ToListAsync();
|
return realmsQuery.Skip(offset).Take(take).ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user