Skip to content
Snippets Groups Projects

Populate involvement type and involvement lookup in database

Merged kainguyen requested to merge Populate-Involvement-Table into main
2 files
+ 237
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -6,6 +6,12 @@ const {
addStateIfNotExists,
checkTableExistence,
} = require("../../repository/stateRepository");
const {
addInvolvementTypeIfNotExists,
addInvolvementIfNotExists,
checkInvolvementTypeTableExistence,
checkInvolvementLookupTableExistence,
} = require("../../repository/involvementRepository");
/*
Class responsible for populating the database
@@ -133,11 +139,109 @@ class DatabaseInitializer {
}
}
/*
Creates all the involvement types
*/
async initializeInvolvementTypes() {
await checkInvolvementTypeTableExistence(); // Ensure the table exists
const involvementTypes = [
"Asian American Cadet Organization",
"Black Cadet Organization",
"Cadet Alumni Team",
"Cadet Language Organization",
"Cadets for a Cause",
"Coast Guard Auxiliary",
"Color Guard",
"Conrad Cavalry",
"Corps Marksmanship Team",
"Eagle Scout Association",
"EMT Staff",
"Esprit de Corps",
"Executive Committee",
"Fenix (Latin Cadets)",
"Gregory Guard",
"Growley Team",
"Hall Council",
"Helping Educate Regarding Orientation (HERO)",
"Historian Staff",
"Honor Court",
"Inspector General Staff",
"Men's Basketball",
"O-Course Committee",
"Ordinance Staff",
"Rappelling Tower Committee",
"Recruiting Staff",
"Sash and Saber Honor Society",
"Signal Corps",
"Skipper Crew",
"Society of American Military Engineers",
"VPI Battalion",
"VTCC Cyber Team",
"Women's Basketball",
];
for (const type of involvementTypes) {
await addInvolvementTypeIfNotExists(type); // Add each involvement type
}
}
/*
Creates all the involvement lookups directly based on the defined involvement types
*/
async initializeInvolvementLookups() {
await checkInvolvementLookupTableExistence(); // Ensure the lookup table exists
// Define lookup entries with type IDs (these IDs should correspond to your actual involvement type IDs)
const involvementLookups = [
{ involvementTypeId: 1 }, // Asian American Cadet Organization
{ involvementTypeId: 2 }, // Black Cadet Organization
{ involvementTypeId: 3 }, // Cadet Alumni Team
{ involvementTypeId: 4 }, // Cadet Language Organization
{ involvementTypeId: 5 }, // Cadets for a Cause
{ involvementTypeId: 6 }, // Coast Guard Auxiliary
{ involvementTypeId: 7 }, // Color Guard
{ involvementTypeId: 8 }, // Conrad Cavalry
{ involvementTypeId: 9 }, // Corps Marksmanship Team
{ involvementTypeId: 10 }, // Eagle Scout Association
{ involvementTypeId: 11 }, // EMT Staff
{ involvementTypeId: 12 }, // Esprit de Corps
{ involvementTypeId: 13 }, // Executive Committee
{ involvementTypeId: 14 }, // Fenix (Latin Cadets)
{ involvementTypeId: 15 }, // Gregory Guard
{ involvementTypeId: 16 }, // Growley Team
{ involvementTypeId: 17 }, // Hall Council
{ involvementTypeId: 18 }, // Helping Educate Regarding Orientation (HERO)
{ involvementTypeId: 19 }, // Historian Staff
{ involvementTypeId: 20 }, // Honor Court
{ involvementTypeId: 21 }, // Inspector General Staff
{ involvementTypeId: 22 }, // Men’s Basketball
{ involvementTypeId: 23 }, // O-Course Committee
{ involvementTypeId: 24 }, // Ordinance Staff
{ involvementTypeId: 25 }, // Rappelling Tower Committee
{ involvementTypeId: 26 }, // Recruiting Staff
{ involvementTypeId: 27 }, // Sash and Saber Honor Society
{ involvementTypeId: 28 }, // Signal Corps
{ involvementTypeId: 29 }, // Skipper Crew
{ involvementTypeId: 30 }, // Society of American Military Engineers
{ involvementTypeId: 31 }, // VPI Battalion
{ involvementTypeId: 32 }, // VTCC Cyber Team
{ involvementTypeId: 33 }, // Women’s Basketball
];
for (const entry of involvementLookups) {
await addInvolvementIfNotExists(entry.involvementTypeId); // Add entry to involvementLookup
}
}
async initializeAll() {
await this.testDBConnection();
await this.initializeRoles();
await this.initializeTestUsers();
await this.initializeStates();
await this.initializeInvolvementTypes();
await this.initializeInvolvementLookups();
console.log("database init completed.");
}
Loading