feat : fix a lot of stuff
Check Deno code / Check Deno code (pull_request) Failing after 8s
Tests / Unit tests (pull_request) Successful in 13s
Tests / Integration tests (pull_request) Failing after 1m0s

This commit is contained in:
2026-04-30 13:49:47 +02:00
parent 04be659d6b
commit df3957741d
50 changed files with 2664 additions and 437 deletions
@@ -64,13 +64,39 @@ export const handler: Handlers = {
}
const body = await request.json();
const { note } = body;
const { note, noteSession2 } = body;
if (note === undefined) {
return new Response("Champ 'note' manquant", { status: 400 });
if (note === undefined && noteSession2 === undefined) {
return new Response("Au moins 'note' ou 'noteSession2' requis", {
status: 400,
});
}
const result = await db.update(notes).set({ note }).where(
if (
note !== undefined &&
(typeof note !== "number" || note < 0 || note > 20)
) {
return new Response("Champ 'note' doit être un nombre entre 0 et 20", {
status: 400,
});
}
if (
noteSession2 !== undefined && noteSession2 !== null &&
(typeof noteSession2 !== "number" || noteSession2 < 0 ||
noteSession2 > 20)
) {
return new Response(
"Champ 'noteSession2' doit être un nombre entre 0 et 20",
{ status: 400 },
);
}
const set: { note?: number; noteSession2?: number | null } = {};
if (note !== undefined) set.note = note;
if (noteSession2 !== undefined) set.noteSession2 = noteSession2;
const result = await db.update(notes).set(set).where(
and(
eq(notes.numEtud, numEtud),
eq(notes.idModule, idModule),
+21 -3
View File
@@ -26,20 +26,38 @@ export const handler: Handlers = {
const rows = XLSX.utils.sheet_to_json(sheet) as {
numEtud: number;
note: number;
noteSession2?: number;
}[];
for (const row of rows) {
const { numEtud, note } = row;
const { numEtud, note, noteSession2 } = row;
if (!numEtud || note === undefined) {
continue;
}
const values: {
numEtud: number;
idModule: string;
note: number;
noteSession2?: number | null;
} = {
numEtud,
idModule,
note,
};
const set: { note: number; noteSession2?: number | null } = { note };
if (noteSession2 !== undefined) {
values.noteSession2 = noteSession2;
set.noteSession2 = noteSession2;
}
await db.insert(notes)
.values({ numEtud, idModule, note })
.values(values)
.onConflictDoUpdate({
target: [notes.numEtud, notes.idModule],
set: { note },
set,
});
}