Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b8d359a507 | |||
| 32ffbb7cda |
+9
-10
@@ -1,9 +1,9 @@
|
|||||||
import {
|
import {
|
||||||
date,
|
date,
|
||||||
|
doublePrecision,
|
||||||
integer,
|
integer,
|
||||||
pgTable,
|
pgTable,
|
||||||
primaryKey,
|
primaryKey,
|
||||||
real,
|
|
||||||
serial,
|
serial,
|
||||||
text,
|
text,
|
||||||
} from "npm:drizzle-orm/pg-core";
|
} from "npm:drizzle-orm/pg-core";
|
||||||
@@ -33,16 +33,15 @@ export const users = pgTable("users", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const promotions = pgTable("promotions", {
|
export const promotions = pgTable("promotions", {
|
||||||
id: serial("id").primaryKey(),
|
id: text("idPromo").primaryKey(),
|
||||||
endyear: integer("endyear"),
|
annee: text("annee"),
|
||||||
current: integer("current"),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const students = pgTable("students", {
|
export const students = pgTable("students", {
|
||||||
numEtud: serial("numEtud").primaryKey(),
|
numEtud: serial("numEtud").primaryKey(),
|
||||||
nom: text("nom").notNull(),
|
nom: text("nom").notNull(),
|
||||||
prenom: text("prenom").notNull(),
|
prenom: text("prenom").notNull(),
|
||||||
idPromo: text("idPromo").references(() => promotions.id as unknown as string),
|
idPromo: text("idPromo").references(() => promotions.id),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const modules = pgTable("modules", {
|
export const modules = pgTable("modules", {
|
||||||
@@ -53,7 +52,7 @@ export const modules = pgTable("modules", {
|
|||||||
export const enseignements = pgTable("enseignements", {
|
export const enseignements = pgTable("enseignements", {
|
||||||
idProf: text("idProf").notNull().references(() => users.id),
|
idProf: text("idProf").notNull().references(() => users.id),
|
||||||
idModule: text("idModule").notNull().references(() => modules.id),
|
idModule: text("idModule").notNull().references(() => modules.id),
|
||||||
idPromo: text("idPromo").notNull(),
|
idPromo: text("idPromo").notNull().references(() => promotions.id),
|
||||||
}, (t) => ({
|
}, (t) => ({
|
||||||
pk: primaryKey({ columns: [t.idProf, t.idModule, t.idPromo] }),
|
pk: primaryKey({ columns: [t.idProf, t.idModule, t.idPromo] }),
|
||||||
}));
|
}));
|
||||||
@@ -66,8 +65,8 @@ export const ues = pgTable("ues", {
|
|||||||
export const ueModules = pgTable("ue_modules", {
|
export const ueModules = pgTable("ue_modules", {
|
||||||
idModule: text("idModule").notNull().references(() => modules.id),
|
idModule: text("idModule").notNull().references(() => modules.id),
|
||||||
idUE: integer("idUE").notNull().references(() => ues.id),
|
idUE: integer("idUE").notNull().references(() => ues.id),
|
||||||
idPromo: text("idPromo").notNull(),
|
idPromo: text("idPromo").notNull().references(() => promotions.id),
|
||||||
coeff: real("coeff").notNull(),
|
coeff: doublePrecision("coeff").notNull(),
|
||||||
}, (t) => ({
|
}, (t) => ({
|
||||||
pk: primaryKey({ columns: [t.idModule, t.idUE, t.idPromo] }),
|
pk: primaryKey({ columns: [t.idModule, t.idUE, t.idPromo] }),
|
||||||
}));
|
}));
|
||||||
@@ -75,7 +74,7 @@ export const ueModules = pgTable("ue_modules", {
|
|||||||
export const notes = pgTable("notes", {
|
export const notes = pgTable("notes", {
|
||||||
numEtud: integer("numEtud").notNull().references(() => students.numEtud),
|
numEtud: integer("numEtud").notNull().references(() => students.numEtud),
|
||||||
idModule: text("idModule").notNull().references(() => modules.id),
|
idModule: text("idModule").notNull().references(() => modules.id),
|
||||||
note: real("note").notNull(),
|
note: doublePrecision("note").notNull(),
|
||||||
}, (t) => ({
|
}, (t) => ({
|
||||||
pk: primaryKey({ columns: [t.numEtud, t.idModule] }),
|
pk: primaryKey({ columns: [t.numEtud, t.idModule] }),
|
||||||
}));
|
}));
|
||||||
@@ -83,7 +82,7 @@ export const notes = pgTable("notes", {
|
|||||||
export const ajustements = pgTable("ajustements", {
|
export const ajustements = pgTable("ajustements", {
|
||||||
numEtud: integer("numEtud").notNull().references(() => students.numEtud),
|
numEtud: integer("numEtud").notNull().references(() => students.numEtud),
|
||||||
idUE: integer("idUE").notNull().references(() => ues.id),
|
idUE: integer("idUE").notNull().references(() => ues.id),
|
||||||
valeur: real("valeur").notNull(),
|
valeur: doublePrecision("valeur").notNull(),
|
||||||
}, (t) => ({
|
}, (t) => ({
|
||||||
pk: primaryKey({ columns: [t.numEtud, t.idUE] }),
|
pk: primaryKey({ columns: [t.numEtud, t.idUE] }),
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { Handlers } from "$fresh/server.ts";
|
||||||
|
import { db } from "../../../../databases/db.ts";
|
||||||
|
import { ues } from "../../../../databases/schema.ts";
|
||||||
|
|
||||||
|
export const handler: Handlers = {
|
||||||
|
async GET() {
|
||||||
|
try {
|
||||||
|
const result = await db.select().from(ues);
|
||||||
|
|
||||||
|
return new Response(JSON.stringify(result), {
|
||||||
|
status: 200,
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching UEs:", error);
|
||||||
|
return new Response("Failed to fetch data", { status: 500 });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user