Skip to content

Commit 885d2b2

Browse files
seeding
1 parent a5919fa commit 885d2b2

File tree

2 files changed

+447
-0
lines changed

2 files changed

+447
-0
lines changed

backend/prisma/seed.ts

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,50 @@ async function main() {
531531
},
532532
];
533533

534+
const tags = [
535+
'Healthcare',
536+
'Education',
537+
'Technology',
538+
'Community',
539+
'Legal Services',
540+
'Transportation',
541+
'Housing',
542+
'Mental Health',
543+
'Caregiving',
544+
'Nutrition',
545+
'Financial Planning',
546+
'Advocacy',
547+
'Emergency',
548+
'COVID-19',
549+
'Medicare',
550+
'Exercise',
551+
'Social Connection',
552+
'Safety',
553+
'Volunteer',
554+
'Events',
555+
];
556+
557+
console.log('Creating tags...');
558+
for (const tagName of tags) {
559+
await prisma.tag.upsert({
560+
where: { name: tagName },
561+
update: {},
562+
create: { name: tagName },
563+
});
564+
}
565+
566+
console.log('Creating admin user...');
567+
await prisma.adminUser.upsert({
568+
where: { clerkId: 'user_34wPCxBIG4LzW9L8cWghoiGYOH8' },
569+
update: {},
570+
create: {
571+
clerkId: 'user_34wPCxBIG4LzW9L8cWghoiGYOH8',
572+
email: 'tcbadevs@gmail.com',
573+
name: 'TCBA Admin',
574+
isActive: true,
575+
},
576+
});
577+
534578
console.log('Creating organizations...');
535579
for (const org of organizations) {
536580
const tempClerkId = `seed_${Date.now()}_${Math.random().toString(36).substring(7)}`;
@@ -621,9 +665,34 @@ async function main() {
621665
},
622666
];
623667

668+
const healthcareTag = await prisma.tag.findUnique({ where: { name: 'Healthcare' } });
669+
const educationTag = await prisma.tag.findUnique({ where: { name: 'Education' } });
670+
const technologyTag = await prisma.tag.findUnique({ where: { name: 'Technology' } });
671+
const communityTag = await prisma.tag.findUnique({ where: { name: 'Community' } });
672+
const eventsTag = await prisma.tag.findUnique({ where: { name: 'Events' } });
673+
const advocacyTag = await prisma.tag.findUnique({ where: { name: 'Advocacy' } });
674+
const volunteerTag = await prisma.tag.findUnique({ where: { name: 'Volunteer' } });
675+
const safetyTag = await prisma.tag.findUnique({ where: { name: 'Safety' } });
676+
677+
const announcementTagMappings: { [key: string]: string[] } = {
678+
'New Partnership with Tennessee Health Department': ['Healthcare', 'Advocacy'],
679+
'Annual Conference Registration Now Open': ['Events', 'Education'],
680+
'Grant Opportunities for Member Organizations': ['Community', 'Advocacy'],
681+
'Legislative Update: Senior Care Bill Passes': ['Healthcare', 'Advocacy'],
682+
'New Resources for Caregiver Support': ['Healthcare', 'Community'],
683+
'Volunteer Appreciation Month': ['Volunteer', 'Events'],
684+
'Summer Program Schedule Released': ['Events', 'Community'],
685+
'Technology Training Initiative Launch': ['Technology', 'Education'],
686+
'Fall Prevention Awareness Campaign': ['Safety', 'Healthcare'],
687+
'Holiday Programs and Resources': ['Events', 'Community'],
688+
};
689+
624690
console.log('Creating announcements...');
625691
for (const ann of announcements) {
626692
const slug = generateSlug(ann.title);
693+
const tagNames = announcementTagMappings[ann.title] || [];
694+
const tags = await prisma.tag.findMany({ where: { name: { in: tagNames } } });
695+
627696
await prisma.announcements.upsert({
628697
where: { slug },
629698
update: {},
@@ -632,6 +701,9 @@ async function main() {
632701
slug,
633702
createdByAdminId: 'admin_seed',
634703
attachmentUrls: [],
704+
tags: {
705+
connect: tags.map(tag => ({ id: tag.id })),
706+
},
635707
},
636708
});
637709
}
@@ -719,16 +791,39 @@ async function main() {
719791
},
720792
];
721793

794+
const blogTagMappings: { [key: string]: string[] } = {
795+
'Understanding Medicare Changes for 2024': ['Medicare', 'Healthcare', 'Financial Planning'],
796+
'The Importance of Social Connections in Aging': ['Social Connection', 'Community'],
797+
'Navigating Long-Term Care Options in Tennessee': ['Healthcare', 'Housing'],
798+
'Healthy Eating Tips for Seniors': ['Nutrition', 'Healthcare'],
799+
'Exercise Programs Designed for Older Adults': ['Exercise', 'Healthcare'],
800+
'Financial Planning for Retirement': ['Financial Planning'],
801+
'Technology Made Easy: A Guide for Seniors': ['Technology', 'Education'],
802+
'Caregiver Self-Care: Taking Time for Yourself': ['Caregiving', 'Mental Health'],
803+
'Understanding Dementia: Signs, Support, and Resources': [
804+
'Healthcare',
805+
'Mental Health',
806+
'Caregiving',
807+
],
808+
'Housing Options for Aging in Place': ['Housing', 'Community'],
809+
};
810+
722811
console.log('Creating blogs...');
723812
for (const blog of blogs) {
724813
const slug = generateSlug(blog.title);
814+
const tagNames = blogTagMappings[blog.title] || [];
815+
const tags = await prisma.tag.findMany({ where: { name: { in: tagNames } } });
816+
725817
await prisma.blog.upsert({
726818
where: { slug },
727819
update: {},
728820
create: {
729821
...blog,
730822
slug,
731823
attachmentUrls: [],
824+
tags: {
825+
connect: tags.map(tag => ({ id: tag.id })),
826+
},
732827
},
733828
});
734829
}

0 commit comments

Comments
 (0)