Optimize database calls across multiple components by implementing Promise.all for parallel fetching of data, enhancing performance and reducing loading times.
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m40s

This commit is contained in:
Julien Froidefond
2025-12-16 11:19:54 +01:00
parent a9a4120874
commit ffbf3cd42f
8 changed files with 162 additions and 120 deletions

View File

@@ -7,7 +7,11 @@ import { getBackgroundImage } from "@/lib/preferences";
export const dynamic = "force-dynamic";
export default async function Home() {
const events = await eventService.getUpcomingEvents(3);
// Paralléliser les appels DB
const [events, backgroundImage] = await Promise.all([
eventService.getUpcomingEvents(3),
getBackgroundImage("home", "/got-2.jpg"),
]);
// Convert Date objects to strings for serialization
const serializedEvents = events.map((event) => ({
@@ -15,9 +19,6 @@ export default async function Home() {
date: event.date.toISOString(),
}));
// Récupérer l'image de fond côté serveur
const backgroundImage = await getBackgroundImage("home", "/got-2.jpg");
return (
<main className="min-h-screen bg-black relative">
<NavigationWrapper />