mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-17 15:36:50 +00:00
Fix allocated server not showing in applications search result
This commit is contained in:
parent
8223cc5822
commit
408b80badf
@ -23,7 +23,23 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
const searchResults = fuse.search(searchterm);
|
const searchResults = fuse.search(searchterm);
|
||||||
|
|
||||||
const results = searchResults.map(({ item }) => item);
|
const searchedApps = searchResults.map(({ item }) => item);
|
||||||
|
|
||||||
|
// Get server IDs from the search results
|
||||||
|
const serverIds = searchedApps
|
||||||
|
.map(app => app.serverId)
|
||||||
|
.filter((id): id is number => id !== null);
|
||||||
|
|
||||||
|
// Fetch server data for these applications
|
||||||
|
const servers = await prisma.server.findMany({
|
||||||
|
where: { id: { in: serverIds } }
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add server name to each application
|
||||||
|
const results = searchedApps.map(app => ({
|
||||||
|
...app,
|
||||||
|
server: servers.find(s => s.id === app.serverId)?.name || "No server"
|
||||||
|
}));
|
||||||
|
|
||||||
return NextResponse.json({ results });
|
return NextResponse.json({ results });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user