feat(seeder): add job tags seeder
- Created seeders/tags.js with area, level, and stack categories - Area: Engineering, Design, Product, Marketing, Sales, etc. - Level: Intern, Junior, Mid, Senior, Lead, Staff, Manager, etc. - Stack: JavaScript, Python, Go, React, Node.js, AWS, Docker, etc. - 79+ tags in total
This commit is contained in:
parent
e47c25fac8
commit
3d7612901d
2 changed files with 119 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import { seedAcmeCorp, seedWileECoyote } from './seeders/acme.js';
|
||||||
import { seedFictionalCompanies } from './seeders/fictional-companies.js';
|
import { seedFictionalCompanies } from './seeders/fictional-companies.js';
|
||||||
import { seedEpicCompanies } from './seeders/epic-companies.js';
|
import { seedEpicCompanies } from './seeders/epic-companies.js';
|
||||||
import { seedNotifications } from './seeders/notifications.js';
|
import { seedNotifications } from './seeders/notifications.js';
|
||||||
|
import { seedTags } from './seeders/tags.js';
|
||||||
|
|
||||||
async function resetDatabase() {
|
async function resetDatabase() {
|
||||||
console.log('🗑️ Resetting database...');
|
console.log('🗑️ Resetting database...');
|
||||||
|
|
@ -87,6 +88,7 @@ async function seedDatabase() {
|
||||||
await seedEpicCompanies(); // 🌟 BNL, Cyberdyne, Wonka, Wayne, Oceanic, InGen, Bubba Gump, Umbrella, Sprawl-Mart
|
await seedEpicCompanies(); // 🌟 BNL, Cyberdyne, Wonka, Wayne, Oceanic, InGen, Bubba Gump, Umbrella, Sprawl-Mart
|
||||||
await seedApplications(); // 📝 Applications from candidates
|
await seedApplications(); // 📝 Applications from candidates
|
||||||
await seedNotifications(); // 🔔 Notifications for dashboard
|
await seedNotifications(); // 🔔 Notifications for dashboard
|
||||||
|
await seedTags(); // 🏷️ Job tags (area, level, stack)
|
||||||
|
|
||||||
console.log('\n✅ Database seeding completed successfully!');
|
console.log('\n✅ Database seeding completed successfully!');
|
||||||
console.log('\n📊 Summary:');
|
console.log('\n📊 Summary:');
|
||||||
|
|
@ -143,6 +145,7 @@ async function seedDatabaseLite() {
|
||||||
await seedEpicCompanies();
|
await seedEpicCompanies();
|
||||||
await seedApplications();
|
await seedApplications();
|
||||||
await seedNotifications();
|
await seedNotifications();
|
||||||
|
await seedTags();
|
||||||
|
|
||||||
console.log('\n✅ Database seeding (LITE) completed successfully!');
|
console.log('\n✅ Database seeding (LITE) completed successfully!');
|
||||||
console.log(' ⚡ Cities skipped for faster seeding');
|
console.log(' ⚡ Cities skipped for faster seeding');
|
||||||
|
|
@ -179,6 +182,7 @@ async function seedDatabaseNoLocations() {
|
||||||
await seedEpicCompanies();
|
await seedEpicCompanies();
|
||||||
await seedApplications();
|
await seedApplications();
|
||||||
await seedNotifications();
|
await seedNotifications();
|
||||||
|
await seedTags();
|
||||||
|
|
||||||
console.log('\n✅ Database seeding (NO LOCATIONS) completed successfully!');
|
console.log('\n✅ Database seeding (NO LOCATIONS) completed successfully!');
|
||||||
console.log(' ⏭️ All location data skipped (continents, countries, states, cities)');
|
console.log(' ⏭️ All location data skipped (continents, countries, states, cities)');
|
||||||
|
|
|
||||||
115
seeder-api/src/seeders/tags.js
Normal file
115
seeder-api/src/seeders/tags.js
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
/**
|
||||||
|
* Tags Seeder
|
||||||
|
* Seeds job_tags table with categories: area, level, stack
|
||||||
|
*/
|
||||||
|
|
||||||
|
const seedTags = async (pool) => {
|
||||||
|
console.log('🏷️ Seeding job tags...');
|
||||||
|
|
||||||
|
const tags = [
|
||||||
|
// Area (Departamento/Área)
|
||||||
|
{ name: 'Engineering', category: 'area' },
|
||||||
|
{ name: 'Design', category: 'area' },
|
||||||
|
{ name: 'Product', category: 'area' },
|
||||||
|
{ name: 'Marketing', category: 'area' },
|
||||||
|
{ name: 'Sales', category: 'area' },
|
||||||
|
{ name: 'Customer Success', category: 'area' },
|
||||||
|
{ name: 'Human Resources', category: 'area' },
|
||||||
|
{ name: 'Finance', category: 'area' },
|
||||||
|
{ name: 'Operations', category: 'area' },
|
||||||
|
{ name: 'Data', category: 'area' },
|
||||||
|
{ name: 'Quality Assurance', category: 'area' },
|
||||||
|
{ name: 'DevOps', category: 'area' },
|
||||||
|
{ name: 'Security', category: 'area' },
|
||||||
|
{ name: 'Legal', category: 'area' },
|
||||||
|
{ name: 'Administrative', category: 'area' },
|
||||||
|
|
||||||
|
// Level (Nível)
|
||||||
|
{ name: 'Intern', category: 'level' },
|
||||||
|
{ name: 'Junior', category: 'level' },
|
||||||
|
{ name: 'Mid-Level', category: 'level' },
|
||||||
|
{ name: 'Senior', category: 'level' },
|
||||||
|
{ name: 'Lead', category: 'level' },
|
||||||
|
{ name: 'Staff', category: 'level' },
|
||||||
|
{ name: 'Principal', category: 'level' },
|
||||||
|
{ name: 'Manager', category: 'level' },
|
||||||
|
{ name: 'Director', category: 'level' },
|
||||||
|
{ name: 'VP', category: 'level' },
|
||||||
|
{ name: 'C-Level', category: 'level' },
|
||||||
|
|
||||||
|
// Stack (Tecnologias)
|
||||||
|
{ name: 'JavaScript', category: 'stack' },
|
||||||
|
{ name: 'TypeScript', category: 'stack' },
|
||||||
|
{ name: 'Python', category: 'stack' },
|
||||||
|
{ name: 'Go', category: 'stack' },
|
||||||
|
{ name: 'Java', category: 'stack' },
|
||||||
|
{ name: 'C#', category: 'stack' },
|
||||||
|
{ name: 'Ruby', category: 'stack' },
|
||||||
|
{ name: 'PHP', category: 'stack' },
|
||||||
|
{ name: 'Rust', category: 'stack' },
|
||||||
|
{ name: 'Swift', category: 'stack' },
|
||||||
|
{ name: 'Kotlin', category: 'stack' },
|
||||||
|
{ name: 'React', category: 'stack' },
|
||||||
|
{ name: 'Vue.js', category: 'stack' },
|
||||||
|
{ name: 'Angular', category: 'stack' },
|
||||||
|
{ name: 'Next.js', category: 'stack' },
|
||||||
|
{ name: 'Node.js', category: 'stack' },
|
||||||
|
{ name: 'NestJS', category: 'stack' },
|
||||||
|
{ name: 'Django', category: 'stack' },
|
||||||
|
{ name: 'FastAPI', category: 'stack' },
|
||||||
|
{ name: 'Spring Boot', category: 'stack' },
|
||||||
|
{ name: '.NET', category: 'stack' },
|
||||||
|
{ name: 'Ruby on Rails', category: 'stack' },
|
||||||
|
{ name: 'Laravel', category: 'stack' },
|
||||||
|
{ name: 'PostgreSQL', category: 'stack' },
|
||||||
|
{ name: 'MySQL', category: 'stack' },
|
||||||
|
{ name: 'MongoDB', category: 'stack' },
|
||||||
|
{ name: 'Redis', category: 'stack' },
|
||||||
|
{ name: 'Elasticsearch', category: 'stack' },
|
||||||
|
{ name: 'Docker', category: 'stack' },
|
||||||
|
{ name: 'Kubernetes', category: 'stack' },
|
||||||
|
{ name: 'AWS', category: 'stack' },
|
||||||
|
{ name: 'GCP', category: 'stack' },
|
||||||
|
{ name: 'Azure', category: 'stack' },
|
||||||
|
{ name: 'Terraform', category: 'stack' },
|
||||||
|
{ name: 'GraphQL', category: 'stack' },
|
||||||
|
{ name: 'REST API', category: 'stack' },
|
||||||
|
{ name: 'Figma', category: 'stack' },
|
||||||
|
{ name: 'Tailwind CSS', category: 'stack' },
|
||||||
|
{ name: 'Git', category: 'stack' },
|
||||||
|
{ name: 'CI/CD', category: 'stack' },
|
||||||
|
{ name: 'Agile/Scrum', category: 'stack' },
|
||||||
|
];
|
||||||
|
|
||||||
|
let inserted = 0;
|
||||||
|
let skipped = 0;
|
||||||
|
|
||||||
|
for (const tag of tags) {
|
||||||
|
try {
|
||||||
|
// Check if tag already exists
|
||||||
|
const exists = await pool.query(
|
||||||
|
'SELECT id FROM job_tags WHERE name = $1 AND category = $2',
|
||||||
|
[tag.name, tag.category]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (exists.rows.length > 0) {
|
||||||
|
skipped++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
await pool.query(
|
||||||
|
`INSERT INTO job_tags (name, category, active, created_at, updated_at)
|
||||||
|
VALUES ($1, $2, true, NOW(), NOW())`,
|
||||||
|
[tag.name, tag.category]
|
||||||
|
);
|
||||||
|
inserted++;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(` ❌ Error inserting tag ${tag.name}:`, error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(` ✅ Tags: ${inserted} inserted, ${skipped} skipped (already exist)`);
|
||||||
|
return { inserted, skipped };
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = { seedTags };
|
||||||
Loading…
Reference in a new issue