2410 lines
50 KiB
JavaScript
2410 lines
50 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Companies = db.companies;
|
|
|
|
const Contacts = db.contacts;
|
|
|
|
const Leads = db.leads;
|
|
|
|
const Deals = db.deals;
|
|
|
|
const Activities = db.activities;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CompaniesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Northbound Software",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"website": "https://northbound.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-212-555-0110",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"industry": "Technology",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Harbor Financial",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"website": "https://harborfin.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-212-555-0111",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"industry": "Finance",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Willow Health",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"website": "https://willowhealth.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-212-555-0112",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"industry": "Retail",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Amber Retail Group",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"website": "https://amberretail.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-212-555-0113",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"industry": "Healthcare",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ContactsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"first_name": "Ethan",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_name": "Park",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "ethan.park@northbound.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-415-555-0201",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"title": "Head of Engineering",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"first_name": "Maya",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_name": "Lopez",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "maya.lopez@harborfin.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-415-555-0202",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"title": "VP Finance",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"first_name": "Noah",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_name": "Adams",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "noah.adams@willowhealth.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-415-555-0203",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"title": "Clinical Program Manager",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"first_name": "Ava",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_name": "Stone",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"email": "ava.stone@amberretail.example.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"phone": "+1-415-555-0204",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"title": "Merchandising Director",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const LeadsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Northbound integration inquiry",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Interested in API integration for single sign on and analytics.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"source": "Web",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Unqualified",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_date": new Date('2025-01-05T09:30:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Harbor Financial billing review",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Requesting demo for billing automation and reconciliation.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"source": "Email",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Contacted",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_date": new Date('2025-01-08T11:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Willow Health compliance lead",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Looking for healthcare compliance workflow and reporting.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"source": "Web",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "New",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_date": new Date('2025-01-10T14:15:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Amber Retail procurement project",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Exploring inventory and procurement integrations for holiday season.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"source": "Referral",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Contacted",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_date": new Date('2025-01-12T10:45:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const DealsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Northbound Enterprise License",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"value": 120000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"stage": "ClosedLost",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"probability": 30,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"close_date": new Date('2025-03-15T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Enterprise license for 250 seats with premium support.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Harbor Financial Billing Suite",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"value": 85000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"stage": "Proposal",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"probability": 55,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"close_date": new Date('2025-02-28T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Billing automation and reconciliation module pilot.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Willow Health Compliance Pack",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"value": 60000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"stage": "ClosedWon",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"probability": 70,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"close_date": new Date('2025-02-10T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Compliance workflows and audit reporting subscription.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Amber Retail Holiday Rollout",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"value": 45000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"currency": "USD",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"stage": "Proposal",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"probability": 45,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"close_date": new Date('2025-03-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Seasonal procurement and inventory features.",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ActivitiesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"subject": "Intro call with Northbound",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"type": "Meeting",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_time": new Date('2025-01-06T15:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_time": new Date('2025-01-06T15:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Discuss integration requirements and timeline.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"subject": "Harbor Financial demo",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"type": "Email",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_time": new Date('2025-01-09T13:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_time": new Date('2025-01-09T14:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Demo covered billing automation features and next steps.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"subject": "Willow Health requirements review",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"type": "Task",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_time": new Date('2025-01-11T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_time": new Date('2025-01-11T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Sent compliance questionnaire and timeline proposal.",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"subject": "Amber Retail procurement briefing",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"type": "Meeting",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_time": new Date('2025-01-13T11:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_time": new Date('2025-01-13T11:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Review integration points with existing procurement system.",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateCompanyWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Company0 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Company0?.setOwner)
|
|
{
|
|
await
|
|
Company0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Company1 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Company1?.setOwner)
|
|
{
|
|
await
|
|
Company1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Company2 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Company2?.setOwner)
|
|
{
|
|
await
|
|
Company2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Company3 = await Companies.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Company3?.setOwner)
|
|
{
|
|
await
|
|
Company3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateContactWithCompany() {
|
|
|
|
const relatedCompany0 = await Companies.findOne({
|
|
offset: Math.floor(Math.random() * (await Companies.count())),
|
|
});
|
|
const Contact0 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Contact0?.setCompany)
|
|
{
|
|
await
|
|
Contact0.
|
|
setCompany(relatedCompany0);
|
|
}
|
|
|
|
const relatedCompany1 = await Companies.findOne({
|
|
offset: Math.floor(Math.random() * (await Companies.count())),
|
|
});
|
|
const Contact1 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Contact1?.setCompany)
|
|
{
|
|
await
|
|
Contact1.
|
|
setCompany(relatedCompany1);
|
|
}
|
|
|
|
const relatedCompany2 = await Companies.findOne({
|
|
offset: Math.floor(Math.random() * (await Companies.count())),
|
|
});
|
|
const Contact2 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Contact2?.setCompany)
|
|
{
|
|
await
|
|
Contact2.
|
|
setCompany(relatedCompany2);
|
|
}
|
|
|
|
const relatedCompany3 = await Companies.findOne({
|
|
offset: Math.floor(Math.random() * (await Companies.count())),
|
|
});
|
|
const Contact3 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Contact3?.setCompany)
|
|
{
|
|
await
|
|
Contact3.
|
|
setCompany(relatedCompany3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateContactWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Contact0 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Contact0?.setOwner)
|
|
{
|
|
await
|
|
Contact0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Contact1 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Contact1?.setOwner)
|
|
{
|
|
await
|
|
Contact1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Contact2 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Contact2?.setOwner)
|
|
{
|
|
await
|
|
Contact2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Contact3 = await Contacts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Contact3?.setOwner)
|
|
{
|
|
await
|
|
Contact3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateLeadWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Lead0 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lead0?.setOwner)
|
|
{
|
|
await
|
|
Lead0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Lead1 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lead1?.setOwner)
|
|
{
|
|
await
|
|
Lead1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Lead2 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lead2?.setOwner)
|
|
{
|
|
await
|
|
Lead2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Lead3 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Lead3?.setOwner)
|
|
{
|
|
await
|
|
Lead3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateLeadWithContact() {
|
|
|
|
const relatedContact0 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Lead0 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lead0?.setContact)
|
|
{
|
|
await
|
|
Lead0.
|
|
setContact(relatedContact0);
|
|
}
|
|
|
|
const relatedContact1 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Lead1 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lead1?.setContact)
|
|
{
|
|
await
|
|
Lead1.
|
|
setContact(relatedContact1);
|
|
}
|
|
|
|
const relatedContact2 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Lead2 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lead2?.setContact)
|
|
{
|
|
await
|
|
Lead2.
|
|
setContact(relatedContact2);
|
|
}
|
|
|
|
const relatedContact3 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Lead3 = await Leads.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Lead3?.setContact)
|
|
{
|
|
await
|
|
Lead3.
|
|
setContact(relatedContact3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateDealWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Deal0 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Deal0?.setOwner)
|
|
{
|
|
await
|
|
Deal0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Deal1 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Deal1?.setOwner)
|
|
{
|
|
await
|
|
Deal1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Deal2 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Deal2?.setOwner)
|
|
{
|
|
await
|
|
Deal2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Deal3 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Deal3?.setOwner)
|
|
{
|
|
await
|
|
Deal3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateDealWithContact() {
|
|
|
|
const relatedContact0 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Deal0 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Deal0?.setContact)
|
|
{
|
|
await
|
|
Deal0.
|
|
setContact(relatedContact0);
|
|
}
|
|
|
|
const relatedContact1 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Deal1 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Deal1?.setContact)
|
|
{
|
|
await
|
|
Deal1.
|
|
setContact(relatedContact1);
|
|
}
|
|
|
|
const relatedContact2 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Deal2 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Deal2?.setContact)
|
|
{
|
|
await
|
|
Deal2.
|
|
setContact(relatedContact2);
|
|
}
|
|
|
|
const relatedContact3 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Deal3 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Deal3?.setContact)
|
|
{
|
|
await
|
|
Deal3.
|
|
setContact(relatedContact3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateDealWithCompany() {
|
|
|
|
const relatedCompany0 = await Companies.findOne({
|
|
offset: Math.floor(Math.random() * (await Companies.count())),
|
|
});
|
|
const Deal0 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Deal0?.setCompany)
|
|
{
|
|
await
|
|
Deal0.
|
|
setCompany(relatedCompany0);
|
|
}
|
|
|
|
const relatedCompany1 = await Companies.findOne({
|
|
offset: Math.floor(Math.random() * (await Companies.count())),
|
|
});
|
|
const Deal1 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Deal1?.setCompany)
|
|
{
|
|
await
|
|
Deal1.
|
|
setCompany(relatedCompany1);
|
|
}
|
|
|
|
const relatedCompany2 = await Companies.findOne({
|
|
offset: Math.floor(Math.random() * (await Companies.count())),
|
|
});
|
|
const Deal2 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Deal2?.setCompany)
|
|
{
|
|
await
|
|
Deal2.
|
|
setCompany(relatedCompany2);
|
|
}
|
|
|
|
const relatedCompany3 = await Companies.findOne({
|
|
offset: Math.floor(Math.random() * (await Companies.count())),
|
|
});
|
|
const Deal3 = await Deals.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Deal3?.setCompany)
|
|
{
|
|
await
|
|
Deal3.
|
|
setCompany(relatedCompany3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateActivityWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Activity0 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Activity0?.setOwner)
|
|
{
|
|
await
|
|
Activity0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Activity1 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Activity1?.setOwner)
|
|
{
|
|
await
|
|
Activity1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Activity2 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Activity2?.setOwner)
|
|
{
|
|
await
|
|
Activity2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Activity3 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Activity3?.setOwner)
|
|
{
|
|
await
|
|
Activity3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateActivityWithRelated_deal() {
|
|
|
|
const relatedRelated_deal0 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Activity0 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Activity0?.setRelated_deal)
|
|
{
|
|
await
|
|
Activity0.
|
|
setRelated_deal(relatedRelated_deal0);
|
|
}
|
|
|
|
const relatedRelated_deal1 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Activity1 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Activity1?.setRelated_deal)
|
|
{
|
|
await
|
|
Activity1.
|
|
setRelated_deal(relatedRelated_deal1);
|
|
}
|
|
|
|
const relatedRelated_deal2 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Activity2 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Activity2?.setRelated_deal)
|
|
{
|
|
await
|
|
Activity2.
|
|
setRelated_deal(relatedRelated_deal2);
|
|
}
|
|
|
|
const relatedRelated_deal3 = await Deals.findOne({
|
|
offset: Math.floor(Math.random() * (await Deals.count())),
|
|
});
|
|
const Activity3 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Activity3?.setRelated_deal)
|
|
{
|
|
await
|
|
Activity3.
|
|
setRelated_deal(relatedRelated_deal3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateActivityWithRelated_lead() {
|
|
|
|
const relatedRelated_lead0 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Activity0 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Activity0?.setRelated_lead)
|
|
{
|
|
await
|
|
Activity0.
|
|
setRelated_lead(relatedRelated_lead0);
|
|
}
|
|
|
|
const relatedRelated_lead1 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Activity1 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Activity1?.setRelated_lead)
|
|
{
|
|
await
|
|
Activity1.
|
|
setRelated_lead(relatedRelated_lead1);
|
|
}
|
|
|
|
const relatedRelated_lead2 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Activity2 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Activity2?.setRelated_lead)
|
|
{
|
|
await
|
|
Activity2.
|
|
setRelated_lead(relatedRelated_lead2);
|
|
}
|
|
|
|
const relatedRelated_lead3 = await Leads.findOne({
|
|
offset: Math.floor(Math.random() * (await Leads.count())),
|
|
});
|
|
const Activity3 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Activity3?.setRelated_lead)
|
|
{
|
|
await
|
|
Activity3.
|
|
setRelated_lead(relatedRelated_lead3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateActivityWithRelated_contact() {
|
|
|
|
const relatedRelated_contact0 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Activity0 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Activity0?.setRelated_contact)
|
|
{
|
|
await
|
|
Activity0.
|
|
setRelated_contact(relatedRelated_contact0);
|
|
}
|
|
|
|
const relatedRelated_contact1 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Activity1 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Activity1?.setRelated_contact)
|
|
{
|
|
await
|
|
Activity1.
|
|
setRelated_contact(relatedRelated_contact1);
|
|
}
|
|
|
|
const relatedRelated_contact2 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Activity2 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Activity2?.setRelated_contact)
|
|
{
|
|
await
|
|
Activity2.
|
|
setRelated_contact(relatedRelated_contact2);
|
|
}
|
|
|
|
const relatedRelated_contact3 = await Contacts.findOne({
|
|
offset: Math.floor(Math.random() * (await Contacts.count())),
|
|
});
|
|
const Activity3 = await Activities.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Activity3?.setRelated_contact)
|
|
{
|
|
await
|
|
Activity3.
|
|
setRelated_contact(relatedRelated_contact3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Companies.bulkCreate(CompaniesData);
|
|
|
|
|
|
|
|
|
|
await Contacts.bulkCreate(ContactsData);
|
|
|
|
|
|
|
|
|
|
await Leads.bulkCreate(LeadsData);
|
|
|
|
|
|
|
|
|
|
await Deals.bulkCreate(DealsData);
|
|
|
|
|
|
|
|
|
|
await Activities.bulkCreate(ActivitiesData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCompanyWithOwner(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateContactWithCompany(),
|
|
|
|
|
|
|
|
|
|
await associateContactWithOwner(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateLeadWithOwner(),
|
|
|
|
|
|
|
|
|
|
await associateLeadWithContact(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateDealWithOwner(),
|
|
|
|
|
|
|
|
|
|
await associateDealWithContact(),
|
|
|
|
|
|
|
|
|
|
await associateDealWithCompany(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateActivityWithOwner(),
|
|
|
|
|
|
|
|
|
|
await associateActivityWithRelated_deal(),
|
|
|
|
|
|
|
|
|
|
await associateActivityWithRelated_lead(),
|
|
|
|
|
|
|
|
|
|
await associateActivityWithRelated_contact(),
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('companies', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('contacts', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('leads', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('deals', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('activities', null, {});
|
|
|
|
|
|
},
|
|
}; |