Skip to content

Commit

Permalink
refactor: Update populate_database.ts to create or update activity st…
Browse files Browse the repository at this point in the history
…atus
  • Loading branch information
FelipeCarillo committed May 23, 2024
1 parent 7fa30d1 commit aef6116
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion populate_database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,39 @@ async function createOrUpdateUser(user: UserEntity): Promise<void> {
}
}

async function createOrUpdateStatusActivity(status: ActivityStatusEnum) {
try {
let existing = await ActivityStatus.findOne({ where: { id: status } });
let name: string;
switch (status) {
case ActivityStatusEnum.ACTIVE:
name = "Apply Now";
break;
case ActivityStatusEnum.CANCELED:
name = "Canceled";
break;
case ActivityStatusEnum.ENDED:
name = "Ended";
break;
case ActivityStatusEnum.ON_HOLD:
name = "Under Analysis";
break;
case ActivityStatusEnum.TO_START:
name = "Coming Soon";
break;
}
if (!existing) {
await ActivityStatus.create({ name: name });
console.log(`Activity status ${status} created`);
} else {
await ActivityStatus.update({ name: name }, { where: { id: status } });
console.log(`Activity status ${status} updated`);
}
} catch (error) {
console.error(`Error creating or updating activity status ${status}:`, error);
}
}

(async () => {
try {
await handleDatabaseCreation();
Expand All @@ -278,7 +311,7 @@ async function createOrUpdateUser(user: UserEntity): Promise<void> {
await handleLanguagesCreation();

await handleCountriesCreation();

await handleCriteriasCreation();

await createOrUpdateSocialMedia();
Expand Down

0 comments on commit aef6116

Please sign in to comment.