This commit is contained in:
louiscklaw
2025-02-01 01:58:47 +08:00
parent b3da7aaef5
commit 04dbefcbaf
1259 changed files with 280657 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
import { addItems } from '../dbSetupFunctions';
const eventId = 1;
addItems(eventId);

View File

@@ -0,0 +1,5 @@
import { addParticipants } from '../dbSetupFunctions';
const eventId = 1;
const participantsAmount = 100;
addParticipants(eventId, participantsAmount);

View File

@@ -0,0 +1,3 @@
import { clearDB } from '../dbSetupFunctions';
clearDB();

View File

@@ -0,0 +1,4 @@
import { createEvents } from '../dbSetupFunctions';
const eventNumbers = 50;
createEvents(eventNumbers);

View File

@@ -0,0 +1,3 @@
import { initDB } from "../dbSetupFunctions";
initDB();

View File

@@ -0,0 +1,4 @@
import { joinEvents } from '../dbSetupFunctions';
const eventsJoinedPerUser = 50;
joinEvents(eventsJoinedPerUser);

View File

@@ -0,0 +1,46 @@
import pg from "pg";
import dotenv from "dotenv";
import { addItems, addParticipants, clearDB, createEvents, initDB, regUsers } from "../dbSetupFunctions";
const newUsersNumber: number = 100;
const createEventsAmountPerUser: number = 1;
const eventId: number = 1;
const participantAmount: number = 100;
lazy();
async function lazy() {
dotenv.config();
const client = new pg.Client({
host: process.env.DB_HOST,
database: process.env.DB_NAME,
user: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
});
await client.connect();
const [tableCount] = (
await client.query(`
select count(*)
from information_schema.tables
where table_schema = 'public';
`)
).rows;
console.log(tableCount);
await client.end();
if (parseInt(tableCount.count)) {
await clearDB();
}
await initDB();
await regUsers(newUsersNumber);
await createEvents(createEventsAmountPerUser);
await addParticipants(eventId, participantAmount);
await addItems(eventId);
}

View File

@@ -0,0 +1,4 @@
import { regUsers } from '../dbSetupFunctions';
const newUsersAmount = 10;
regUsers(newUsersAmount);

View File

@@ -0,0 +1,3 @@
import { truncateDB } from '../dbSetupFunctions';
truncateDB();