Files
classroomio/packages/db/src/utils/seed/course.ts
T

140 lines
5.3 KiB
TypeScript
Raw Normal View History

2025-12-25 05:09:27 +01:00
import { course, db } from '@db/drizzle';
2026-03-09 11:18:22 +01:00
import type { TNewCourse } from '@db/types';
2025-12-25 05:09:27 +01:00
interface SeedCourse {
mvcGroupId: string;
reactGroupId: string;
pandasGroupId: string;
2026-04-27 11:40:38 +01:00
earlyAdopterGroupId: string;
2025-12-25 05:09:27 +01:00
}
2026-04-27 11:40:38 +01:00
export async function seedCourses({ mvcGroupId, reactGroupId, pandasGroupId, earlyAdopterGroupId }: SeedCourse) {
2025-12-25 05:09:27 +01:00
const existingCourses = await db.select().from(course);
const existingCourseIds = existingCourses.map((c) => c.id);
const mvcCourseId = '98e6e798-f0bd-4f9d-a6f5-ce0816a4f97e';
const reactCourseId = '16e3bc8d-5d1b-4708-988e-93abae288ccf';
const pandasCourseId = 'f0a85d18-aff4-412f-b8e6-3b34ef098dce';
2026-04-27 11:40:38 +01:00
const earlyAdopterCourseId = '9bd496cc-c494-4a7e-e12c-6baeef246f8b';
2025-12-25 05:09:27 +01:00
2026-03-09 11:18:22 +01:00
const coursesToInsert: TNewCourse[] = [
2025-12-25 05:09:27 +01:00
{
id: mvcCourseId,
title: 'Getting started with MVC',
description:
"Embark on a comprehensive journey into the world of Model-View-Controller (MVC) architecture with our course, 'Getting Started with MVC.' Designed for beginners and aspiring developers, this course provides a solid foundation for understanding the principles and practices behind MVC, a widely adopted design pattern in software development.",
overview:
'<p>"Getting Started with MVC. is designed for beginners and aspiring developers, this course provides a solid foundation for understanding the principles and practices behind MVC, a widely adopted design pattern in software development.</p>',
groupId: mvcGroupId,
isTemplate: true,
logo: '',
slug: 'getting-started-with-mvc',
metadata: {
goals: '',
grading: false,
description: '',
requirements: '',
lessonDownload: false,
2026-03-09 11:18:22 +01:00
allowNewStudent: true
2025-12-25 05:09:27 +01:00
},
cost: 0,
currency: 'NGN',
isPublished: true,
certificate: {
isDownloadable: false,
theme: 'professional'
},
2025-12-25 05:09:27 +01:00
status: 'ACTIVE'
},
{
id: reactCourseId,
title: 'Modern Web Development with React',
description:
"By the end of this course, you'll be equipped to build interactive and responsive web applications, making you a proficient React developer ready for the demands of today's web development landscape.",
overview: 'Welcome to this amazing course 🚀 ',
groupId: reactGroupId,
isTemplate: true,
logo: 'https://images.unsplash.com/photo-1565843708714-52ecf69ab81f?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w1MTE1NTV8MHwxfHNlYXJjaHwxOHx8cmVhY3QlMjBkZXZ8ZW58MHx8fHwxNzA3Nzk5NDMyfDA&ixlib=rb-4.0.3&q=80&w=1080',
slug: 'modern-web-development',
metadata: {
goals: '',
grading: true,
description: '',
requirements: '',
lessonDownload: false,
2026-03-09 11:18:22 +01:00
allowNewStudent: true
2025-12-25 05:09:27 +01:00
},
cost: 0,
currency: 'NGN',
isPublished: true,
certificate: {
isDownloadable: false,
theme: 'professional'
},
2025-12-25 05:09:27 +01:00
status: 'ACTIVE'
},
{
id: pandasCourseId,
title: 'Data Science with Python and Pandas',
description:
'Unlock the power of data with our "Data Science with Python and Pandas" course. Dive into Python programming fundamentals and then journey into the world of Pandas for efficient data manipulation and analysis. Learn essential data cleaning and preprocessing techniques before venturing into statistical analysis using Pandas. Cap off your exploration with data visualization using Matplotlib and Seaborn.',
overview: 'Welcome to this amazing course 🚀 ',
groupId: pandasGroupId,
isTemplate: true,
logo: 'https://images.unsplash.com/photo-1518186285589-2f7649de83e0?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3w1MTE1NTV8MHwxfHNlYXJjaHwxOHx8ZGF0YSUyMHNjaWVuY2V8ZW58MHx8fHwxNzA3Nzk5MzMwfDA&ixlib=rb-4.0.3&q=80&w=1080',
slug: 'data-science-with-python-and-pandas-1702919269375',
metadata: {
goals: '',
grading: true,
description: '',
requirements: '',
lessonDownload: true,
2026-03-09 11:18:22 +01:00
allowNewStudent: true
2025-12-25 05:09:27 +01:00
},
cost: 0,
currency: 'NGN',
isPublished: true,
certificate: {
isDownloadable: false,
theme: 'professional'
},
2025-12-25 05:09:27 +01:00
status: 'ACTIVE'
2026-04-27 11:40:38 +01:00
},
{
id: earlyAdopterCourseId,
title: 'Product Management Fundamentals',
description:
'A practical introduction to product management covering roadmaps, prioritization frameworks, user research, and cross-functional collaboration skills needed to ship great products.',
overview: 'Welcome to Product Management Fundamentals 🚀',
groupId: earlyAdopterGroupId,
isTemplate: false,
logo: '',
slug: 'product-management-fundamentals',
metadata: {
goals: '',
grading: false,
description: '',
requirements: '',
lessonDownload: false,
allowNewStudent: true
},
cost: 0,
currency: 'NGN',
isPublished: true,
certificate: {
isDownloadable: false,
theme: 'professional'
},
status: 'ACTIVE'
2025-12-25 05:09:27 +01:00
}
].filter((c) => !existingCourseIds.includes(c.id));
if (coursesToInsert.length > 0) {
await db.insert(course).values(coursesToInsert);
console.log(` ✓ Inserted ${coursesToInsert.length} course(s)`);
} else {
console.log(' ✓ Courses already exist, skipping');
}
}