Checkpoint: Ajout de badges Actif/Inactif dans la liste des apprenants et création d'une page dédiée aux établissements avec statistiques de participation
This commit is contained in:
19
server/db.ts
19
server/db.ts
@@ -280,7 +280,24 @@ export async function getApprenants() {
|
||||
const db = await getDb();
|
||||
if (!db) return [];
|
||||
|
||||
return await db.select().from(apprenants);
|
||||
const apprenantsData = await db.select().from(apprenants);
|
||||
|
||||
// Pour chaque apprenant, récupérer ses inscriptions
|
||||
const apprenantsWithInscriptions = await Promise.all(
|
||||
apprenantsData.map(async (apprenant) => {
|
||||
const inscriptionsData = await db
|
||||
.select()
|
||||
.from(inscriptions)
|
||||
.where(eq(inscriptions.apprenantId, apprenant.id));
|
||||
|
||||
return {
|
||||
...apprenant,
|
||||
inscriptions: inscriptionsData,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return apprenantsWithInscriptions;
|
||||
}
|
||||
|
||||
export async function getApprenantById(id: number): Promise<Apprenant | undefined> {
|
||||
|
||||
Reference in New Issue
Block a user