Skip to content

Commit

Permalink
✨ feature: Adding MINI-MUN Seed (#201)
Browse files Browse the repository at this point in the history
* feat: Add custom seeds for MINI-MUN 2024 delegations and seed script

* 🧼 format & lint (App Frontend):
branch: mini-mun
  • Loading branch information
Strehk authored Jul 17, 2024
1 parent c440d2e commit 8ac92d7
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 4 deletions.
57 changes: 57 additions & 0 deletions chase/backend/prisma/custom_seeds/mini_mun2024_delegations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[
{
"nation": "China",
"alpha2Code": "cn",
"SR": true
},
{
"nation": "Sierra Leone",
"alpha2Code": "sl",
"SR": true
},
{
"nation": "Schweiz",
"alpha2Code": "ch",
"SR": true
},
{
"nation": "Ecuador",
"alpha2Code": "ec",
"SR": true
},
{
"nation": "Vereinigte Staaten",
"alpha2Code": "us",
"SR": true
},
{
"nation": "Russland",
"alpha2Code": "ru",
"SR": true
},
{
"nation": "Japan",
"alpha2Code": "jp",
"SR": true
},
{
"nation": "Frankreich",
"alpha2Code": "fr",
"SR": true
},
{
"nation": "Guyana",
"alpha2Code": "gy",
"SR": true
},
{
"nation": "Vereinigtes Königreich",
"alpha2Code": "uk",
"SR": true
},
{
"nation": "Algerien",
"alpha2Code": "dz",
"SR": true
}
]
177 changes: 177 additions & 0 deletions chase/backend/prisma/custom_seeds/seed_mini_mun2024.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
// import { faker } from "@faker-js/faker";
import { $Enums, PrismaClient } from "../generated/client";
import delegationData from "./mun-sh_delegations.json";
const prisma = new PrismaClient();

try {
/*
* --------------------
* MUN-SH 2024 Data
* --------------------
*/
const conference = await prisma.conference.upsert({
where: {
name: "MINI-MUN 2024",
},
update: {},
create: {
name: "MINI-MUN 2024",
start: new Date("2024-07-18"),
end: new Date("2024-07-18"),
},
});
console.info("\n----------------\n");
console.info(
`Created a MINI-MUN 2024 Conference with the ID ${conference.id}`,
);

// Committees

const committees = {} as {
SR: Awaited<ReturnType<typeof prisma.committee.create>> | undefined;
};

committees.SR = await prisma.committee.create({
data: {
conferenceId: conference.id,
abbreviation: "SR",
name: "Sicherheitsrat",
category: "COMMITTEE",
},
});

console.info("\nCreated Committees:");
console.info(
` - Created ${committees.SR.abbreviation} with ID ${committees.SR.id}`,
);

// Committee seeding

const agendaItems = {
SR: ["Desinfektion Kampagnen"],
};

for (const committee of Object.keys(committees)) {
if (committees[committee as keyof typeof committees]) {
for (const itemTemplate of agendaItems[
committee as keyof typeof committees
]) {
const agendaItem = await prisma.agendaItem.create({
data: {
committeeId:
committees[committee as keyof typeof committees]?.id || "0",
title: itemTemplate || "Dummy Agenda Item",
},
});
await prisma.speakersList.createMany({
data: [
{
type: "SPEAKERS_LIST",
agendaItemId: agendaItem.id,
speakingTime: 180,
timeLeft: 180,
},
{
type: "COMMENT_LIST",
agendaItemId: agendaItem.id,
speakingTime: 30,
timeLeft: 30,
},
],
});
}
}
}

console.info("\nCreated Agenda Items");

// Delegations
console.info("\nCreated Delegations:");

for (const data of delegationData) {
const delegation = await prisma.delegation.create({
data: {
conference: { connect: { id: conference.id } },
nation: { connect: { alpha3Code: data.alpha3Code } },
},
});
console.info(
` - Created Delegation for ${data.alpha3Code} with ID ${delegation.id}`,
);

if (data.SR) {
await prisma.committeeMember.create({
data: {
committeeId: committees.SR?.id,
delegationId: delegation.id,
},
});
}
}

// Non-State Actors
console.info("\nCreated Non-State Actor CommitteeMemberships:");

const nonStateActors: string[] = [];

for (const nonStateActor of nonStateActors) {
const delegation = await prisma.delegation.create({
data: {
conference: { connect: { id: conference.id } },
nation: { connect: { alpha3Code: nonStateActor } },
},
});

for (const committee of Object.values(committees)) {
if (committee) {
await prisma.committeeMember.create({
data: {
committeeId: committee.id,
delegationId: delegation.id,
},
});
console.info(
` - Created CommitteeMembership for ${nonStateActor} in ${committee.abbreviation}`,
);
}
}
}

// Special Persons
console.info("\nCreated Special Persons CommitteeMemberships:");

const specialPersons = await prisma.nation.findMany({
where: {
variant: $Enums.NationVariant.SPECIAL_PERSON,
},
});

for (const specialPerson of specialPersons) {
const delegation = await prisma.delegation.create({
data: {
conference: { connect: { id: conference.id } },
nation: { connect: { alpha3Code: specialPerson.alpha3Code } },
},
});

for (const committee of Object.values(committees)) {
if (committee) {
await prisma.committeeMember.create({
data: {
committeeId: committee.id,
delegationId: delegation.id,
},
});
console.info(
` - Created CommitteeMembership for ${specialPerson.alpha3Code} in ${committee.abbreviation}`,
);
}
}
}

await prisma.$disconnect();
} catch (e) {
console.error(e);
await prisma.$disconnect();
process.exit(1);
}
11 changes: 7 additions & 4 deletions chase/frontend/components/version_modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import Link from "next/link";
import SmallInfoCard from "./small_info_card";
import { env } from "next-runtime-env";
import FAIcon from "./font_awesome_icon";
import remarkGfm from 'remark-gfm'
import rehypeRaw from 'rehype-raw'
import rehypeSanitize from 'rehype-sanitize'
import remarkGfm from "remark-gfm";
import rehypeRaw from "rehype-raw";
import rehypeSanitize from "rehype-sanitize";

export default function VersionModal({
visible,
Expand Down Expand Up @@ -134,7 +134,10 @@ export default function VersionModal({
})}
</div>
</div>
<Markdown rehypePlugins={[remarkGfm,rehypeRaw,rehypeSanitize]} className="prose prose-sm !max-w-full w-full overflow-x-scroll">
<Markdown
rehypePlugins={[remarkGfm, rehypeRaw, rehypeSanitize]}
className="prose prose-sm !max-w-full w-full overflow-x-scroll"
>
{release.body}
</Markdown>
</div>
Expand Down

0 comments on commit 8ac92d7

Please sign in to comment.