Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import roleRoutes from './src/routes/role.routes';
import teamRoutes from './src/routes/team.routes';
import tentRoutes from './src/routes/tent.routes';
import userRoutes from './src/routes/user.routes';
import makerBattleRoutes from './src/routes/maker_battle.routes';
import bannedRoutes from './src/routes/banned.routes';
import { server_port } from './src/shared/secrets/secrets';
import { initQcmvss } from './src/database/initdb/initQcmvss';
Expand Down Expand Up @@ -69,6 +70,7 @@ async function startServer() {
app.use('/api/discord', authenticateUser, discordRoutes);
app.use('/api/tent', authenticateUser, tentRoutes);
app.use('/api/bus', authenticateUser, busRoutes);
app.use('/api/maker-battle', authenticateUser, makerBattleRoutes);
app.use('/api/uploads/news', express.static(path.join(__dirname, '/uploads/news')));
app.use('/api/uploads/notebooks', express.static(path.join(__dirname, '/uploads/notebooks')));
app.use('/api/uploads/foodmenu', express.static(path.join(__dirname, '/uploads/foodmenu')));
Expand Down
20 changes: 20 additions & 0 deletions backend/src/controllers/maker_battle.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as maker_battle_service from '../services/maker_battle.service';
import type { AppRequestHandler } from '../types/http';
import { Error } from '../shared/http/responses';
import type { MakerBattleDTO } from '../dto/maker_battle.dto';

export const distributeGroups: AppRequestHandler<MakerBattleDTO> = async (req, res) => {
const groups = req.body.groups;
if (!groups || !Array.isArray(groups)) {
return Error(res, { msg: 'Invalid request: groups must be an array' });
}

try {
for (const group of groups) {
await maker_battle_service.distributeGroups(group);
}
return res.status(200).json({ success: true, message: 'Groups allocated successfully' });
} catch (err) {
return Error(res, { msg: 'Erreur lors de la distribution des groupes : ' + err });
}
};
6 changes: 6 additions & 0 deletions backend/src/database/migrations/0028_aberrant_mysterio.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE "defi_tc_attribution" (
"user_id" integer PRIMARY KEY NOT NULL,
"team" integer NOT NULL
);
--> statement-breakpoint
ALTER TABLE "defi_tc_attribution" ADD CONSTRAINT "defi_tc_attribution_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
5 changes: 5 additions & 0 deletions backend/src/database/migrations/0029_famous_thing.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE "defi_tc_attribution" RENAME TO "maker_battle_attribution";--> statement-breakpoint
ALTER TABLE "maker_battle_attribution" DROP CONSTRAINT "defi_tc_attribution_user_id_users_id_fk";
--> statement-breakpoint
ALTER TABLE "maker_battle_attribution" ADD COLUMN "table" text NOT NULL;--> statement-breakpoint
ALTER TABLE "maker_battle_attribution" ADD CONSTRAINT "maker_battle_attribution_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "maker_battle_attribution" RENAME COLUMN "team" TO "maker_team_id";--> statement-breakpoint
ALTER TABLE "maker_battle_attribution" ADD COLUMN "group" text NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE "maker_battle_attribution" CASCADE;
8 changes: 8 additions & 0 deletions backend/src/database/migrations/0032_groovy_mother_askani.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE "maker_battle_attribution" (
"user_id" integer PRIMARY KEY NOT NULL,
"maker_team_id" integer NOT NULL,
"table" text NOT NULL,
"group" text NOT NULL
);
--> statement-breakpoint
ALTER TABLE "maker_battle_attribution" ADD CONSTRAINT "maker_battle_attribution_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
1 change: 1 addition & 0 deletions backend/src/database/migrations/0033_lazy_salo.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-- Custom SQL migration file, put your code below! --
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS "maker_battle_attribution" CASCADE;
8 changes: 8 additions & 0 deletions backend/src/database/migrations/0035_true_ultragirl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE TABLE "maker_battle_attribution" (
"user_id" integer PRIMARY KEY NOT NULL,
"maker_team_id" integer NOT NULL,
"table" text NOT NULL,
"group" text NOT NULL
);
--> statement-breakpoint
ALTER TABLE "maker_battle_attribution" ADD CONSTRAINT "maker_battle_attribution_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
Loading
Loading