1064 lines
26 KiB
JavaScript
1064 lines
26 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Experts = db.experts;
|
|
|
|
const Matches = db.matches;
|
|
|
|
const Problems = db.problems;
|
|
|
|
const ResumeData = db.resume_data;
|
|
|
|
const Translations = db.translations;
|
|
|
|
const Organizations = db.organizations;
|
|
|
|
const ExpertsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
specialization: 'Supply Chain Management',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
specialization: 'Marketing Strategy',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
specialization: 'Cybersecurity',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
specialization: 'Customer Service',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
specialization: 'Product Development',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const MatchesData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
score: 85.5,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
score: 90,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
score: 88,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
score: 92.5,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
score: 87,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ProblemsData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
title: 'Optimize Supply Chain',
|
|
|
|
description: 'Improve efficiency in the supply chain process.',
|
|
|
|
category: 'operational',
|
|
|
|
status: 'submitted',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
title: 'Develop New Marketing Strategy',
|
|
|
|
description: 'Create a strategy to increase brand awareness.',
|
|
|
|
category: 'technical',
|
|
|
|
status: 'resolved',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
title: 'Enhance Cybersecurity Measures',
|
|
|
|
description: "Strengthen the company's cybersecurity protocols.",
|
|
|
|
category: 'strategic',
|
|
|
|
status: 'submitted',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
title: 'Improve Customer Service',
|
|
|
|
description: 'Develop a plan to enhance customer service experience.',
|
|
|
|
category: 'operational',
|
|
|
|
status: 'refined',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
title: 'Expand Product Line',
|
|
|
|
description: 'Research and propose new products for the market.',
|
|
|
|
category: 'operational',
|
|
|
|
status: 'resolved',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ResumeDataData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
raw_text: "Diana Prince's resume text",
|
|
|
|
structured_data:
|
|
'{name:Diana Prince,skills:[Supply Chain Management,Logistics]}',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
raw_text: "Charlie Brown's resume text",
|
|
|
|
structured_data: '{name:Charlie Brown,skills:[Marketing,Strategy]}',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
raw_text: "Bob Smith's resume text",
|
|
|
|
structured_data: '{name:Bob Smith,skills:[Cybersecurity,Network Security]}',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
raw_text: "Alice Johnson's resume text",
|
|
|
|
structured_data:
|
|
'{name:Alice Johnson,skills:[Customer Service,Communication]}',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
raw_text: "Eve Adams's resume text",
|
|
|
|
structured_data:
|
|
'{name:Eve Adams,skills:[Product Development,Market Research]}',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const TranslationsData = [
|
|
{
|
|
key: 'welcome_message',
|
|
|
|
lang: 'en',
|
|
|
|
value: 'Welcome to the Solving Center',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
key: 'welcome_message',
|
|
|
|
lang: 'fa',
|
|
|
|
value: 'به مرکز حل مسائل خوش آمدید',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
key: 'submit_problem',
|
|
|
|
lang: 'en',
|
|
|
|
value: 'Submit a Problem',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
key: 'submit_problem',
|
|
|
|
lang: 'fa',
|
|
|
|
value: 'یک مسئله ارسال کنید',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
key: 'view_solutions',
|
|
|
|
lang: 'en',
|
|
|
|
value: 'View Solutions',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const OrganizationsData = [
|
|
{
|
|
name: 'Carl Gauss (Karl Friedrich Gauss)',
|
|
},
|
|
|
|
{
|
|
name: 'Carl Gauss (Karl Friedrich Gauss)',
|
|
},
|
|
|
|
{
|
|
name: 'Heike Kamerlingh Onnes',
|
|
},
|
|
|
|
{
|
|
name: 'Paul Dirac',
|
|
},
|
|
|
|
{
|
|
name: 'B. F. Skinner',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateUserWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User0 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (User0?.setOrganization) {
|
|
await User0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User1 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (User1?.setOrganization) {
|
|
await User1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User2 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (User2?.setOrganization) {
|
|
await User2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User3 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (User3?.setOrganization) {
|
|
await User3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User4 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (User4?.setOrganization) {
|
|
await User4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateExpertWithUser() {
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Expert0 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Expert0?.setUser) {
|
|
await Expert0.setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Expert1 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Expert1?.setUser) {
|
|
await Expert1.setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Expert2 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Expert2?.setUser) {
|
|
await Expert2.setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Expert3 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Expert3?.setUser) {
|
|
await Expert3.setUser(relatedUser3);
|
|
}
|
|
|
|
const relatedUser4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Expert4 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Expert4?.setUser) {
|
|
await Expert4.setUser(relatedUser4);
|
|
}
|
|
}
|
|
|
|
async function associateExpertWithResume() {
|
|
const relatedResume0 = await ResumeData.findOne({
|
|
offset: Math.floor(Math.random() * (await ResumeData.count())),
|
|
});
|
|
const Expert0 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Expert0?.setResume) {
|
|
await Expert0.setResume(relatedResume0);
|
|
}
|
|
|
|
const relatedResume1 = await ResumeData.findOne({
|
|
offset: Math.floor(Math.random() * (await ResumeData.count())),
|
|
});
|
|
const Expert1 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Expert1?.setResume) {
|
|
await Expert1.setResume(relatedResume1);
|
|
}
|
|
|
|
const relatedResume2 = await ResumeData.findOne({
|
|
offset: Math.floor(Math.random() * (await ResumeData.count())),
|
|
});
|
|
const Expert2 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Expert2?.setResume) {
|
|
await Expert2.setResume(relatedResume2);
|
|
}
|
|
|
|
const relatedResume3 = await ResumeData.findOne({
|
|
offset: Math.floor(Math.random() * (await ResumeData.count())),
|
|
});
|
|
const Expert3 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Expert3?.setResume) {
|
|
await Expert3.setResume(relatedResume3);
|
|
}
|
|
|
|
const relatedResume4 = await ResumeData.findOne({
|
|
offset: Math.floor(Math.random() * (await ResumeData.count())),
|
|
});
|
|
const Expert4 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Expert4?.setResume) {
|
|
await Expert4.setResume(relatedResume4);
|
|
}
|
|
}
|
|
|
|
async function associateExpertWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Expert0 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Expert0?.setOrganization) {
|
|
await Expert0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Expert1 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Expert1?.setOrganization) {
|
|
await Expert1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Expert2 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Expert2?.setOrganization) {
|
|
await Expert2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Expert3 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Expert3?.setOrganization) {
|
|
await Expert3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Expert4 = await Experts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Expert4?.setOrganization) {
|
|
await Expert4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateMatchWithProblem() {
|
|
const relatedProblem0 = await Problems.findOne({
|
|
offset: Math.floor(Math.random() * (await Problems.count())),
|
|
});
|
|
const Match0 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Match0?.setProblem) {
|
|
await Match0.setProblem(relatedProblem0);
|
|
}
|
|
|
|
const relatedProblem1 = await Problems.findOne({
|
|
offset: Math.floor(Math.random() * (await Problems.count())),
|
|
});
|
|
const Match1 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Match1?.setProblem) {
|
|
await Match1.setProblem(relatedProblem1);
|
|
}
|
|
|
|
const relatedProblem2 = await Problems.findOne({
|
|
offset: Math.floor(Math.random() * (await Problems.count())),
|
|
});
|
|
const Match2 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Match2?.setProblem) {
|
|
await Match2.setProblem(relatedProblem2);
|
|
}
|
|
|
|
const relatedProblem3 = await Problems.findOne({
|
|
offset: Math.floor(Math.random() * (await Problems.count())),
|
|
});
|
|
const Match3 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Match3?.setProblem) {
|
|
await Match3.setProblem(relatedProblem3);
|
|
}
|
|
|
|
const relatedProblem4 = await Problems.findOne({
|
|
offset: Math.floor(Math.random() * (await Problems.count())),
|
|
});
|
|
const Match4 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Match4?.setProblem) {
|
|
await Match4.setProblem(relatedProblem4);
|
|
}
|
|
}
|
|
|
|
async function associateMatchWithExpert() {
|
|
const relatedExpert0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Match0 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Match0?.setExpert) {
|
|
await Match0.setExpert(relatedExpert0);
|
|
}
|
|
|
|
const relatedExpert1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Match1 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Match1?.setExpert) {
|
|
await Match1.setExpert(relatedExpert1);
|
|
}
|
|
|
|
const relatedExpert2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Match2 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Match2?.setExpert) {
|
|
await Match2.setExpert(relatedExpert2);
|
|
}
|
|
|
|
const relatedExpert3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Match3 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Match3?.setExpert) {
|
|
await Match3.setExpert(relatedExpert3);
|
|
}
|
|
|
|
const relatedExpert4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Match4 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Match4?.setExpert) {
|
|
await Match4.setExpert(relatedExpert4);
|
|
}
|
|
}
|
|
|
|
async function associateMatchWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Match0 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Match0?.setOrganization) {
|
|
await Match0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Match1 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Match1?.setOrganization) {
|
|
await Match1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Match2 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Match2?.setOrganization) {
|
|
await Match2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Match3 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Match3?.setOrganization) {
|
|
await Match3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Match4 = await Matches.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Match4?.setOrganization) {
|
|
await Match4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateProblemWithUser() {
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Problem0 = await Problems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Problem0?.setUser) {
|
|
await Problem0.setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Problem1 = await Problems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Problem1?.setUser) {
|
|
await Problem1.setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Problem2 = await Problems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Problem2?.setUser) {
|
|
await Problem2.setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Problem3 = await Problems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Problem3?.setUser) {
|
|
await Problem3.setUser(relatedUser3);
|
|
}
|
|
|
|
const relatedUser4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Problem4 = await Problems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Problem4?.setUser) {
|
|
await Problem4.setUser(relatedUser4);
|
|
}
|
|
}
|
|
|
|
async function associateProblemWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Problem0 = await Problems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Problem0?.setOrganization) {
|
|
await Problem0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Problem1 = await Problems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Problem1?.setOrganization) {
|
|
await Problem1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Problem2 = await Problems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Problem2?.setOrganization) {
|
|
await Problem2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Problem3 = await Problems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Problem3?.setOrganization) {
|
|
await Problem3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Problem4 = await Problems.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Problem4?.setOrganization) {
|
|
await Problem4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateResumeDatumWithUser() {
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ResumeDatum0 = await ResumeData.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (ResumeDatum0?.setUser) {
|
|
await ResumeDatum0.setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ResumeDatum1 = await ResumeData.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (ResumeDatum1?.setUser) {
|
|
await ResumeDatum1.setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ResumeDatum2 = await ResumeData.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (ResumeDatum2?.setUser) {
|
|
await ResumeDatum2.setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ResumeDatum3 = await ResumeData.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (ResumeDatum3?.setUser) {
|
|
await ResumeDatum3.setUser(relatedUser3);
|
|
}
|
|
|
|
const relatedUser4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ResumeDatum4 = await ResumeData.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (ResumeDatum4?.setUser) {
|
|
await ResumeDatum4.setUser(relatedUser4);
|
|
}
|
|
}
|
|
|
|
async function associateResumeDatumWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ResumeDatum0 = await ResumeData.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (ResumeDatum0?.setOrganization) {
|
|
await ResumeDatum0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ResumeDatum1 = await ResumeData.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (ResumeDatum1?.setOrganization) {
|
|
await ResumeDatum1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ResumeDatum2 = await ResumeData.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (ResumeDatum2?.setOrganization) {
|
|
await ResumeDatum2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ResumeDatum3 = await ResumeData.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (ResumeDatum3?.setOrganization) {
|
|
await ResumeDatum3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const ResumeDatum4 = await ResumeData.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (ResumeDatum4?.setOrganization) {
|
|
await ResumeDatum4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateTranslationWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Translation0 = await Translations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Translation0?.setOrganization) {
|
|
await Translation0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Translation1 = await Translations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Translation1?.setOrganization) {
|
|
await Translation1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Translation2 = await Translations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Translation2?.setOrganization) {
|
|
await Translation2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Translation3 = await Translations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Translation3?.setOrganization) {
|
|
await Translation3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Translation4 = await Translations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Translation4?.setOrganization) {
|
|
await Translation4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Experts.bulkCreate(ExpertsData);
|
|
|
|
await Matches.bulkCreate(MatchesData);
|
|
|
|
await Problems.bulkCreate(ProblemsData);
|
|
|
|
await ResumeData.bulkCreate(ResumeDataData);
|
|
|
|
await Translations.bulkCreate(TranslationsData);
|
|
|
|
await Organizations.bulkCreate(OrganizationsData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithOrganization(),
|
|
|
|
await associateExpertWithUser(),
|
|
|
|
await associateExpertWithResume(),
|
|
|
|
await associateExpertWithOrganization(),
|
|
|
|
await associateMatchWithProblem(),
|
|
|
|
await associateMatchWithExpert(),
|
|
|
|
await associateMatchWithOrganization(),
|
|
|
|
await associateProblemWithUser(),
|
|
|
|
await associateProblemWithOrganization(),
|
|
|
|
await associateResumeDatumWithUser(),
|
|
|
|
await associateResumeDatumWithOrganization(),
|
|
|
|
await associateTranslationWithOrganization(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('experts', null, {});
|
|
|
|
await queryInterface.bulkDelete('matches', null, {});
|
|
|
|
await queryInterface.bulkDelete('problems', null, {});
|
|
|
|
await queryInterface.bulkDelete('resume_data', null, {});
|
|
|
|
await queryInterface.bulkDelete('translations', null, {});
|
|
|
|
await queryInterface.bulkDelete('organizations', null, {});
|
|
},
|
|
};
|