changes
This commit is contained in:
1 parent
a99af426db
commit
8886aa8640
91 files changed
+2823
-773
No files matched your search
+64
-1
@@ -20,6 +20,10 @@ import {
|
||||
stats,
|
||||
testimonials,
|
||||
} from "../src/lib/mock/site.ts";
|
||||
import {
|
||||
SEED_COURSE_CATEGORIES,
|
||||
SEED_COURSE_TAGS,
|
||||
} from "../src/lib/taxonomy.ts";
|
||||
|
||||
import {
|
||||
alumniStoryToRow,
|
||||
@@ -81,8 +85,42 @@ async function main() {
|
||||
results.push([table, n]);
|
||||
});
|
||||
|
||||
await upsert(
|
||||
"course_categories",
|
||||
SEED_COURSE_CATEGORIES.map((c) => ({
|
||||
id: c.id,
|
||||
slug: c.slug,
|
||||
label: c.label,
|
||||
sort_order: c.sortOrder,
|
||||
show_in_filter: true,
|
||||
published: true,
|
||||
})),
|
||||
["id", "slug", "label", "sort_order", "show_in_filter", "published"],
|
||||
);
|
||||
await upsert(
|
||||
"course_tags",
|
||||
SEED_COURSE_TAGS.map((t) => ({
|
||||
id: t.id,
|
||||
slug: t.slug,
|
||||
label: t.label,
|
||||
sort_order: t.sortOrder,
|
||||
show_in_nav: t.showInNav,
|
||||
show_in_filter: true,
|
||||
published: true,
|
||||
})),
|
||||
[
|
||||
"id",
|
||||
"slug",
|
||||
"label",
|
||||
"sort_order",
|
||||
"show_in_nav",
|
||||
"show_in_filter",
|
||||
"published",
|
||||
],
|
||||
);
|
||||
|
||||
await upsert("courses", courses.map(courseToRow), [
|
||||
"id", "slug", "title", "summary", "category", "duration_hours", "format", "price",
|
||||
"id", "slug", "title", "summary", "duration_hours", "format", "price",
|
||||
"registration_url", "poster_image_url", "brochure_image_url", "image_url", "seo_description", "published",
|
||||
]);
|
||||
const courseIds = courses.map((c) => c.id);
|
||||
@@ -91,6 +129,31 @@ async function main() {
|
||||
[courseIds],
|
||||
);
|
||||
results.push(["courses_pruned", courseIds.length]);
|
||||
|
||||
await client.query(`DELETE FROM course_category_links`);
|
||||
await client.query(`DELETE FROM course_tag_links`);
|
||||
let catLinks = 0;
|
||||
let tagLinks = 0;
|
||||
for (const course of courses) {
|
||||
for (const cat of course.categories ?? []) {
|
||||
await client.query(
|
||||
`INSERT INTO course_category_links (course_id, category_id)
|
||||
VALUES ($1, $2) ON CONFLICT DO NOTHING`,
|
||||
[course.id, cat.id],
|
||||
);
|
||||
catLinks += 1;
|
||||
}
|
||||
for (const tag of course.tags ?? []) {
|
||||
await client.query(
|
||||
`INSERT INTO course_tag_links (course_id, tag_id)
|
||||
VALUES ($1, $2) ON CONFLICT DO NOTHING`,
|
||||
[course.id, tag.id],
|
||||
);
|
||||
tagLinks += 1;
|
||||
}
|
||||
}
|
||||
results.push(["course_category_links", catLinks]);
|
||||
results.push(["course_tag_links", tagLinks]);
|
||||
await upsert("programs", programs.map(programToRow), [
|
||||
"id", "slug", "title", "blurb", "group_key", "href", "tagline", "audience",
|
||||
"duration_label", "format_label", "highlights", "body", "published",
|
||||
|
||||
Reference in new issue
Block a user