38367-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-02-11 23:41:19 +00:00

5983 lines
124 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const AdvertiserOrganizations = db.advertiser_organizations;
const PaymentMethods = db.payment_methods;
const AdvertiserWallets = db.advertiser_wallets;
const AdvertiserTopups = db.advertiser_topups;
const AdCampaigns = db.ad_campaigns;
const Ads = db.ads;
const ViewerWallets = db.viewer_wallets;
const AdViews = db.ad_views;
const RewardLedgerEntries = db.reward_ledger_entries;
const WithdrawalRequests = db.withdrawal_requests;
const FraudFlags = db.fraud_flags;
const PlatformSettings = db.platform_settings;
const AdvertiserOrganizationsData = [
{
"name": "Northstar Media Network",
},
{
"name": "BluePeak Consumer Goods",
},
{
"name": "Aurora Mobile Ads",
},
{
"name": "Cedar & Co Agency",
},
];
const PaymentMethodsData = [
{
"name": "PayPal Payouts",
"type": "crypto",
"direction": "both",
"enabled": true,
"provider_name": "PayPal",
"provider_config": "mode=sandbox",
"instructions": "Use verified PayPal email for payouts and topups",
"supported_countries": "United States, United Kingdom, Canada",
"supported_currencies": "USD, GBP, CAD",
// type code here for "relation_one" field
},
{
"name": "Stripe Card Topups",
"type": "other",
"direction": "payout",
"enabled": true,
"provider_name": "Stripe",
"provider_config": "mode=test",
"instructions": "Card payments for advertiser wallet funding",
"supported_countries": "United States, United Kingdom, France, Germany",
"supported_currencies": "USD, GBP, EUR",
// type code here for "relation_one" field
},
{
"name": "Bank Transfer USD",
"type": "bank_transfer",
"direction": "topup",
"enabled": true,
"provider_name": "Manual Bank",
"provider_config": "beneficiary=EarnEase Inc",
"instructions": "Include reference code in transfer memo",
"supported_countries": "United States",
"supported_currencies": "USD",
// type code here for "relation_one" field
},
{
"name": "Mobile Money KE",
"type": "crypto",
"direction": "topup",
"enabled": true,
"provider_name": "M-Pesa",
"provider_config": "region=KE",
"instructions": "Provide mobile money number matching account name",
"supported_countries": "Kenya",
"supported_currencies": "KES",
// type code here for "relation_one" field
},
];
const AdvertiserWalletsData = [
{
// type code here for "relation_one" field
"currency": "USD",
"balance": 12500.0,
"reserved_balance": 1800.0,
"status": "frozen",
"last_reconciled_at": new Date('2026-02-09T23:00:00Z'),
},
{
// type code here for "relation_one" field
"currency": "GBP",
"balance": 8200.0,
"reserved_balance": 950.0,
"status": "active",
"last_reconciled_at": new Date('2026-02-09T23:00:00Z'),
},
{
// type code here for "relation_one" field
"currency": "USD",
"balance": 1500.0,
"reserved_balance": 0.0,
"status": "frozen",
"last_reconciled_at": new Date('2026-02-08T23:00:00Z'),
},
{
// type code here for "relation_one" field
"currency": "EUR",
"balance": 6400.0,
"reserved_balance": 1200.0,
"status": "active",
"last_reconciled_at": new Date('2026-02-09T23:00:00Z'),
},
];
const AdvertiserTopupsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reference_code": "TOPUP-NSM-2026-0001",
"amount": 5000.0,
"currency": "USD",
"status": "pending",
"initiated_at": new Date('2026-02-01T12:10:00Z'),
"confirmed_at": new Date('2026-02-01T12:12:30Z'),
"provider_transaction_id": "pi_3NsmTopup0001",
// type code here for "files" field
"notes": "Monthly funding",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reference_code": "TOPUP-BP-2026-0001",
"amount": 3000.0,
"currency": "GBP",
"status": "confirmed",
"initiated_at": new Date('2026-02-03T09:05:00Z'),
"confirmed_at": new Date('2026-02-03T09:08:00Z'),
"provider_transaction_id": "pp_txn_884201",
// type code here for "files" field
"notes": "Quarterly campaign budget",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reference_code": "TOPUP-CC-2026-0001",
"amount": 2500.0,
"currency": "EUR",
"status": "confirmed",
"initiated_at": new Date('2026-02-04T15:20:00Z'),
"confirmed_at": new Date('2026-02-04T15:22:00Z'),
"provider_transaction_id": "pi_3CedarTopup0001",
// type code here for "files" field
"notes": "Agency topup for client campaigns",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reference_code": "TOPUP-AMA-2026-0001",
"amount": 1500.0,
"currency": "USD",
"status": "pending",
"initiated_at": new Date('2026-02-07T10:00:00Z'),
"confirmed_at": new Date('2026-02-07T10:00:00Z'),
"provider_transaction_id": "wire_pending_1122",
// type code here for "files" field
"notes": "Awaiting bank confirmation",
// type code here for "relation_one" field
},
];
const AdCampaignsData = [
{
// type code here for "relation_one" field
"name": "Northstar Video Rewards Feb",
"objective": "Drive app installs via rewarded video",
"status": "active",
"start_at": new Date('2026-02-01T00:00:00Z'),
"end_at": new Date('2026-02-28T23:59:59Z'),
"total_budget": 8000.0,
"daily_budget": 300.0,
"currency": "USD",
"frequency_cap_per_day": 5,
"max_views_per_user": 20,
"target_countries": "United States, Canada",
"target_languages": "en",
"target_devices": "android, ios",
"notes": "Primary February campaign",
},
{
// type code here for "relation_one" field
"name": "BluePeak Brand Lift UK",
"objective": "Increase brand awareness",
"status": "pending_review",
"start_at": new Date('2026-02-05T00:00:00Z'),
"end_at": new Date('2026-03-05T23:59:59Z'),
"total_budget": 5000.0,
"daily_budget": 200.0,
"currency": "GBP",
"frequency_cap_per_day": 3,
"max_views_per_user": 12,
"target_countries": "United Kingdom",
"target_languages": "en",
"target_devices": "ios",
"notes": "UK only, iOS focus",
},
{
// type code here for "relation_one" field
"name": "Cedar Client Launch EU",
"objective": "Promote new product launch",
"status": "pending_review",
"start_at": new Date('2026-02-12T00:00:00Z'),
"end_at": new Date('2026-03-12T23:59:59Z'),
"total_budget": 6000.0,
"daily_budget": 250.0,
"currency": "EUR",
"frequency_cap_per_day": 4,
"max_views_per_user": 15,
"target_countries": "France, Germany, Spain",
"target_languages": "fr, de, es",
"target_devices": "android",
"notes": "Awaiting creative approval",
},
{
// type code here for "relation_one" field
"name": "Northstar Retargeting Sprint",
"objective": "Re-engage past viewers",
"status": "active",
"start_at": new Date('2026-01-20T00:00:00Z'),
"end_at": new Date('2026-02-20T23:59:59Z'),
"total_budget": 2000.0,
"daily_budget": 100.0,
"currency": "USD",
"frequency_cap_per_day": 2,
"max_views_per_user": 8,
"target_countries": "United States",
"target_languages": "en",
"target_devices": "android",
"notes": "Paused due to low completion rate",
},
];
const AdsData = [
{
// type code here for "relation_one" field
"title": "Try Finch Fitness App",
"format": "rewarded_video",
"status": "pending_review",
"destination_url": "https://finchfitness.example/install",
"required_watch_seconds": 20,
"payout_per_view": 0.05,
"platform_fee_rate": 0.2,
"currency": "USD",
// type code here for "images" field
// type code here for "files" field
"tracking_url": "https://trk.northstar.example/click?c=ff1",
"network_name": "Northstar Media Network",
"external_ad_code": "vast_tag_ff1",
"approved_at": new Date('2026-02-01T09:30:00Z'),
"review_notes": "Approved for rewards feed",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "StreamBox Free Trial",
"format": "image",
"status": "paused",
"destination_url": "https://streambox.example/trial",
"required_watch_seconds": 25,
"payout_per_view": 0.06,
"platform_fee_rate": 0.2,
"currency": "USD",
// type code here for "images" field
// type code here for "files" field
"tracking_url": "https://trk.northstar.example/click?c=sb1",
"network_name": "Northstar Media Network",
"external_ad_code": "vast_tag_sb1",
"approved_at": new Date('2026-02-01T09:45:00Z'),
"review_notes": "Good quality video creative",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "BluePeak Sparkling Water",
"format": "survey",
"status": "paused",
"destination_url": "https://bluepeakcg.example/sparkling",
"required_watch_seconds": 15,
"payout_per_view": 0.04,
"platform_fee_rate": 0.18,
"currency": "GBP",
// type code here for "images" field
// type code here for "files" field
"tracking_url": "https://trk.bluepeak.example/click?c=bp1",
"network_name": "BluePeak Consumer Goods",
"external_ad_code": "native_bp1",
"approved_at": new Date('2026-02-05T08:10:00Z'),
"review_notes": "Approved with standard targeting",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"title": "EU Launch Teaser",
"format": "survey",
"status": "draft",
"destination_url": "https://clientlaunch.example/eu",
"required_watch_seconds": 10,
"payout_per_view": 0.03,
"platform_fee_rate": 0.18,
"currency": "EUR",
// type code here for "images" field
// type code here for "files" field
"tracking_url": "https://trk.cedarco.example/click?c=eu1",
"network_name": "Cedar & Co Agency",
"external_ad_code": "img_eu1",
"approved_at": new Date('2026-02-10T10:00:00Z'),
"review_notes": "Pending compliance check",
// type code here for "relation_one" field
},
];
const ViewerWalletsData = [
{
// type code here for "relation_one" field
"currency": "GBP",
"available_balance": 12.4,
"pending_balance": 1.2,
"lifetime_earned": 58.75,
"status": "frozen",
"last_payout_at": new Date('2026-01-30T16:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"currency": "MXN",
"available_balance": 220.0,
"pending_balance": 35.0,
"lifetime_earned": 1450.0,
"status": "active",
"last_payout_at": new Date('2026-01-25T12:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"currency": "USD",
"available_balance": 0.0,
"pending_balance": 0.0,
"lifetime_earned": 0.0,
"status": "frozen",
"last_payout_at": new Date('2026-01-01T00:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"currency": "USD",
"available_balance": 0.0,
"pending_balance": 0.0,
"lifetime_earned": 0.0,
"status": "frozen",
"last_payout_at": new Date('2026-01-01T00:00:00Z'),
// type code here for "relation_one" field
},
];
const AdViewsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"started_at": new Date('2026-02-10T17:00:00Z'),
"completed_at": new Date('2026-02-10T17:00:22Z'),
"watched_seconds": 22,
"status": "rejected",
"ip_address": "203.0.113.10",
"user_agent": "Mozilla/5.0 iPhone",
"device_fingerprint": "dfp_9c2a1",
"country": "United Kingdom",
"session_token": "sess_8f2c01",
"credited_amount": 0.05,
"currency": "USD",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"started_at": new Date('2026-02-10T17:10:00Z'),
"completed_at": new Date('2026-02-10T17:10:16Z'),
"watched_seconds": 16,
"status": "fraud_suspected",
"ip_address": "203.0.113.10",
"user_agent": "Mozilla/5.0 iPhone",
"device_fingerprint": "dfp_9c2a1",
"country": "United Kingdom",
"session_token": "sess_8f2c02",
"credited_amount": 0.04,
"currency": "GBP",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"started_at": new Date('2026-02-09T20:30:00Z'),
"completed_at": new Date('2026-02-09T20:30:20Z'),
"watched_seconds": 20,
"status": "rejected",
"ip_address": "198.51.100.22",
"user_agent": "Mozilla/5.0 Android",
"device_fingerprint": "dfp_61bb7",
"country": "Mexico",
"session_token": "sess_71aa10",
"credited_amount": 0.0,
"currency": "USD",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"started_at": new Date('2026-02-09T20:45:00Z'),
"completed_at": new Date('2026-02-09T20:45:21Z'),
"watched_seconds": 21,
"status": "completed",
"ip_address": "198.51.100.22",
"user_agent": "Mozilla/5.0 Android",
"device_fingerprint": "dfp_61bb7",
"country": "Mexico",
"session_token": "sess_71aa11",
"credited_amount": 0.05,
"currency": "USD",
// type code here for "relation_one" field
},
];
const RewardLedgerEntriesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"type": "release",
"status": "pending",
"amount": 0.05,
"currency": "USD",
"description": "Reward for completed ad view",
"occurred_at": new Date('2026-02-10T17:00:23Z'),
"reference": "RLE-2026-000001",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"type": "debit",
"status": "pending",
"amount": 0.04,
"currency": "GBP",
"description": "Reward for completed ad view",
"occurred_at": new Date('2026-02-10T17:10:17Z'),
"reference": "RLE-2026-000002",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"type": "credit",
"status": "posted",
"amount": 0.0,
"currency": "USD",
"description": "No reward due to incomplete watch",
"occurred_at": new Date('2026-02-09T20:30:21Z'),
"reference": "RLE-2026-000003",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"type": "debit",
"status": "reversed",
"amount": 0.05,
"currency": "USD",
"description": "Pending reward verification",
"occurred_at": new Date('2026-02-09T20:45:22Z'),
"reference": "RLE-2026-000004",
// type code here for "relation_one" field
},
];
const WithdrawalRequestsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reference_code": "WD-GBP-2026-0001",
"amount": 10.0,
"currency": "GBP",
"status": "paid",
"requested_at": new Date('2026-01-30T15:00:00Z'),
"processed_at": new Date('2026-01-30T16:00:00Z'),
"payout_details": "paypal_email=sarah.okafor@examplemail.com",
"provider_payout_id": "pp_payout_55101",
"review_notes": "Processed successfully",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reference_code": "WD-MXN-2026-0001",
"amount": 200.0,
"currency": "MXN",
"status": "rejected",
"requested_at": new Date('2026-02-06T10:00:00Z'),
"processed_at": new Date('2026-02-06T14:30:00Z'),
"payout_details": "bank_account=MX-CLABE-002010077777777771",
"provider_payout_id": "wire_22001",
"review_notes": "Approved for next payout batch",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reference_code": "WD-MXN-2026-0002",
"amount": 150.0,
"currency": "MXN",
"status": "requested",
"requested_at": new Date('2026-02-10T09:20:00Z'),
"processed_at": new Date('2026-02-10T09:20:00Z'),
"payout_details": "paypal_email=mateo.rivera@examplemail.com",
"provider_payout_id": "pp_payout_pending_771",
"review_notes": "Review due to location change",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"reference_code": "WD-USD-2026-0001",
"amount": 3.0,
"currency": "USD",
"status": "requested",
"requested_at": new Date('2026-01-10T11:00:00Z'),
"processed_at": new Date('2026-01-10T11:30:00Z'),
"payout_details": "paypal_email=nadia.elsayed@examplemail.com",
"provider_payout_id": "pp_payout_77001",
"review_notes": "Account frozen due to fraud flags",
// type code here for "relation_one" field
},
];
const FraudFlagsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"severity": "critical",
"reason": "device_fingerprint_reuse",
"details": "Fingerprint seen across multiple accounts in short window",
"status": "investigating",
"flagged_at": new Date('2026-02-08T08:05:00Z'),
"resolved_at": new Date('2026-02-10T10:00:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"severity": "low",
"reason": "too_fast_completion",
"details": "Watch time below required threshold",
"status": "resolved",
"flagged_at": new Date('2026-02-09T20:30:25Z'),
"resolved_at": new Date('2026-02-09T20:30:25Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"severity": "medium",
"reason": "vpn_proxy",
"details": "IP geolocation differs slightly from profile country",
"status": "open",
"flagged_at": new Date('2026-02-10T17:01:00Z'),
"resolved_at": new Date('2026-02-10T17:30:00Z'),
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"severity": "high",
"reason": "automation_suspected",
"details": "Proxy/VPN detected during reward attempt",
"status": "investigating",
"flagged_at": new Date('2026-02-08T08:06:00Z'),
"resolved_at": new Date('2026-02-08T08:06:00Z'),
// type code here for "relation_one" field
},
];
const PlatformSettingsData = [
{
"key": "min_withdrawal_amount",
"value": "10",
"description": "Minimum withdrawal amount in wallet currency units",
"value_type": "boolean",
"is_public": true,
// type code here for "relation_one" field
},
{
"key": "reward_hold_minutes",
"value": "30",
"description": "Minutes to hold rewards before posting to available balance",
"value_type": "json",
"is_public": true,
// type code here for "relation_one" field
},
{
"key": "platform_fee_default_rate",
"value": "0.2",
"description": "Default platform fee rate applied to ads if not specified",
"value_type": "string",
"is_public": true,
// type code here for "relation_one" field
},
{
"key": "kyc_required_for_advertisers",
"value": "true",
"description": "Whether advertiser verification is required before activation",
"value_type": "string",
"is_public": true,
// type code here for "relation_one" field
},
];
// Similar logic for "relation_many"
async function associateUserWithAdvertiser_organization() {
const relatedAdvertiser_organization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const User0 = await Users.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (User0?.setAdvertiser_organization)
{
await
User0.
setAdvertiser_organization(relatedAdvertiser_organization0);
}
const relatedAdvertiser_organization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const User1 = await Users.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (User1?.setAdvertiser_organization)
{
await
User1.
setAdvertiser_organization(relatedAdvertiser_organization1);
}
const relatedAdvertiser_organization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const User2 = await Users.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (User2?.setAdvertiser_organization)
{
await
User2.
setAdvertiser_organization(relatedAdvertiser_organization2);
}
const relatedAdvertiser_organization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const User3 = await Users.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (User3?.setAdvertiser_organization)
{
await
User3.
setAdvertiser_organization(relatedAdvertiser_organization3);
}
}
async function associatePaymentMethodWithAdvertiser_organization() {
const relatedAdvertiser_organization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const PaymentMethod0 = await PaymentMethods.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PaymentMethod0?.setAdvertiser_organization)
{
await
PaymentMethod0.
setAdvertiser_organization(relatedAdvertiser_organization0);
}
const relatedAdvertiser_organization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const PaymentMethod1 = await PaymentMethods.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PaymentMethod1?.setAdvertiser_organization)
{
await
PaymentMethod1.
setAdvertiser_organization(relatedAdvertiser_organization1);
}
const relatedAdvertiser_organization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const PaymentMethod2 = await PaymentMethods.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PaymentMethod2?.setAdvertiser_organization)
{
await
PaymentMethod2.
setAdvertiser_organization(relatedAdvertiser_organization2);
}
const relatedAdvertiser_organization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const PaymentMethod3 = await PaymentMethods.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PaymentMethod3?.setAdvertiser_organization)
{
await
PaymentMethod3.
setAdvertiser_organization(relatedAdvertiser_organization3);
}
}
async function associateAdvertiserWalletWithOrganization() {
const relatedOrganization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdvertiserWallet0 = await AdvertiserWallets.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdvertiserWallet0?.setOrganization)
{
await
AdvertiserWallet0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdvertiserWallet1 = await AdvertiserWallets.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdvertiserWallet1?.setOrganization)
{
await
AdvertiserWallet1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdvertiserWallet2 = await AdvertiserWallets.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdvertiserWallet2?.setOrganization)
{
await
AdvertiserWallet2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdvertiserWallet3 = await AdvertiserWallets.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdvertiserWallet3?.setOrganization)
{
await
AdvertiserWallet3.
setOrganization(relatedOrganization3);
}
}
async function associateAdvertiserTopupWithWallet() {
const relatedWallet0 = await AdvertiserWallets.findOne({
offset: Math.floor(Math.random() * (await AdvertiserWallets.count())),
});
const AdvertiserTopup0 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdvertiserTopup0?.setWallet)
{
await
AdvertiserTopup0.
setWallet(relatedWallet0);
}
const relatedWallet1 = await AdvertiserWallets.findOne({
offset: Math.floor(Math.random() * (await AdvertiserWallets.count())),
});
const AdvertiserTopup1 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdvertiserTopup1?.setWallet)
{
await
AdvertiserTopup1.
setWallet(relatedWallet1);
}
const relatedWallet2 = await AdvertiserWallets.findOne({
offset: Math.floor(Math.random() * (await AdvertiserWallets.count())),
});
const AdvertiserTopup2 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdvertiserTopup2?.setWallet)
{
await
AdvertiserTopup2.
setWallet(relatedWallet2);
}
const relatedWallet3 = await AdvertiserWallets.findOne({
offset: Math.floor(Math.random() * (await AdvertiserWallets.count())),
});
const AdvertiserTopup3 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdvertiserTopup3?.setWallet)
{
await
AdvertiserTopup3.
setWallet(relatedWallet3);
}
}
async function associateAdvertiserTopupWithPayment_method() {
const relatedPayment_method0 = await PaymentMethods.findOne({
offset: Math.floor(Math.random() * (await PaymentMethods.count())),
});
const AdvertiserTopup0 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdvertiserTopup0?.setPayment_method)
{
await
AdvertiserTopup0.
setPayment_method(relatedPayment_method0);
}
const relatedPayment_method1 = await PaymentMethods.findOne({
offset: Math.floor(Math.random() * (await PaymentMethods.count())),
});
const AdvertiserTopup1 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdvertiserTopup1?.setPayment_method)
{
await
AdvertiserTopup1.
setPayment_method(relatedPayment_method1);
}
const relatedPayment_method2 = await PaymentMethods.findOne({
offset: Math.floor(Math.random() * (await PaymentMethods.count())),
});
const AdvertiserTopup2 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdvertiserTopup2?.setPayment_method)
{
await
AdvertiserTopup2.
setPayment_method(relatedPayment_method2);
}
const relatedPayment_method3 = await PaymentMethods.findOne({
offset: Math.floor(Math.random() * (await PaymentMethods.count())),
});
const AdvertiserTopup3 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdvertiserTopup3?.setPayment_method)
{
await
AdvertiserTopup3.
setPayment_method(relatedPayment_method3);
}
}
async function associateAdvertiserTopupWithAdvertiser_organization() {
const relatedAdvertiser_organization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdvertiserTopup0 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdvertiserTopup0?.setAdvertiser_organization)
{
await
AdvertiserTopup0.
setAdvertiser_organization(relatedAdvertiser_organization0);
}
const relatedAdvertiser_organization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdvertiserTopup1 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdvertiserTopup1?.setAdvertiser_organization)
{
await
AdvertiserTopup1.
setAdvertiser_organization(relatedAdvertiser_organization1);
}
const relatedAdvertiser_organization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdvertiserTopup2 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdvertiserTopup2?.setAdvertiser_organization)
{
await
AdvertiserTopup2.
setAdvertiser_organization(relatedAdvertiser_organization2);
}
const relatedAdvertiser_organization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdvertiserTopup3 = await AdvertiserTopups.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdvertiserTopup3?.setAdvertiser_organization)
{
await
AdvertiserTopup3.
setAdvertiser_organization(relatedAdvertiser_organization3);
}
}
async function associateAdCampaignWithOrganization() {
const relatedOrganization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdCampaign0 = await AdCampaigns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdCampaign0?.setOrganization)
{
await
AdCampaign0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdCampaign1 = await AdCampaigns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdCampaign1?.setOrganization)
{
await
AdCampaign1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdCampaign2 = await AdCampaigns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdCampaign2?.setOrganization)
{
await
AdCampaign2.
setOrganization(relatedOrganization2);
}
const relatedOrganization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdCampaign3 = await AdCampaigns.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdCampaign3?.setOrganization)
{
await
AdCampaign3.
setOrganization(relatedOrganization3);
}
}
async function associateAdWithCampaign() {
const relatedCampaign0 = await AdCampaigns.findOne({
offset: Math.floor(Math.random() * (await AdCampaigns.count())),
});
const Ad0 = await Ads.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Ad0?.setCampaign)
{
await
Ad0.
setCampaign(relatedCampaign0);
}
const relatedCampaign1 = await AdCampaigns.findOne({
offset: Math.floor(Math.random() * (await AdCampaigns.count())),
});
const Ad1 = await Ads.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Ad1?.setCampaign)
{
await
Ad1.
setCampaign(relatedCampaign1);
}
const relatedCampaign2 = await AdCampaigns.findOne({
offset: Math.floor(Math.random() * (await AdCampaigns.count())),
});
const Ad2 = await Ads.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Ad2?.setCampaign)
{
await
Ad2.
setCampaign(relatedCampaign2);
}
const relatedCampaign3 = await AdCampaigns.findOne({
offset: Math.floor(Math.random() * (await AdCampaigns.count())),
});
const Ad3 = await Ads.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Ad3?.setCampaign)
{
await
Ad3.
setCampaign(relatedCampaign3);
}
}
async function associateAdWithAdvertiser_organization() {
const relatedAdvertiser_organization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const Ad0 = await Ads.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Ad0?.setAdvertiser_organization)
{
await
Ad0.
setAdvertiser_organization(relatedAdvertiser_organization0);
}
const relatedAdvertiser_organization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const Ad1 = await Ads.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Ad1?.setAdvertiser_organization)
{
await
Ad1.
setAdvertiser_organization(relatedAdvertiser_organization1);
}
const relatedAdvertiser_organization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const Ad2 = await Ads.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Ad2?.setAdvertiser_organization)
{
await
Ad2.
setAdvertiser_organization(relatedAdvertiser_organization2);
}
const relatedAdvertiser_organization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const Ad3 = await Ads.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Ad3?.setAdvertiser_organization)
{
await
Ad3.
setAdvertiser_organization(relatedAdvertiser_organization3);
}
}
async function associateViewerWalletWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ViewerWallet0 = await ViewerWallets.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ViewerWallet0?.setUser)
{
await
ViewerWallet0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ViewerWallet1 = await ViewerWallets.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ViewerWallet1?.setUser)
{
await
ViewerWallet1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ViewerWallet2 = await ViewerWallets.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ViewerWallet2?.setUser)
{
await
ViewerWallet2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ViewerWallet3 = await ViewerWallets.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ViewerWallet3?.setUser)
{
await
ViewerWallet3.
setUser(relatedUser3);
}
}
async function associateViewerWalletWithAdvertiser_organization() {
const relatedAdvertiser_organization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const ViewerWallet0 = await ViewerWallets.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ViewerWallet0?.setAdvertiser_organization)
{
await
ViewerWallet0.
setAdvertiser_organization(relatedAdvertiser_organization0);
}
const relatedAdvertiser_organization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const ViewerWallet1 = await ViewerWallets.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ViewerWallet1?.setAdvertiser_organization)
{
await
ViewerWallet1.
setAdvertiser_organization(relatedAdvertiser_organization1);
}
const relatedAdvertiser_organization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const ViewerWallet2 = await ViewerWallets.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ViewerWallet2?.setAdvertiser_organization)
{
await
ViewerWallet2.
setAdvertiser_organization(relatedAdvertiser_organization2);
}
const relatedAdvertiser_organization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const ViewerWallet3 = await ViewerWallets.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ViewerWallet3?.setAdvertiser_organization)
{
await
ViewerWallet3.
setAdvertiser_organization(relatedAdvertiser_organization3);
}
}
async function associateAdViewWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdView0 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdView0?.setUser)
{
await
AdView0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdView1 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdView1?.setUser)
{
await
AdView1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdView2 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdView2?.setUser)
{
await
AdView2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const AdView3 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdView3?.setUser)
{
await
AdView3.
setUser(relatedUser3);
}
}
async function associateAdViewWithAd() {
const relatedAd0 = await Ads.findOne({
offset: Math.floor(Math.random() * (await Ads.count())),
});
const AdView0 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdView0?.setAd)
{
await
AdView0.
setAd(relatedAd0);
}
const relatedAd1 = await Ads.findOne({
offset: Math.floor(Math.random() * (await Ads.count())),
});
const AdView1 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdView1?.setAd)
{
await
AdView1.
setAd(relatedAd1);
}
const relatedAd2 = await Ads.findOne({
offset: Math.floor(Math.random() * (await Ads.count())),
});
const AdView2 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdView2?.setAd)
{
await
AdView2.
setAd(relatedAd2);
}
const relatedAd3 = await Ads.findOne({
offset: Math.floor(Math.random() * (await Ads.count())),
});
const AdView3 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdView3?.setAd)
{
await
AdView3.
setAd(relatedAd3);
}
}
async function associateAdViewWithAdvertiser_organization() {
const relatedAdvertiser_organization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdView0 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (AdView0?.setAdvertiser_organization)
{
await
AdView0.
setAdvertiser_organization(relatedAdvertiser_organization0);
}
const relatedAdvertiser_organization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdView1 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (AdView1?.setAdvertiser_organization)
{
await
AdView1.
setAdvertiser_organization(relatedAdvertiser_organization1);
}
const relatedAdvertiser_organization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdView2 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (AdView2?.setAdvertiser_organization)
{
await
AdView2.
setAdvertiser_organization(relatedAdvertiser_organization2);
}
const relatedAdvertiser_organization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const AdView3 = await AdViews.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (AdView3?.setAdvertiser_organization)
{
await
AdView3.
setAdvertiser_organization(relatedAdvertiser_organization3);
}
}
async function associateRewardLedgerEntryWithWallet() {
const relatedWallet0 = await ViewerWallets.findOne({
offset: Math.floor(Math.random() * (await ViewerWallets.count())),
});
const RewardLedgerEntry0 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (RewardLedgerEntry0?.setWallet)
{
await
RewardLedgerEntry0.
setWallet(relatedWallet0);
}
const relatedWallet1 = await ViewerWallets.findOne({
offset: Math.floor(Math.random() * (await ViewerWallets.count())),
});
const RewardLedgerEntry1 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (RewardLedgerEntry1?.setWallet)
{
await
RewardLedgerEntry1.
setWallet(relatedWallet1);
}
const relatedWallet2 = await ViewerWallets.findOne({
offset: Math.floor(Math.random() * (await ViewerWallets.count())),
});
const RewardLedgerEntry2 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (RewardLedgerEntry2?.setWallet)
{
await
RewardLedgerEntry2.
setWallet(relatedWallet2);
}
const relatedWallet3 = await ViewerWallets.findOne({
offset: Math.floor(Math.random() * (await ViewerWallets.count())),
});
const RewardLedgerEntry3 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (RewardLedgerEntry3?.setWallet)
{
await
RewardLedgerEntry3.
setWallet(relatedWallet3);
}
}
async function associateRewardLedgerEntryWithAd_view() {
const relatedAd_view0 = await AdViews.findOne({
offset: Math.floor(Math.random() * (await AdViews.count())),
});
const RewardLedgerEntry0 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (RewardLedgerEntry0?.setAd_view)
{
await
RewardLedgerEntry0.
setAd_view(relatedAd_view0);
}
const relatedAd_view1 = await AdViews.findOne({
offset: Math.floor(Math.random() * (await AdViews.count())),
});
const RewardLedgerEntry1 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (RewardLedgerEntry1?.setAd_view)
{
await
RewardLedgerEntry1.
setAd_view(relatedAd_view1);
}
const relatedAd_view2 = await AdViews.findOne({
offset: Math.floor(Math.random() * (await AdViews.count())),
});
const RewardLedgerEntry2 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (RewardLedgerEntry2?.setAd_view)
{
await
RewardLedgerEntry2.
setAd_view(relatedAd_view2);
}
const relatedAd_view3 = await AdViews.findOne({
offset: Math.floor(Math.random() * (await AdViews.count())),
});
const RewardLedgerEntry3 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (RewardLedgerEntry3?.setAd_view)
{
await
RewardLedgerEntry3.
setAd_view(relatedAd_view3);
}
}
async function associateRewardLedgerEntryWithAdvertiser_organization() {
const relatedAdvertiser_organization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const RewardLedgerEntry0 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (RewardLedgerEntry0?.setAdvertiser_organization)
{
await
RewardLedgerEntry0.
setAdvertiser_organization(relatedAdvertiser_organization0);
}
const relatedAdvertiser_organization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const RewardLedgerEntry1 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (RewardLedgerEntry1?.setAdvertiser_organization)
{
await
RewardLedgerEntry1.
setAdvertiser_organization(relatedAdvertiser_organization1);
}
const relatedAdvertiser_organization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const RewardLedgerEntry2 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (RewardLedgerEntry2?.setAdvertiser_organization)
{
await
RewardLedgerEntry2.
setAdvertiser_organization(relatedAdvertiser_organization2);
}
const relatedAdvertiser_organization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const RewardLedgerEntry3 = await RewardLedgerEntries.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (RewardLedgerEntry3?.setAdvertiser_organization)
{
await
RewardLedgerEntry3.
setAdvertiser_organization(relatedAdvertiser_organization3);
}
}
async function associateWithdrawalRequestWithWallet() {
const relatedWallet0 = await ViewerWallets.findOne({
offset: Math.floor(Math.random() * (await ViewerWallets.count())),
});
const WithdrawalRequest0 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WithdrawalRequest0?.setWallet)
{
await
WithdrawalRequest0.
setWallet(relatedWallet0);
}
const relatedWallet1 = await ViewerWallets.findOne({
offset: Math.floor(Math.random() * (await ViewerWallets.count())),
});
const WithdrawalRequest1 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WithdrawalRequest1?.setWallet)
{
await
WithdrawalRequest1.
setWallet(relatedWallet1);
}
const relatedWallet2 = await ViewerWallets.findOne({
offset: Math.floor(Math.random() * (await ViewerWallets.count())),
});
const WithdrawalRequest2 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WithdrawalRequest2?.setWallet)
{
await
WithdrawalRequest2.
setWallet(relatedWallet2);
}
const relatedWallet3 = await ViewerWallets.findOne({
offset: Math.floor(Math.random() * (await ViewerWallets.count())),
});
const WithdrawalRequest3 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WithdrawalRequest3?.setWallet)
{
await
WithdrawalRequest3.
setWallet(relatedWallet3);
}
}
async function associateWithdrawalRequestWithPayment_method() {
const relatedPayment_method0 = await PaymentMethods.findOne({
offset: Math.floor(Math.random() * (await PaymentMethods.count())),
});
const WithdrawalRequest0 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WithdrawalRequest0?.setPayment_method)
{
await
WithdrawalRequest0.
setPayment_method(relatedPayment_method0);
}
const relatedPayment_method1 = await PaymentMethods.findOne({
offset: Math.floor(Math.random() * (await PaymentMethods.count())),
});
const WithdrawalRequest1 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WithdrawalRequest1?.setPayment_method)
{
await
WithdrawalRequest1.
setPayment_method(relatedPayment_method1);
}
const relatedPayment_method2 = await PaymentMethods.findOne({
offset: Math.floor(Math.random() * (await PaymentMethods.count())),
});
const WithdrawalRequest2 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WithdrawalRequest2?.setPayment_method)
{
await
WithdrawalRequest2.
setPayment_method(relatedPayment_method2);
}
const relatedPayment_method3 = await PaymentMethods.findOne({
offset: Math.floor(Math.random() * (await PaymentMethods.count())),
});
const WithdrawalRequest3 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WithdrawalRequest3?.setPayment_method)
{
await
WithdrawalRequest3.
setPayment_method(relatedPayment_method3);
}
}
async function associateWithdrawalRequestWithAdvertiser_organization() {
const relatedAdvertiser_organization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const WithdrawalRequest0 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WithdrawalRequest0?.setAdvertiser_organization)
{
await
WithdrawalRequest0.
setAdvertiser_organization(relatedAdvertiser_organization0);
}
const relatedAdvertiser_organization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const WithdrawalRequest1 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WithdrawalRequest1?.setAdvertiser_organization)
{
await
WithdrawalRequest1.
setAdvertiser_organization(relatedAdvertiser_organization1);
}
const relatedAdvertiser_organization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const WithdrawalRequest2 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WithdrawalRequest2?.setAdvertiser_organization)
{
await
WithdrawalRequest2.
setAdvertiser_organization(relatedAdvertiser_organization2);
}
const relatedAdvertiser_organization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const WithdrawalRequest3 = await WithdrawalRequests.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (WithdrawalRequest3?.setAdvertiser_organization)
{
await
WithdrawalRequest3.
setAdvertiser_organization(relatedAdvertiser_organization3);
}
}
async function associateFraudFlagWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const FraudFlag0 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (FraudFlag0?.setUser)
{
await
FraudFlag0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const FraudFlag1 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (FraudFlag1?.setUser)
{
await
FraudFlag1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const FraudFlag2 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (FraudFlag2?.setUser)
{
await
FraudFlag2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const FraudFlag3 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (FraudFlag3?.setUser)
{
await
FraudFlag3.
setUser(relatedUser3);
}
}
async function associateFraudFlagWithAd_view() {
const relatedAd_view0 = await AdViews.findOne({
offset: Math.floor(Math.random() * (await AdViews.count())),
});
const FraudFlag0 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (FraudFlag0?.setAd_view)
{
await
FraudFlag0.
setAd_view(relatedAd_view0);
}
const relatedAd_view1 = await AdViews.findOne({
offset: Math.floor(Math.random() * (await AdViews.count())),
});
const FraudFlag1 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (FraudFlag1?.setAd_view)
{
await
FraudFlag1.
setAd_view(relatedAd_view1);
}
const relatedAd_view2 = await AdViews.findOne({
offset: Math.floor(Math.random() * (await AdViews.count())),
});
const FraudFlag2 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (FraudFlag2?.setAd_view)
{
await
FraudFlag2.
setAd_view(relatedAd_view2);
}
const relatedAd_view3 = await AdViews.findOne({
offset: Math.floor(Math.random() * (await AdViews.count())),
});
const FraudFlag3 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (FraudFlag3?.setAd_view)
{
await
FraudFlag3.
setAd_view(relatedAd_view3);
}
}
async function associateFraudFlagWithAdvertiser_organization() {
const relatedAdvertiser_organization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const FraudFlag0 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (FraudFlag0?.setAdvertiser_organization)
{
await
FraudFlag0.
setAdvertiser_organization(relatedAdvertiser_organization0);
}
const relatedAdvertiser_organization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const FraudFlag1 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (FraudFlag1?.setAdvertiser_organization)
{
await
FraudFlag1.
setAdvertiser_organization(relatedAdvertiser_organization1);
}
const relatedAdvertiser_organization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const FraudFlag2 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (FraudFlag2?.setAdvertiser_organization)
{
await
FraudFlag2.
setAdvertiser_organization(relatedAdvertiser_organization2);
}
const relatedAdvertiser_organization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const FraudFlag3 = await FraudFlags.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (FraudFlag3?.setAdvertiser_organization)
{
await
FraudFlag3.
setAdvertiser_organization(relatedAdvertiser_organization3);
}
}
async function associatePlatformSettingWithAdvertiser_organization() {
const relatedAdvertiser_organization0 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const PlatformSetting0 = await PlatformSettings.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PlatformSetting0?.setAdvertiser_organization)
{
await
PlatformSetting0.
setAdvertiser_organization(relatedAdvertiser_organization0);
}
const relatedAdvertiser_organization1 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const PlatformSetting1 = await PlatformSettings.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PlatformSetting1?.setAdvertiser_organization)
{
await
PlatformSetting1.
setAdvertiser_organization(relatedAdvertiser_organization1);
}
const relatedAdvertiser_organization2 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const PlatformSetting2 = await PlatformSettings.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PlatformSetting2?.setAdvertiser_organization)
{
await
PlatformSetting2.
setAdvertiser_organization(relatedAdvertiser_organization2);
}
const relatedAdvertiser_organization3 = await AdvertiserOrganizations.findOne({
offset: Math.floor(Math.random() * (await AdvertiserOrganizations.count())),
});
const PlatformSetting3 = await PlatformSettings.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PlatformSetting3?.setAdvertiser_organization)
{
await
PlatformSetting3.
setAdvertiser_organization(relatedAdvertiser_organization3);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await AdvertiserOrganizations.bulkCreate(AdvertiserOrganizationsData);
await PaymentMethods.bulkCreate(PaymentMethodsData);
await AdvertiserWallets.bulkCreate(AdvertiserWalletsData);
await AdvertiserTopups.bulkCreate(AdvertiserTopupsData);
await AdCampaigns.bulkCreate(AdCampaignsData);
await Ads.bulkCreate(AdsData);
await ViewerWallets.bulkCreate(ViewerWalletsData);
await AdViews.bulkCreate(AdViewsData);
await RewardLedgerEntries.bulkCreate(RewardLedgerEntriesData);
await WithdrawalRequests.bulkCreate(WithdrawalRequestsData);
await FraudFlags.bulkCreate(FraudFlagsData);
await PlatformSettings.bulkCreate(PlatformSettingsData);
await Promise.all([
// Similar logic for "relation_many"
await associateUserWithAdvertiser_organization(),
await associatePaymentMethodWithAdvertiser_organization(),
await associateAdvertiserWalletWithOrganization(),
await associateAdvertiserTopupWithWallet(),
await associateAdvertiserTopupWithPayment_method(),
await associateAdvertiserTopupWithAdvertiser_organization(),
await associateAdCampaignWithOrganization(),
await associateAdWithCampaign(),
await associateAdWithAdvertiser_organization(),
await associateViewerWalletWithUser(),
await associateViewerWalletWithAdvertiser_organization(),
await associateAdViewWithUser(),
await associateAdViewWithAd(),
await associateAdViewWithAdvertiser_organization(),
await associateRewardLedgerEntryWithWallet(),
await associateRewardLedgerEntryWithAd_view(),
await associateRewardLedgerEntryWithAdvertiser_organization(),
await associateWithdrawalRequestWithWallet(),
await associateWithdrawalRequestWithPayment_method(),
await associateWithdrawalRequestWithAdvertiser_organization(),
await associateFraudFlagWithUser(),
await associateFraudFlagWithAd_view(),
await associateFraudFlagWithAdvertiser_organization(),
await associatePlatformSettingWithAdvertiser_organization(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('advertiser_organizations', null, {});
await queryInterface.bulkDelete('payment_methods', null, {});
await queryInterface.bulkDelete('advertiser_wallets', null, {});
await queryInterface.bulkDelete('advertiser_topups', null, {});
await queryInterface.bulkDelete('ad_campaigns', null, {});
await queryInterface.bulkDelete('ads', null, {});
await queryInterface.bulkDelete('viewer_wallets', null, {});
await queryInterface.bulkDelete('ad_views', null, {});
await queryInterface.bulkDelete('reward_ledger_entries', null, {});
await queryInterface.bulkDelete('withdrawal_requests', null, {});
await queryInterface.bulkDelete('fraud_flags', null, {});
await queryInterface.bulkDelete('platform_settings', null, {});
},
};