update,
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
import { addItems } from '../dbSetupFunctions';
|
||||
|
||||
const eventId = 1;
|
||||
addItems(eventId);
|
@@ -0,0 +1,5 @@
|
||||
import { addParticipants } from '../dbSetupFunctions';
|
||||
|
||||
const eventId = 1;
|
||||
const participantsAmount = 100;
|
||||
addParticipants(eventId, participantsAmount);
|
@@ -0,0 +1,3 @@
|
||||
import { clearDB } from '../dbSetupFunctions';
|
||||
|
||||
clearDB();
|
@@ -0,0 +1,4 @@
|
||||
import { createEvents } from '../dbSetupFunctions';
|
||||
|
||||
const eventNumbers = 50;
|
||||
createEvents(eventNumbers);
|
@@ -0,0 +1,3 @@
|
||||
import { initDB } from "../dbSetupFunctions";
|
||||
|
||||
initDB();
|
@@ -0,0 +1,4 @@
|
||||
import { joinEvents } from '../dbSetupFunctions';
|
||||
|
||||
const eventsJoinedPerUser = 50;
|
||||
joinEvents(eventsJoinedPerUser);
|
@@ -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);
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
import { regUsers } from '../dbSetupFunctions';
|
||||
|
||||
const newUsersAmount = 10;
|
||||
regUsers(newUsersAmount);
|
@@ -0,0 +1,3 @@
|
||||
import { truncateDB } from '../dbSetupFunctions';
|
||||
|
||||
truncateDB();
|
Reference in New Issue
Block a user