38334-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-02-10 04:26:32 +00:00

3725 lines
55 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const SiteSettings = db.site_settings;
const Pages = db.pages;
const PageSections = db.page_sections;
const Services = db.services;
const PortfolioItems = db.portfolio_items;
const Testimonials = db.testimonials;
const Skills = db.skills;
const Benefits = db.benefits;
const SocialLinks = db.social_links;
const Inquiries = db.inquiries;
const SiteSettingsData = [
{
"site_name": "Ada Lovelace",
"tagline": "Marie Curie",
"primary_domain": "Ada Lovelace",
"primary_cta_label": "Grace Hopper",
"primary_cta_url": "Ada Lovelace",
"contact_email": "Ada Lovelace",
"contact_phone": "Alan Turing",
"location": "Grace Hopper",
"accent_color_hex": "Grace Hopper",
"seo_title": "Grace Hopper",
"seo_description": "Alan Turing",
// type code here for "images" field
// type code here for "images" field
},
{
"site_name": "Ada Lovelace",
"tagline": "Grace Hopper",
"primary_domain": "Alan Turing",
"primary_cta_label": "Ada Lovelace",
"primary_cta_url": "Alan Turing",
"contact_email": "Grace Hopper",
"contact_phone": "Marie Curie",
"location": "Marie Curie",
"accent_color_hex": "Alan Turing",
"seo_title": "Marie Curie",
"seo_description": "Marie Curie",
// type code here for "images" field
// type code here for "images" field
},
{
"site_name": "Marie Curie",
"tagline": "Marie Curie",
"primary_domain": "Marie Curie",
"primary_cta_label": "Grace Hopper",
"primary_cta_url": "Ada Lovelace",
"contact_email": "Ada Lovelace",
"contact_phone": "Grace Hopper",
"location": "Marie Curie",
"accent_color_hex": "Grace Hopper",
"seo_title": "Grace Hopper",
"seo_description": "Alan Turing",
// type code here for "images" field
// type code here for "images" field
},
{
"site_name": "Ada Lovelace",
"tagline": "Marie Curie",
"primary_domain": "Marie Curie",
"primary_cta_label": "Marie Curie",
"primary_cta_url": "Marie Curie",
"contact_email": "Ada Lovelace",
"contact_phone": "Ada Lovelace",
"location": "Marie Curie",
"accent_color_hex": "Grace Hopper",
"seo_title": "Ada Lovelace",
"seo_description": "Alan Turing",
// type code here for "images" field
// type code here for "images" field
},
];
const PagesData = [
{
"title": "Ada Lovelace",
"slug": "Marie Curie",
"status": "draft",
"sort_order": 7,
"meta_title": "Grace Hopper",
"meta_description": "Grace Hopper",
"show_in_header_nav": false,
"show_in_footer_nav": true,
// type code here for "relation_one" field
},
{
"title": "Grace Hopper",
"slug": "Ada Lovelace",
"status": "draft",
"sort_order": 3,
"meta_title": "Ada Lovelace",
"meta_description": "Alan Turing",
"show_in_header_nav": false,
"show_in_footer_nav": false,
// type code here for "relation_one" field
},
{
"title": "Marie Curie",
"slug": "Alan Turing",
"status": "published",
"sort_order": 6,
"meta_title": "Alan Turing",
"meta_description": "Ada Lovelace",
"show_in_header_nav": true,
"show_in_footer_nav": true,
// type code here for "relation_one" field
},
{
"title": "Marie Curie",
"slug": "Ada Lovelace",
"status": "published",
"sort_order": 4,
"meta_title": "Grace Hopper",
"meta_description": "Grace Hopper",
"show_in_header_nav": true,
"show_in_footer_nav": true,
// type code here for "relation_one" field
},
];
const PageSectionsData = [
{
// type code here for "relation_one" field
"section_type": "portfolio",
"section_label": "Alan Turing",
"headline": "Grace Hopper",
"subheadline": "Alan Turing",
"body": "Grace Hopper",
// type code here for "images" field
"primary_button_label": "Marie Curie",
"primary_button_url": "Grace Hopper",
"secondary_button_label": "Grace Hopper",
"secondary_button_url": "Ada Lovelace",
"sort_order": 7,
"is_visible": false,
},
{
// type code here for "relation_one" field
"section_type": "portfolio",
"section_label": "Marie Curie",
"headline": "Grace Hopper",
"subheadline": "Ada Lovelace",
"body": "Ada Lovelace",
// type code here for "images" field
"primary_button_label": "Alan Turing",
"primary_button_url": "Alan Turing",
"secondary_button_label": "Grace Hopper",
"secondary_button_url": "Marie Curie",
"sort_order": 6,
"is_visible": false,
},
{
// type code here for "relation_one" field
"section_type": "services",
"section_label": "Alan Turing",
"headline": "Marie Curie",
"subheadline": "Grace Hopper",
"body": "Ada Lovelace",
// type code here for "images" field
"primary_button_label": "Alan Turing",
"primary_button_url": "Grace Hopper",
"secondary_button_label": "Ada Lovelace",
"secondary_button_url": "Marie Curie",
"sort_order": 4,
"is_visible": true,
},
{
// type code here for "relation_one" field
"section_type": "why_choose_me",
"section_label": "Grace Hopper",
"headline": "Alan Turing",
"subheadline": "Alan Turing",
"body": "Ada Lovelace",
// type code here for "images" field
"primary_button_label": "Marie Curie",
"primary_button_url": "Grace Hopper",
"secondary_button_label": "Marie Curie",
"secondary_button_url": "Ada Lovelace",
"sort_order": 8,
"is_visible": true,
},
];
const ServicesData = [
{
"name": "Grace Hopper",
"short_description": "Ada Lovelace",
"details": "Grace Hopper",
"category": "technical_documentation",
"sort_order": 3,
"is_featured": true,
"is_active": false,
"cta_label": "Alan Turing",
"cta_url": "Marie Curie",
"icon_name": "Ada Lovelace",
},
{
"name": "Grace Hopper",
"short_description": "Grace Hopper",
"details": "Ada Lovelace",
"category": "guides",
"sort_order": 4,
"is_featured": true,
"is_active": false,
"cta_label": "Alan Turing",
"cta_url": "Ada Lovelace",
"icon_name": "Ada Lovelace",
},
{
"name": "Marie Curie",
"short_description": "Marie Curie",
"details": "Alan Turing",
"category": "technical_documentation",
"sort_order": 7,
"is_featured": false,
"is_active": true,
"cta_label": "Alan Turing",
"cta_url": "Grace Hopper",
"icon_name": "Grace Hopper",
},
{
"name": "Grace Hopper",
"short_description": "Ada Lovelace",
"details": "Grace Hopper",
"category": "technical_documentation",
"sort_order": 5,
"is_featured": false,
"is_active": false,
"cta_label": "Grace Hopper",
"cta_url": "Marie Curie",
"icon_name": "Ada Lovelace",
},
];
const PortfolioItemsData = [
{
"title": "Alan Turing",
"work_type": "guide",
"client_name": "Alan Turing",
"summary": "Marie Curie",
"case_study": "Marie Curie",
// type code here for "images" field
// type code here for "files" field
"external_url": "Grace Hopper",
"tech_stack": "Marie Curie",
"published_on": new Date(Date.now()),
"is_featured": true,
"is_public": true,
},
{
"title": "Marie Curie",
"work_type": "documentation",
"client_name": "Grace Hopper",
"summary": "Ada Lovelace",
"case_study": "Grace Hopper",
// type code here for "images" field
// type code here for "files" field
"external_url": "Marie Curie",
"tech_stack": "Marie Curie",
"published_on": new Date(Date.now()),
"is_featured": true,
"is_public": false,
},
{
"title": "Grace Hopper",
"work_type": "review",
"client_name": "Ada Lovelace",
"summary": "Ada Lovelace",
"case_study": "Alan Turing",
// type code here for "images" field
// type code here for "files" field
"external_url": "Ada Lovelace",
"tech_stack": "Grace Hopper",
"published_on": new Date(Date.now()),
"is_featured": true,
"is_public": false,
},
{
"title": "Grace Hopper",
"work_type": "documentation",
"client_name": "Alan Turing",
"summary": "Grace Hopper",
"case_study": "Alan Turing",
// type code here for "images" field
// type code here for "files" field
"external_url": "Marie Curie",
"tech_stack": "Marie Curie",
"published_on": new Date(Date.now()),
"is_featured": true,
"is_public": true,
},
];
const TestimonialsData = [
{
"client_name": "Ada Lovelace",
"client_title": "Ada Lovelace",
"company_name": "Grace Hopper",
"quote": "Marie Curie",
"rating": 7,
// type code here for "images" field
"source": "Alan Turing",
"source_url": "Marie Curie",
"testimonial_date": new Date(Date.now()),
"is_featured": true,
"is_public": false,
},
{
"client_name": "Grace Hopper",
"client_title": "Marie Curie",
"company_name": "Marie Curie",
"quote": "Ada Lovelace",
"rating": 6,
// type code here for "images" field
"source": "Marie Curie",
"source_url": "Grace Hopper",
"testimonial_date": new Date(Date.now()),
"is_featured": true,
"is_public": false,
},
{
"client_name": "Ada Lovelace",
"client_title": "Ada Lovelace",
"company_name": "Marie Curie",
"quote": "Marie Curie",
"rating": 4,
// type code here for "images" field
"source": "Grace Hopper",
"source_url": "Grace Hopper",
"testimonial_date": new Date(Date.now()),
"is_featured": true,
"is_public": true,
},
{
"client_name": "Ada Lovelace",
"client_title": "Marie Curie",
"company_name": "Grace Hopper",
"quote": "Ada Lovelace",
"rating": 8,
// type code here for "images" field
"source": "Grace Hopper",
"source_url": "Ada Lovelace",
"testimonial_date": new Date(Date.now()),
"is_featured": false,
"is_public": true,
},
];
const SkillsData = [
{
"name": "Grace Hopper",
"category": "tools",
"proficiency_level": 9,
"sort_order": 6,
"is_featured": true,
},
{
"name": "Grace Hopper",
"category": "domain",
"proficiency_level": 8,
"sort_order": 4,
"is_featured": false,
},
{
"name": "Ada Lovelace",
"category": "domain",
"proficiency_level": 2,
"sort_order": 2,
"is_featured": false,
},
{
"name": "Ada Lovelace",
"category": "tools",
"proficiency_level": 2,
"sort_order": 8,
"is_featured": true,
},
];
const BenefitsData = [
{
"title": "Alan Turing",
"description": "Grace Hopper",
"icon_name": "Grace Hopper",
"sort_order": 6,
"is_active": true,
},
{
"title": "Marie Curie",
"description": "Ada Lovelace",
"icon_name": "Alan Turing",
"sort_order": 2,
"is_active": true,
},
{
"title": "Ada Lovelace",
"description": "Alan Turing",
"icon_name": "Ada Lovelace",
"sort_order": 5,
"is_active": true,
},
{
"title": "Grace Hopper",
"description": "Marie Curie",
"icon_name": "Alan Turing",
"sort_order": 1,
"is_active": true,
},
];
const SocialLinksData = [
{
"platform": "linkedin",
"label": "Ada Lovelace",
"url": "Grace Hopper",
"sort_order": 7,
"is_active": false,
},
{
"platform": "x",
"label": "Alan Turing",
"url": "Ada Lovelace",
"sort_order": 2,
"is_active": false,
},
{
"platform": "github",
"label": "Marie Curie",
"url": "Grace Hopper",
"sort_order": 2,
"is_active": false,
},
{
"platform": "linkedin",
"label": "Ada Lovelace",
"url": "Ada Lovelace",
"sort_order": 5,
"is_active": true,
},
];
const InquiriesData = [
{
"full_name": "Alan Turing",
"email": "Grace Hopper",
"company_name": "Ada Lovelace",
"subject": "Ada Lovelace",
"message": "Alan Turing",
"source_page": "Grace Hopper",
"status": "replied",
"received_at": new Date(Date.now()),
"replied_at": new Date(Date.now()),
"fiverr_url": "Marie Curie",
// type code here for "relation_one" field
},
{
"full_name": "Marie Curie",
"email": "Grace Hopper",
"company_name": "Ada Lovelace",
"subject": "Grace Hopper",
"message": "Ada Lovelace",
"source_page": "Alan Turing",
"status": "replied",
"received_at": new Date(Date.now()),
"replied_at": new Date(Date.now()),
"fiverr_url": "Alan Turing",
// type code here for "relation_one" field
},
{
"full_name": "Marie Curie",
"email": "Grace Hopper",
"company_name": "Ada Lovelace",
"subject": "Grace Hopper",
"message": "Marie Curie",
"source_page": "Alan Turing",
"status": "archived",
"received_at": new Date(Date.now()),
"replied_at": new Date(Date.now()),
"fiverr_url": "Alan Turing",
// type code here for "relation_one" field
},
{
"full_name": "Marie Curie",
"email": "Grace Hopper",
"company_name": "Grace Hopper",
"subject": "Alan Turing",
"message": "Alan Turing",
"source_page": "Ada Lovelace",
"status": "new",
"received_at": new Date(Date.now()),
"replied_at": new Date(Date.now()),
"fiverr_url": "Alan Turing",
// type code here for "relation_one" field
},
];
// Similar logic for "relation_many"
async function associatePageWithAuthor() {
const relatedAuthor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Page0 = await Pages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Page0?.setAuthor)
{
await
Page0.
setAuthor(relatedAuthor0);
}
const relatedAuthor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Page1 = await Pages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Page1?.setAuthor)
{
await
Page1.
setAuthor(relatedAuthor1);
}
const relatedAuthor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Page2 = await Pages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Page2?.setAuthor)
{
await
Page2.
setAuthor(relatedAuthor2);
}
const relatedAuthor3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Page3 = await Pages.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Page3?.setAuthor)
{
await
Page3.
setAuthor(relatedAuthor3);
}
}
async function associatePageSectionWithPage() {
const relatedPage0 = await Pages.findOne({
offset: Math.floor(Math.random() * (await Pages.count())),
});
const PageSection0 = await PageSections.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PageSection0?.setPage)
{
await
PageSection0.
setPage(relatedPage0);
}
const relatedPage1 = await Pages.findOne({
offset: Math.floor(Math.random() * (await Pages.count())),
});
const PageSection1 = await PageSections.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PageSection1?.setPage)
{
await
PageSection1.
setPage(relatedPage1);
}
const relatedPage2 = await Pages.findOne({
offset: Math.floor(Math.random() * (await Pages.count())),
});
const PageSection2 = await PageSections.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PageSection2?.setPage)
{
await
PageSection2.
setPage(relatedPage2);
}
const relatedPage3 = await Pages.findOne({
offset: Math.floor(Math.random() * (await Pages.count())),
});
const PageSection3 = await PageSections.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PageSection3?.setPage)
{
await
PageSection3.
setPage(relatedPage3);
}
}
async function associateInquiryWithAssigned_to() {
const relatedAssigned_to0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Inquiry0 = await Inquiries.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Inquiry0?.setAssigned_to)
{
await
Inquiry0.
setAssigned_to(relatedAssigned_to0);
}
const relatedAssigned_to1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Inquiry1 = await Inquiries.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Inquiry1?.setAssigned_to)
{
await
Inquiry1.
setAssigned_to(relatedAssigned_to1);
}
const relatedAssigned_to2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Inquiry2 = await Inquiries.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Inquiry2?.setAssigned_to)
{
await
Inquiry2.
setAssigned_to(relatedAssigned_to2);
}
const relatedAssigned_to3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Inquiry3 = await Inquiries.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Inquiry3?.setAssigned_to)
{
await
Inquiry3.
setAssigned_to(relatedAssigned_to3);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await SiteSettings.bulkCreate(SiteSettingsData);
await Pages.bulkCreate(PagesData);
await PageSections.bulkCreate(PageSectionsData);
await Services.bulkCreate(ServicesData);
await PortfolioItems.bulkCreate(PortfolioItemsData);
await Testimonials.bulkCreate(TestimonialsData);
await Skills.bulkCreate(SkillsData);
await Benefits.bulkCreate(BenefitsData);
await SocialLinks.bulkCreate(SocialLinksData);
await Inquiries.bulkCreate(InquiriesData);
await Promise.all([
// Similar logic for "relation_many"
await associatePageWithAuthor(),
await associatePageSectionWithPage(),
await associateInquiryWithAssigned_to(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('site_settings', null, {});
await queryInterface.bulkDelete('pages', null, {});
await queryInterface.bulkDelete('page_sections', null, {});
await queryInterface.bulkDelete('services', null, {});
await queryInterface.bulkDelete('portfolio_items', null, {});
await queryInterface.bulkDelete('testimonials', null, {});
await queryInterface.bulkDelete('skills', null, {});
await queryInterface.bulkDelete('benefits', null, {});
await queryInterface.bulkDelete('social_links', null, {});
await queryInterface.bulkDelete('inquiries', null, {});
},
};