34136/backend/src/db/seeders/20231127130745-sample-data.js
2025-09-17 09:46:25 +00:00

860 lines
20 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const db = require('../models');
const Users = db.users;
const Clients = db.clients;
const Commissions = db.commissions;
const Firms = db.firms;
const Offers = db.offers;
const Providers = db.providers;
const Requests = db.requests;
const Firmă = db.firmă;
const ClientsData = [
{
name: 'Arthur Eddington',
email: 'otelia.barrows@jacobi.test',
phone: '539 563 9604',
// type code here for "relation_one" field
},
{
name: 'Max Born',
email: 'ricky@oreilly.example',
phone: '431-330-3020',
// type code here for "relation_one" field
},
{
name: 'Max Planck',
email: 'charlesetta@vonrueden-pacocha.test',
phone: '528.756.8079',
// type code here for "relation_one" field
},
{
name: 'J. Robert Oppenheimer',
email: 'linn_lebsack@daniel.test',
phone: '774-008-6934',
// type code here for "relation_one" field
},
{
name: 'Claude Bernard',
email: 'stephen.dooley@glover.example',
phone: '563 145 3440',
// type code here for "relation_one" field
},
];
const CommissionsData = [
{
amount: 22.25,
billing_date: new Date('2024-12-30'),
// type code here for "relation_one" field
},
{
amount: 72.08,
billing_date: new Date('2025-04-02'),
// type code here for "relation_one" field
},
{
amount: 38.19,
billing_date: new Date('2025-02-16'),
// type code here for "relation_one" field
},
{
amount: 92.43,
billing_date: new Date('2025-07-10'),
// type code here for "relation_one" field
},
{
amount: 66.87,
billing_date: new Date('2025-07-13'),
// type code here for "relation_one" field
},
];
const FirmsData = [
{
name: 'Charles Sherrington',
address: 'Suite 659 644 Judi Mountains, Port Aleidamouth, WV 77659-3774',
contact_email: 'Let me tell ya',
contact_phone: 'I want my damn cart back',
},
{
name: 'James Clerk Maxwell',
address: '493 Will Inlet, Tyeshastad, ID 22921-8762',
contact_email: 'That damn Bill Stull',
contact_phone: "That's messed up",
},
{
name: 'Carl Gauss (Karl Friedrich Gauss)',
address: '31842 Murray Island, Krisfort, PA 81664-3813',
contact_email: 'That damn Bill Stull',
contact_phone: "I'm washing my hands of it",
},
{
name: 'Jonas Salk',
address: '351 Luke Estates, South Kirstenside, WI 94046-9450',
contact_email: 'Like a red-headed stepchild',
contact_phone: 'Standby',
},
{
name: 'Marcello Malpighi',
address: '459 Mann Road, Schroederberg, HI 74439',
contact_email: "How 'bout them Cowboys",
contact_phone: 'That damn gimble',
},
];
const OffersData = [
{
price: 48.76,
intervention_date: new Date('2024-11-20'),
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
price: 80.09,
intervention_date: new Date('2025-04-14'),
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
price: 92.28,
intervention_date: new Date('2024-11-25'),
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
price: 58.18,
intervention_date: new Date('2025-02-18'),
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
price: 96.47,
intervention_date: new Date('2025-05-03'),
// type code here for "relation_one" field
// type code here for "relation_one" field
},
];
const ProvidersData = [
{
company_name: 'My boss gonna fire me',
service_areas: 'At an end your rule is, and not short enough it was!',
services_offered: 'Feel the force!',
base_rate: 78.64,
// type code here for "relation_one" field
},
{
company_name: 'No one tells me shit',
service_areas:
'Once you start down the dark path, forever will it dominate your destiny, consume you it will.',
services_offered: 'Younglings, younglings gather round.',
base_rate: 97.92,
// type code here for "relation_one" field
},
{
company_name: "That's messed up",
service_areas:
'Ready are you? What know you of ready? For eight hundred years have I trained Jedi. My own counsel will I keep on who is to be trained. A Jedi must have the deepest commitment, the most serious mind. This one a long time have I watched. All his life has he looked away - to the future, to the horizon. Never his mind on where he was. Hmm? What he was doing. Hmph. Adventure. Heh. Excitement. Heh. A Jedi craves not these things. You are reckless.',
services_offered: 'Not if anything to say about it I have',
base_rate: 30.42,
// type code here for "relation_one" field
},
{
company_name: 'So I was walking Oscar',
service_areas: 'At an end your rule is, and not short enough it was!',
services_offered:
'Through the Force, things you will see. Other places. The future - the past. Old friends long gone.',
base_rate: 31.07,
// type code here for "relation_one" field
},
{
company_name: 'So I was walking Oscar',
service_areas: 'Luminous beings are we - not this crude matter.',
services_offered: 'Your weapons, you will not need them.',
base_rate: 90.13,
// type code here for "relation_one" field
},
];
const RequestsData = [
{
county: 'My buddy Harlen',
locality: "How 'bout them Cowboys",
address: '48398 Devin Hills, Schmidttown, WA 61796-2181',
water_type: 'industrial',
approx_volume: 29.42,
distance_truck_to_tank: 36.98,
details: 'Hmm. In the end, cowards are those who follow the dark side.',
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
county: 'I want my damn cart back',
locality: "That Barbala couldn't fly his way out of a wet paper bag",
address: '994 Treutel Road, Kendrickfurt, IN 78915',
water_type: 'industrial',
approx_volume: 99.35,
distance_truck_to_tank: 34.36,
details:
'Yes, a Jedis strength flows from the Force. But beware of the dark side. Anger, fear, aggression; the dark side of the Force are they. Easily they flow, quick to join you in a fight. If once you start down the dark path, forever will it dominate your destiny, consume you it will, as it did Obi-Wans apprentice.',
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
county: 'My boss gonna fire me',
locality: 'Always the last one to the party',
address: '3195 Felipa Lodge, Bruenmouth, SD 51145-8042',
water_type: 'menajer',
approx_volume: 23.61,
distance_truck_to_tank: 91.13,
details:
'Always two there are, no more, no less. A master and an apprentice.',
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
county: "I'm washing my hands of it",
locality: "That Barbala couldn't fly his way out of a wet paper bag",
address: '600 Mertz Land, West Antonio, AZ 04758',
water_type: 'industrial',
approx_volume: 16.37,
distance_truck_to_tank: 26.26,
details: 'Luminous beings are we - not this crude matter.',
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
county: 'That damn diabetes',
locality: "That's messed up",
address: 'Apt. 409 304 Tarah Brook, Runtestad, WV 01315-3341',
water_type: 'industrial',
approx_volume: 67.13,
distance_truck_to_tank: 95.23,
details:
'Like fire across the galaxy the Clone Wars spread. In league with the wicked Count Dooku, more and more planets slip. Against this threat, upon the Jedi Knights falls the duty to lead the newly formed army of the Republic. And as the heat of war grows, so, to, grows the prowess of one most gifted student of the Force.',
// type code here for "relation_one" field
// type code here for "relation_one" field
},
];
const FirmăData = [
{
name: 'J. Robert Oppenheimer',
},
{
name: 'Thomas Hunt Morgan',
},
{
name: 'Isaac Newton',
},
{
name: 'Edward O. Wilson',
},
{
name: 'Max von Laue',
},
];
// Similar logic for "relation_many"
async function associateClientWithFirm() {
const relatedFirm0 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Client0 = await Clients.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Client0?.setFirm) {
await Client0.setFirm(relatedFirm0);
}
const relatedFirm1 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Client1 = await Clients.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Client1?.setFirm) {
await Client1.setFirm(relatedFirm1);
}
const relatedFirm2 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Client2 = await Clients.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Client2?.setFirm) {
await Client2.setFirm(relatedFirm2);
}
const relatedFirm3 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Client3 = await Clients.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Client3?.setFirm) {
await Client3.setFirm(relatedFirm3);
}
const relatedFirm4 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Client4 = await Clients.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Client4?.setFirm) {
await Client4.setFirm(relatedFirm4);
}
}
async function associateCommissionWithProvider() {
const relatedProvider0 = await Providers.findOne({
offset: Math.floor(Math.random() * (await Providers.count())),
});
const Commission0 = await Commissions.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Commission0?.setProvider) {
await Commission0.setProvider(relatedProvider0);
}
const relatedProvider1 = await Providers.findOne({
offset: Math.floor(Math.random() * (await Providers.count())),
});
const Commission1 = await Commissions.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Commission1?.setProvider) {
await Commission1.setProvider(relatedProvider1);
}
const relatedProvider2 = await Providers.findOne({
offset: Math.floor(Math.random() * (await Providers.count())),
});
const Commission2 = await Commissions.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Commission2?.setProvider) {
await Commission2.setProvider(relatedProvider2);
}
const relatedProvider3 = await Providers.findOne({
offset: Math.floor(Math.random() * (await Providers.count())),
});
const Commission3 = await Commissions.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Commission3?.setProvider) {
await Commission3.setProvider(relatedProvider3);
}
const relatedProvider4 = await Providers.findOne({
offset: Math.floor(Math.random() * (await Providers.count())),
});
const Commission4 = await Commissions.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Commission4?.setProvider) {
await Commission4.setProvider(relatedProvider4);
}
}
async function associateOfferWithRequest() {
const relatedRequest0 = await Requests.findOne({
offset: Math.floor(Math.random() * (await Requests.count())),
});
const Offer0 = await Offers.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Offer0?.setRequest) {
await Offer0.setRequest(relatedRequest0);
}
const relatedRequest1 = await Requests.findOne({
offset: Math.floor(Math.random() * (await Requests.count())),
});
const Offer1 = await Offers.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Offer1?.setRequest) {
await Offer1.setRequest(relatedRequest1);
}
const relatedRequest2 = await Requests.findOne({
offset: Math.floor(Math.random() * (await Requests.count())),
});
const Offer2 = await Offers.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Offer2?.setRequest) {
await Offer2.setRequest(relatedRequest2);
}
const relatedRequest3 = await Requests.findOne({
offset: Math.floor(Math.random() * (await Requests.count())),
});
const Offer3 = await Offers.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Offer3?.setRequest) {
await Offer3.setRequest(relatedRequest3);
}
const relatedRequest4 = await Requests.findOne({
offset: Math.floor(Math.random() * (await Requests.count())),
});
const Offer4 = await Offers.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Offer4?.setRequest) {
await Offer4.setRequest(relatedRequest4);
}
}
async function associateOfferWithProvider() {
const relatedProvider0 = await Providers.findOne({
offset: Math.floor(Math.random() * (await Providers.count())),
});
const Offer0 = await Offers.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Offer0?.setProvider) {
await Offer0.setProvider(relatedProvider0);
}
const relatedProvider1 = await Providers.findOne({
offset: Math.floor(Math.random() * (await Providers.count())),
});
const Offer1 = await Offers.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Offer1?.setProvider) {
await Offer1.setProvider(relatedProvider1);
}
const relatedProvider2 = await Providers.findOne({
offset: Math.floor(Math.random() * (await Providers.count())),
});
const Offer2 = await Offers.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Offer2?.setProvider) {
await Offer2.setProvider(relatedProvider2);
}
const relatedProvider3 = await Providers.findOne({
offset: Math.floor(Math.random() * (await Providers.count())),
});
const Offer3 = await Offers.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Offer3?.setProvider) {
await Offer3.setProvider(relatedProvider3);
}
const relatedProvider4 = await Providers.findOne({
offset: Math.floor(Math.random() * (await Providers.count())),
});
const Offer4 = await Offers.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Offer4?.setProvider) {
await Offer4.setProvider(relatedProvider4);
}
}
async function associateProviderWithFirm() {
const relatedFirm0 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Provider0 = await Providers.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Provider0?.setFirm) {
await Provider0.setFirm(relatedFirm0);
}
const relatedFirm1 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Provider1 = await Providers.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Provider1?.setFirm) {
await Provider1.setFirm(relatedFirm1);
}
const relatedFirm2 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Provider2 = await Providers.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Provider2?.setFirm) {
await Provider2.setFirm(relatedFirm2);
}
const relatedFirm3 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Provider3 = await Providers.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Provider3?.setFirm) {
await Provider3.setFirm(relatedFirm3);
}
const relatedFirm4 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Provider4 = await Providers.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Provider4?.setFirm) {
await Provider4.setFirm(relatedFirm4);
}
}
async function associateRequestWithClient() {
const relatedClient0 = await Clients.findOne({
offset: Math.floor(Math.random() * (await Clients.count())),
});
const Request0 = await Requests.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Request0?.setClient) {
await Request0.setClient(relatedClient0);
}
const relatedClient1 = await Clients.findOne({
offset: Math.floor(Math.random() * (await Clients.count())),
});
const Request1 = await Requests.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Request1?.setClient) {
await Request1.setClient(relatedClient1);
}
const relatedClient2 = await Clients.findOne({
offset: Math.floor(Math.random() * (await Clients.count())),
});
const Request2 = await Requests.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Request2?.setClient) {
await Request2.setClient(relatedClient2);
}
const relatedClient3 = await Clients.findOne({
offset: Math.floor(Math.random() * (await Clients.count())),
});
const Request3 = await Requests.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Request3?.setClient) {
await Request3.setClient(relatedClient3);
}
const relatedClient4 = await Clients.findOne({
offset: Math.floor(Math.random() * (await Clients.count())),
});
const Request4 = await Requests.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Request4?.setClient) {
await Request4.setClient(relatedClient4);
}
}
async function associateRequestWithFirm() {
const relatedFirm0 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Request0 = await Requests.findOne({
order: [['id', 'ASC']],
offset: 0,
});
if (Request0?.setFirm) {
await Request0.setFirm(relatedFirm0);
}
const relatedFirm1 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Request1 = await Requests.findOne({
order: [['id', 'ASC']],
offset: 1,
});
if (Request1?.setFirm) {
await Request1.setFirm(relatedFirm1);
}
const relatedFirm2 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Request2 = await Requests.findOne({
order: [['id', 'ASC']],
offset: 2,
});
if (Request2?.setFirm) {
await Request2.setFirm(relatedFirm2);
}
const relatedFirm3 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Request3 = await Requests.findOne({
order: [['id', 'ASC']],
offset: 3,
});
if (Request3?.setFirm) {
await Request3.setFirm(relatedFirm3);
}
const relatedFirm4 = await Firms.findOne({
offset: Math.floor(Math.random() * (await Firms.count())),
});
const Request4 = await Requests.findOne({
order: [['id', 'ASC']],
offset: 4,
});
if (Request4?.setFirm) {
await Request4.setFirm(relatedFirm4);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Clients.bulkCreate(ClientsData);
await Commissions.bulkCreate(CommissionsData);
await Firms.bulkCreate(FirmsData);
await Offers.bulkCreate(OffersData);
await Providers.bulkCreate(ProvidersData);
await Requests.bulkCreate(RequestsData);
await Firmă.bulkCreate(FirmăData);
await Promise.all([
// Similar logic for "relation_many"
await associateClientWithFirm(),
await associateCommissionWithProvider(),
await associateOfferWithRequest(),
await associateOfferWithProvider(),
await associateProviderWithFirm(),
await associateRequestWithClient(),
await associateRequestWithFirm(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('clients', null, {});
await queryInterface.bulkDelete('commissions', null, {});
await queryInterface.bulkDelete('firms', null, {});
await queryInterface.bulkDelete('offers', null, {});
await queryInterface.bulkDelete('providers', null, {});
await queryInterface.bulkDelete('requests', null, {});
await queryInterface.bulkDelete('firmă', null, {});
},
};