40043-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-05-19 13:26:31 +00:00

8393 lines
171 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const PasswordResets = db.password_resets;
const Friendships = db.friendships;
const CodingChallenges = db.coding_challenges;
const MatchmakingQueues = db.matchmaking_queues;
const Matches = db.matches;
const MatchRounds = db.match_rounds;
const RoundSubmissions = db.round_submissions;
const MatchEvents = db.match_events;
const ChatMessages = db.chat_messages;
const SpectatorSessions = db.spectator_sessions;
const RankTiers = db.rank_tiers;
const PointsTransactions = db.points_transactions;
const ShopItems = db.shop_items;
const ShopPurchases = db.shop_purchases;
const PlayerStats = db.player_stats;
const Replays = db.replays;
const Notifications = db.notifications;
const PasswordResetsData = [
{
// type code here for "relation_one" field
"reset_token_hash": "rtok_9f2c3a1b4d6e8h",
"requested_at": new Date('2026-05-10T10:00:00Z'),
"expires_at": new Date('2026-05-10T11:00:00Z'),
"used_at": new Date('2026-05-10T10:20:00Z'),
"request_ip": "203.0.113.10",
"user_agent": "Mozilla/5.0 Chrome 124",
},
{
// type code here for "relation_one" field
"reset_token_hash": "rtok_7a1c2d3e4f5g6h",
"requested_at": new Date('2026-05-11T12:15:00Z'),
"expires_at": new Date('2026-05-11T13:15:00Z'),
"used_at": new Date('2026-05-11T12:40:00Z'),
"request_ip": "203.0.113.11",
"user_agent": "Mozilla/5.0 Firefox 126",
},
{
// type code here for "relation_one" field
"reset_token_hash": "rtok_4b9c8a7d6e5f4g",
"requested_at": new Date('2026-05-12T08:05:00Z'),
"expires_at": new Date('2026-05-12T09:05:00Z'),
"used_at": new Date('2026-05-12T08:50:00Z'),
"request_ip": "198.51.100.20",
"user_agent": "Mozilla/5.0 Safari 17",
},
{
// type code here for "relation_one" field
"reset_token_hash": "rtok_2d3e4f5g6h7j8k",
"requested_at": new Date('2026-05-13T17:45:00Z'),
"expires_at": new Date('2026-05-13T18:45:00Z'),
"used_at": new Date('2026-05-13T18:05:00Z'),
"request_ip": "198.51.100.21",
"user_agent": "Mozilla/5.0 Edge 125",
},
{
// type code here for "relation_one" field
"reset_token_hash": "rtok_1a2b3c4d5e6f7g",
"requested_at": new Date('2026-05-14T21:30:00Z'),
"expires_at": new Date('2026-05-14T22:30:00Z'),
"used_at": new Date('2026-05-14T21:55:00Z'),
"request_ip": "192.0.2.30",
"user_agent": "Mozilla/5.0 Chrome 124",
},
];
const FriendshipsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "accepted",
"requested_at": new Date('2026-04-20T14:00:00Z'),
"responded_at": new Date('2026-04-20T15:10:00Z'),
"note": "Practice partner for JavaScript duels",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "accepted",
"requested_at": new Date('2026-05-01T09:00:00Z'),
"responded_at": new Date('2026-05-01T09:05:00Z'),
"note": "Met in spectate chat, invited to connect",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "accepted",
"requested_at": new Date('2026-03-18T19:30:00Z'),
"responded_at": new Date('2026-03-18T19:45:00Z'),
"note": "Discussing challenge strategies",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "blocked",
"requested_at": new Date('2026-04-02T10:20:00Z'),
"responded_at": new Date('2026-04-02T11:00:00Z'),
"note": "Blocked due to spam messages",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "pending",
"requested_at": new Date('2026-02-11T13:10:00Z'),
"responded_at": new Date('2026-02-11T13:40:00Z'),
"note": "Moderator contact for fair play questions",
},
];
const CodingChallengesData = [
{
"title": "Array Sum Under Pressure",
"difficulty": "easy",
"challenge_type": "html_css",
"prompt": "Write a function sum(arr) that returns the sum of all numbers in an array.",
"starter_code_js": "function sum(arr) { }",
"starter_code_html": "<div></div>",
"starter_code_css": "body { }",
"test_spec": "Input: [1,2,3] Output: 6",
"time_limit_seconds": 180,
"is_active": true,
// type code here for "relation_one" field
"published_at": new Date('2026-02-01T10:00:00Z'),
},
{
"title": "DOM Button Toggle",
"difficulty": "hard",
"challenge_type": "html_css",
"prompt": "Create a button that toggles an active class on click.",
"starter_code_js": "const btn = document.querySelector(button);",
"starter_code_html": "<button id=toggle>Toggle</button>",
"starter_code_css": ".active { background: #22c55e; }",
"test_spec": "Click toggles .active class",
"time_limit_seconds": 180,
"is_active": true,
// type code here for "relation_one" field
"published_at": new Date('2026-02-05T10:00:00Z'),
},
{
"title": "Valid Parentheses",
"difficulty": "easy",
"challenge_type": "mixed",
"prompt": "Return true if the string has valid parentheses ordering.",
"starter_code_js": "function isValid(s) { }",
"starter_code_html": "<div></div>",
"starter_code_css": "body { }",
"test_spec": "Input: ()[]{} Output: true",
"time_limit_seconds": 180,
"is_active": true,
// type code here for "relation_one" field
"published_at": new Date('2026-03-01T10:00:00Z'),
},
{
"title": "CSS Card Layout",
"difficulty": "hard",
"challenge_type": "javascript",
"prompt": "Build a responsive card with image, title, and body text using flex or grid.",
"starter_code_js": "",
"starter_code_html": "<div class=card><img alt=/><h3>Title</h3><p>Body</p></div>",
"starter_code_css": ".card { }",
"test_spec": "Card stays readable at 320px width",
"time_limit_seconds": 180,
"is_active": true,
// type code here for "relation_one" field
"published_at": new Date('2026-03-10T10:00:00Z'),
},
{
"title": "Debounce Implementation",
"difficulty": "medium",
"challenge_type": "html_css",
"prompt": "Implement debounce(fn, wait) that delays invocation until wait ms have passed.",
"starter_code_js": "function debounce(fn, wait) { }",
"starter_code_html": "<div></div>",
"starter_code_css": "body { }",
"test_spec": "Calls fn once after burst of calls",
"time_limit_seconds": 180,
"is_active": true,
// type code here for "relation_one" field
"published_at": new Date('2026-04-01T10:00:00Z'),
},
];
const MatchmakingQueuesData = [
{
"name": "Easy JavaScript Queue",
"difficulty": "medium",
"language_mode": "mixed",
"is_open": true,
"max_wait_seconds": 90,
},
{
"name": "Medium JavaScript Queue",
"difficulty": "easy",
"language_mode": "javascript",
"is_open": true,
"max_wait_seconds": 120,
},
{
"name": "Hard JavaScript Queue",
"difficulty": "medium",
"language_mode": "javascript",
"is_open": true,
"max_wait_seconds": 180,
},
{
"name": "HTML and CSS Queue",
"difficulty": "medium",
"language_mode": "html_css",
"is_open": true,
"max_wait_seconds": 120,
},
{
"name": "Mixed Skills Queue",
"difficulty": "medium",
"language_mode": "mixed",
"is_open": true,
"max_wait_seconds": 150,
},
];
const MatchesData = [
{
"room_code": "ARENA-7KQ2",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "completed",
"started_at": new Date('2026-05-18T20:00:00Z'),
"ended_at": new Date('2026-05-18T20:12:00Z'),
// type code here for "relation_one" field
"player_one_round_wins": 1,
"player_two_round_wins": 3,
"best_of_rounds": 5,
"rematch_requested": true,
// type code here for "relation_one" field
"server_region": "eu-west",
},
{
"room_code": "ARENA-3MNF",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "in_progress",
"started_at": new Date('2026-05-19T08:30:00Z'),
"ended_at": new Date('2026-05-19T08:55:00Z'),
// type code here for "relation_one" field
"player_one_round_wins": 2,
"player_two_round_wins": 1,
"best_of_rounds": 5,
"rematch_requested": true,
// type code here for "relation_one" field
"server_region": "eu-west",
},
{
"room_code": "ARENA-P9T1",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "cancelled",
"started_at": new Date('2026-05-17T10:10:00Z'),
"ended_at": new Date('2026-05-17T10:12:00Z'),
// type code here for "relation_one" field
"player_one_round_wins": 0,
"player_two_round_wins": 0,
"best_of_rounds": 5,
"rematch_requested": false,
// type code here for "relation_one" field
"server_region": "us-east",
},
{
"room_code": "ARENA-J2D8",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "completed",
"started_at": new Date('2026-05-14T19:00:00Z'),
"ended_at": new Date('2026-05-14T19:14:00Z'),
// type code here for "relation_one" field
"player_one_round_wins": 3,
"player_two_round_wins": 0,
"best_of_rounds": 5,
"rematch_requested": false,
// type code here for "relation_one" field
"server_region": "eu-central",
},
{
"room_code": "ARENA-Z5C4",
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "in_progress",
"started_at": new Date('2026-05-12T16:00:00Z'),
"ended_at": new Date('2026-05-12T16:13:00Z'),
// type code here for "relation_one" field
"player_one_round_wins": 3,
"player_two_round_wins": 2,
"best_of_rounds": 5,
"rematch_requested": false,
// type code here for "relation_one" field
"server_region": "us-west",
},
];
const MatchRoundsData = [
{
// type code here for "relation_one" field
"round_number": 1,
// type code here for "relation_one" field
"status": "skipped",
"round_started_at": new Date('2026-05-18T20:00:00Z'),
"round_ended_at": new Date('2026-05-18T20:03:00Z'),
"duration_seconds": 180,
// type code here for "relation_one" field
"win_reason": "first_valid_submit",
"time_limit_seconds": 180,
"allow_test_before_submit": true,
},
{
// type code here for "relation_one" field
"round_number": 2,
// type code here for "relation_one" field
"status": "completed",
"round_started_at": new Date('2026-05-18T20:03:30Z'),
"round_ended_at": new Date('2026-05-18T20:06:30Z'),
"duration_seconds": 180,
// type code here for "relation_one" field
"win_reason": "opponent_forfeit",
"time_limit_seconds": 180,
"allow_test_before_submit": true,
},
{
// type code here for "relation_one" field
"round_number": 3,
// type code here for "relation_one" field
"status": "completed",
"round_started_at": new Date('2026-05-18T20:07:00Z'),
"round_ended_at": new Date('2026-05-18T20:10:00Z'),
"duration_seconds": 180,
// type code here for "relation_one" field
"win_reason": "opponent_timeout",
"time_limit_seconds": 180,
"allow_test_before_submit": true,
},
{
// type code here for "relation_one" field
"round_number": 4,
// type code here for "relation_one" field
"status": "active",
"round_started_at": new Date('2026-05-18T20:10:15Z'),
"round_ended_at": new Date('2026-05-18T20:12:00Z'),
"duration_seconds": 105,
// type code here for "relation_one" field
"win_reason": "admin_decision",
"time_limit_seconds": 180,
"allow_test_before_submit": true,
},
{
// type code here for "relation_one" field
"round_number": 1,
// type code here for "relation_one" field
"status": "skipped",
"round_started_at": new Date('2026-05-12T16:00:00Z'),
"round_ended_at": new Date('2026-05-12T16:03:00Z'),
"duration_seconds": 180,
// type code here for "relation_one" field
"win_reason": "opponent_forfeit",
"time_limit_seconds": 180,
"allow_test_before_submit": true,
},
];
const RoundSubmissionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"language": "javascript",
"code_text": "function sum(arr){return arr.reduce((a,b)=>a+b,0)}",
"is_final_submit": true,
"is_valid": true,
"score": 1.0,
"test_output": "All tests passed",
"submitted_at": new Date('2026-05-18T20:02:50Z'),
"elapsed_ms": 170000,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"language": "javascript",
"code_text": "function sum(arr){let s=0;for(const n of arr)s+=n;return s}",
"is_final_submit": true,
"is_valid": true,
"score": 1.0,
"test_output": "All tests passed",
"submitted_at": new Date('2026-05-18T20:02:20Z'),
"elapsed_ms": 140000,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"language": "javascript",
"code_text": "function isValid(s){const st=[];const m={')':'(',']':'[','}':'{'};for(const c of s){if(m[c]){if(st.pop()!==m[c])return false}else st.push(c)}return st.length===0}",
"is_final_submit": true,
"is_valid": true,
"score": 1.0,
"test_output": "All tests passed",
"submitted_at": new Date('2026-05-18T20:06:10Z'),
"elapsed_ms": 160000,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"language": "javascript",
"code_text": "<button id=toggle>Toggle</button>",
"is_final_submit": false,
"is_valid": true,
"score": 0.6,
"test_output": "Markup ok",
"submitted_at": new Date('2026-05-18T20:08:00Z'),
"elapsed_ms": 60000,
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"language": "css",
"code_text": ".card{display:grid;gap:12px;max-width:420px}img{width:100%;height:auto}",
"is_final_submit": true,
"is_valid": true,
"score": 0.9,
"test_output": "Layout checks passed",
"submitted_at": new Date('2026-05-18T20:11:40Z'),
"elapsed_ms": 85000,
},
];
const MatchEventsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "typing_start",
"payload": "{side:player_one}",
"occurred_at": new Date('2026-05-18T19:59:50Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "code_sync",
"payload": "{side:player_two}",
"occurred_at": new Date('2026-05-18T19:59:55Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "match_end",
"payload": "{language:javascript}",
"occurred_at": new Date('2026-05-18T20:01:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "submit",
"payload": "{submission:round_submissions:2}",
"occurred_at": new Date('2026-05-18T20:02:20Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"event_type": "typing_stop",
"payload": "{cost_points:20}",
"occurred_at": new Date('2026-05-18T20:12:10Z'),
},
];
const ChatMessagesData = [
{
"channel_type": "match",
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_text": "Good luck, have fun",
"emoji": "thumbs_up",
"sent_at": new Date('2026-05-18T20:00:10Z'),
"is_deleted": false,
},
{
"channel_type": "spectator",
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_text": "You too, lets go",
"emoji": "rocket",
"sent_at": new Date('2026-05-18T20:00:15Z'),
"is_deleted": true,
},
{
"channel_type": "spectator",
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_text": "Nice solve on round 1",
"emoji": "clap",
"sent_at": new Date('2026-05-18T20:03:10Z'),
"is_deleted": true,
},
{
"channel_type": "spectator",
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_text": "Great pace from both players",
"emoji": "eyes",
"sent_at": new Date('2026-05-18T20:04:05Z'),
"is_deleted": false,
},
{
"channel_type": "match",
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_text": "Reminder: be respectful in chat",
"emoji": "shield",
"sent_at": new Date('2026-05-18T20:04:10Z'),
"is_deleted": true,
},
];
const SpectatorSessionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"joined_at": new Date('2026-05-18T20:00:30Z'),
"left_at": new Date('2026-05-18T20:12:30Z'),
"connection_id": "sock_spect_aa12",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"joined_at": new Date('2026-05-18T20:01:00Z'),
"left_at": new Date('2026-05-18T20:12:20Z'),
"connection_id": "sock_spect_bb34",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"joined_at": new Date('2026-05-12T16:01:10Z'),
"left_at": new Date('2026-05-12T16:10:00Z'),
"connection_id": "sock_spect_cc56",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"joined_at": new Date('2026-05-19T08:35:00Z'),
"left_at": new Date('2026-05-19T08:50:00Z'),
"connection_id": "sock_spect_dd78",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"joined_at": new Date('2026-05-14T19:02:00Z'),
"left_at": new Date('2026-05-14T19:12:00Z'),
"connection_id": "sock_spect_ee90",
},
];
const RankTiersData = [
{
"name": "Bronze",
"min_points": 0,
"max_points": 99,
"badge_label": "Bronze Tier",
// type code here for "images" field
},
{
"name": "Silver",
"min_points": 100,
"max_points": 249,
"badge_label": "Silver Tier",
// type code here for "images" field
},
{
"name": "Gold",
"min_points": 250,
"max_points": 499,
"badge_label": "Gold Tier",
// type code here for "images" field
},
{
"name": "Platinum",
"min_points": 500,
"max_points": 799,
"badge_label": "Platinum Tier",
// type code here for "images" field
},
{
"name": "Diamond",
"min_points": 800,
"max_points": 2000,
"badge_label": "Diamond Tier",
// type code here for "images" field
},
];
const PointsTransactionsData = [
{
// type code here for "relation_one" field
"transaction_type": "match_win",
"points_delta": 3,
"balance_after": 75,
// type code here for "relation_one" field
"reason": "Match victory in ARENA-7KQ2",
"occurred_at": new Date('2026-05-18T20:12:10Z'),
},
{
// type code here for "relation_one" field
"transaction_type": "shop_purchase",
"points_delta": 1,
"balance_after": 42,
// type code here for "relation_one" field
"reason": "Match loss in ARENA-7KQ2",
"occurred_at": new Date('2026-05-18T20:12:10Z'),
},
{
// type code here for "relation_one" field
"transaction_type": "match_win",
"points_delta": -20,
"balance_after": 22,
// type code here for "relation_one" field
"reason": "Requested rematch",
"occurred_at": new Date('2026-05-18T20:12:12Z'),
},
{
// type code here for "relation_one" field
"transaction_type": "match_loss",
"points_delta": -10,
"balance_after": 8,
// type code here for "relation_one" field
"reason": "Copied opponent code for review",
"occurred_at": new Date('2026-05-12T16:08:00Z'),
},
{
// type code here for "relation_one" field
"transaction_type": "shop_purchase",
"points_delta": 50,
"balance_after": 55,
// type code here for "relation_one" field
"reason": "Promo credit for beta testers",
"occurred_at": new Date('2026-05-01T09:00:00Z'),
},
];
const ShopItemsData = [
{
"name": "Copy Opponent Code",
"description": "Unlock a one-time copy of the opponent code in the current round.",
"item_key": "request_rematch",
"cost_points": 10,
"is_active": true,
},
{
"name": "Skip Current Round",
"description": "Skip the current round and move to the next challenge.",
"item_key": "copy_opponent_code",
"cost_points": 15,
"is_active": true,
},
{
"name": "Request Rematch",
"description": "Request a rematch after the match ends.",
"item_key": "skip_current_round",
"cost_points": 20,
"is_active": true,
},
{
"name": "Extra Hint",
"description": "Get a small hint for the current challenge.",
"item_key": "skip_current_round",
"cost_points": 12,
"is_active": true,
},
{
"name": "Extended Timer",
"description": "Not available in ranked matches.",
"item_key": "copy_opponent_code",
"cost_points": 25,
"is_active": true,
},
];
const ShopPurchasesData = [
{
// 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
"cost_points": 20,
"purchased_at": new Date('2026-05-18T20:12:12Z'),
"status": "rejected",
"result_note": "Rematch request sent",
},
{
// 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
"cost_points": 10,
"purchased_at": new Date('2026-05-12T16:08:00Z'),
"status": "completed",
"result_note": "Code copy enabled for 30 seconds",
},
{
// 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
"cost_points": 15,
"purchased_at": new Date('2026-05-14T19:05:00Z'),
"status": "completed",
"result_note": "Not enough points at purchase time",
},
{
// 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
"cost_points": 10,
"purchased_at": new Date('2026-05-18T20:01:30Z'),
"status": "refunded",
"result_note": "Code copy enabled for 30 seconds",
},
{
// 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
"cost_points": 20,
"purchased_at": new Date('2026-05-14T19:14:30Z'),
"status": "completed",
"result_note": "Match cancelled, purchase refunded",
},
];
const PlayerStatsData = [
{
// type code here for "relation_one" field
"matches_played": 28,
"matches_won": 14,
"matches_lost": 14,
"rounds_played": 112,
"rounds_won": 56,
"rounds_lost": 56,
"win_rate": 0.5,
"current_win_streak": 2,
"best_win_streak": 6,
"last_match_at": new Date('2026-05-18T20:12:00Z'),
},
{
// type code here for "relation_one" field
"matches_played": 45,
"matches_won": 30,
"matches_lost": 15,
"rounds_played": 176,
"rounds_won": 110,
"rounds_lost": 66,
"win_rate": 0.6667,
"current_win_streak": 4,
"best_win_streak": 9,
"last_match_at": new Date('2026-05-19T08:30:00Z'),
},
{
// type code here for "relation_one" field
"matches_played": 12,
"matches_won": 4,
"matches_lost": 8,
"rounds_played": 48,
"rounds_won": 18,
"rounds_lost": 30,
"win_rate": 0.3333,
"current_win_streak": 0,
"best_win_streak": 2,
"last_match_at": new Date('2026-05-17T10:12:00Z'),
},
{
// type code here for "relation_one" field
"matches_played": 8,
"matches_won": 6,
"matches_lost": 2,
"rounds_played": 30,
"rounds_won": 20,
"rounds_lost": 10,
"win_rate": 0.75,
"current_win_streak": 1,
"best_win_streak": 4,
"last_match_at": new Date('2026-05-14T19:14:00Z'),
},
{
// type code here for "relation_one" field
"matches_played": 3,
"matches_won": 1,
"matches_lost": 2,
"rounds_played": 10,
"rounds_won": 4,
"rounds_lost": 6,
"win_rate": 0.3333,
"current_win_streak": 0,
"best_win_streak": 1,
"last_match_at": new Date('2026-05-12T16:13:00Z'),
},
];
const ReplaysData = [
{
// type code here for "relation_one" field
"title": "Gold vs Platinum Duel",
// type code here for "files" field
"timeline_json": "{events:120,notes:Fast submissions}",
"recorded_at": new Date('2026-05-18T20:12:30Z'),
"is_public": true,
},
{
// type code here for "relation_one" field
"title": "Hard Queue Sweep",
// type code here for "files" field
"timeline_json": "{events:95,notes:Clean solutions}",
"recorded_at": new Date('2026-05-14T19:14:30Z'),
"is_public": true,
},
{
// type code here for "relation_one" field
"title": "Close Match to Round 5",
// type code here for "files" field
"timeline_json": "{events:140,notes:Back and forth}",
"recorded_at": new Date('2026-05-12T16:13:30Z'),
"is_public": true,
},
{
// type code here for "relation_one" field
"title": "Ongoing Medium Match Snapshot",
// type code here for "files" field
"timeline_json": "{events:30,notes:Mid-match snapshot}",
"recorded_at": new Date('2026-05-19T08:40:00Z'),
"is_public": false,
},
{
// type code here for "relation_one" field
"title": "Cancelled Room Example",
// type code here for "files" field
"timeline_json": "{events:10,notes:Players disconnected}",
"recorded_at": new Date('2026-05-17T10:12:30Z'),
"is_public": false,
},
];
const NotificationsData = [
{
// type code here for "relation_one" field
"type": "rank_up",
"title": "Rematch requested",
"body": "Your rematch request for ARENA-7KQ2 was sent.",
"action_url": "/matches/ARENA-7KQ2",
"is_read": true,
"sent_at": new Date('2026-05-18T20:12:13Z'),
"read_at": new Date('2026-05-18T20:13:00Z'),
},
{
// type code here for "relation_one" field
"type": "friend_request",
"title": "Rank updated",
"body": "You are now in Platinum tier based on your points.",
"action_url": "/leaderboard",
"is_read": false,
"sent_at": new Date('2026-05-10T09:00:00Z'),
"read_at": new Date('2026-05-10T09:05:00Z'),
},
{
// type code here for "relation_one" field
"type": "system",
"title": "New friend request",
"body": "aya_codes sent you a friend request.",
"action_url": "/friends",
"is_read": false,
"sent_at": new Date('2026-05-01T09:00:00Z'),
"read_at": new Date('2026-05-01T10:00:00Z'),
},
{
// type code here for "relation_one" field
"type": "rank_up",
"title": "Moderator tools updated",
"body": "Chat moderation filters were refreshed.",
"action_url": "/moderation/chat",
"is_read": true,
"sent_at": new Date('2026-04-15T12:00:00Z'),
"read_at": new Date('2026-04-15T12:10:00Z'),
},
{
// type code here for "relation_one" field
"type": "system",
"title": "Points credit applied",
"body": "A promo credit was added to your account.",
"action_url": "/shop",
"is_read": true,
"sent_at": new Date('2026-05-01T09:00:00Z'),
"read_at": new Date('2026-05-01T09:02:00Z'),
},
];
// Similar logic for "relation_many"
async function associatePasswordResetWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PasswordReset0 = await PasswordResets.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PasswordReset0?.setUser)
{
await
PasswordReset0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PasswordReset1 = await PasswordResets.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PasswordReset1?.setUser)
{
await
PasswordReset1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PasswordReset2 = await PasswordResets.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PasswordReset2?.setUser)
{
await
PasswordReset2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PasswordReset3 = await PasswordResets.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PasswordReset3?.setUser)
{
await
PasswordReset3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PasswordReset4 = await PasswordResets.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PasswordReset4?.setUser)
{
await
PasswordReset4.
setUser(relatedUser4);
}
}
async function associateFriendshipWithRequester() {
const relatedRequester0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Friendship0 = await Friendships.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Friendship0?.setRequester)
{
await
Friendship0.
setRequester(relatedRequester0);
}
const relatedRequester1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Friendship1 = await Friendships.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Friendship1?.setRequester)
{
await
Friendship1.
setRequester(relatedRequester1);
}
const relatedRequester2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Friendship2 = await Friendships.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Friendship2?.setRequester)
{
await
Friendship2.
setRequester(relatedRequester2);
}
const relatedRequester3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Friendship3 = await Friendships.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Friendship3?.setRequester)
{
await
Friendship3.
setRequester(relatedRequester3);
}
const relatedRequester4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Friendship4 = await Friendships.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Friendship4?.setRequester)
{
await
Friendship4.
setRequester(relatedRequester4);
}
}
async function associateFriendshipWithAddressee() {
const relatedAddressee0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Friendship0 = await Friendships.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Friendship0?.setAddressee)
{
await
Friendship0.
setAddressee(relatedAddressee0);
}
const relatedAddressee1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Friendship1 = await Friendships.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Friendship1?.setAddressee)
{
await
Friendship1.
setAddressee(relatedAddressee1);
}
const relatedAddressee2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Friendship2 = await Friendships.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Friendship2?.setAddressee)
{
await
Friendship2.
setAddressee(relatedAddressee2);
}
const relatedAddressee3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Friendship3 = await Friendships.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Friendship3?.setAddressee)
{
await
Friendship3.
setAddressee(relatedAddressee3);
}
const relatedAddressee4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Friendship4 = await Friendships.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Friendship4?.setAddressee)
{
await
Friendship4.
setAddressee(relatedAddressee4);
}
}
async function associateCodingChallengeWithCreated_by_user() {
const relatedCreated_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CodingChallenge0 = await CodingChallenges.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (CodingChallenge0?.setCreated_by_user)
{
await
CodingChallenge0.
setCreated_by_user(relatedCreated_by_user0);
}
const relatedCreated_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CodingChallenge1 = await CodingChallenges.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (CodingChallenge1?.setCreated_by_user)
{
await
CodingChallenge1.
setCreated_by_user(relatedCreated_by_user1);
}
const relatedCreated_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CodingChallenge2 = await CodingChallenges.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (CodingChallenge2?.setCreated_by_user)
{
await
CodingChallenge2.
setCreated_by_user(relatedCreated_by_user2);
}
const relatedCreated_by_user3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CodingChallenge3 = await CodingChallenges.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (CodingChallenge3?.setCreated_by_user)
{
await
CodingChallenge3.
setCreated_by_user(relatedCreated_by_user3);
}
const relatedCreated_by_user4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const CodingChallenge4 = await CodingChallenges.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (CodingChallenge4?.setCreated_by_user)
{
await
CodingChallenge4.
setCreated_by_user(relatedCreated_by_user4);
}
}
async function associateMatcheWithQueue() {
const relatedQueue0 = await MatchmakingQueues.findOne({
offset: Math.floor(Math.random() * (await MatchmakingQueues.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setQueue)
{
await
Matche0.
setQueue(relatedQueue0);
}
const relatedQueue1 = await MatchmakingQueues.findOne({
offset: Math.floor(Math.random() * (await MatchmakingQueues.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setQueue)
{
await
Matche1.
setQueue(relatedQueue1);
}
const relatedQueue2 = await MatchmakingQueues.findOne({
offset: Math.floor(Math.random() * (await MatchmakingQueues.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setQueue)
{
await
Matche2.
setQueue(relatedQueue2);
}
const relatedQueue3 = await MatchmakingQueues.findOne({
offset: Math.floor(Math.random() * (await MatchmakingQueues.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setQueue)
{
await
Matche3.
setQueue(relatedQueue3);
}
const relatedQueue4 = await MatchmakingQueues.findOne({
offset: Math.floor(Math.random() * (await MatchmakingQueues.count())),
});
const Matche4 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Matche4?.setQueue)
{
await
Matche4.
setQueue(relatedQueue4);
}
}
async function associateMatcheWithPlayer_one() {
const relatedPlayer_one0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setPlayer_one)
{
await
Matche0.
setPlayer_one(relatedPlayer_one0);
}
const relatedPlayer_one1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setPlayer_one)
{
await
Matche1.
setPlayer_one(relatedPlayer_one1);
}
const relatedPlayer_one2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setPlayer_one)
{
await
Matche2.
setPlayer_one(relatedPlayer_one2);
}
const relatedPlayer_one3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setPlayer_one)
{
await
Matche3.
setPlayer_one(relatedPlayer_one3);
}
const relatedPlayer_one4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche4 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Matche4?.setPlayer_one)
{
await
Matche4.
setPlayer_one(relatedPlayer_one4);
}
}
async function associateMatcheWithPlayer_two() {
const relatedPlayer_two0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setPlayer_two)
{
await
Matche0.
setPlayer_two(relatedPlayer_two0);
}
const relatedPlayer_two1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setPlayer_two)
{
await
Matche1.
setPlayer_two(relatedPlayer_two1);
}
const relatedPlayer_two2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setPlayer_two)
{
await
Matche2.
setPlayer_two(relatedPlayer_two2);
}
const relatedPlayer_two3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setPlayer_two)
{
await
Matche3.
setPlayer_two(relatedPlayer_two3);
}
const relatedPlayer_two4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche4 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Matche4?.setPlayer_two)
{
await
Matche4.
setPlayer_two(relatedPlayer_two4);
}
}
async function associateMatcheWithWinner() {
const relatedWinner0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setWinner)
{
await
Matche0.
setWinner(relatedWinner0);
}
const relatedWinner1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setWinner)
{
await
Matche1.
setWinner(relatedWinner1);
}
const relatedWinner2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setWinner)
{
await
Matche2.
setWinner(relatedWinner2);
}
const relatedWinner3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setWinner)
{
await
Matche3.
setWinner(relatedWinner3);
}
const relatedWinner4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche4 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Matche4?.setWinner)
{
await
Matche4.
setWinner(relatedWinner4);
}
}
async function associateMatcheWithRematch_requested_by() {
const relatedRematch_requested_by0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche0 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Matche0?.setRematch_requested_by)
{
await
Matche0.
setRematch_requested_by(relatedRematch_requested_by0);
}
const relatedRematch_requested_by1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche1 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Matche1?.setRematch_requested_by)
{
await
Matche1.
setRematch_requested_by(relatedRematch_requested_by1);
}
const relatedRematch_requested_by2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche2 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Matche2?.setRematch_requested_by)
{
await
Matche2.
setRematch_requested_by(relatedRematch_requested_by2);
}
const relatedRematch_requested_by3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche3 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Matche3?.setRematch_requested_by)
{
await
Matche3.
setRematch_requested_by(relatedRematch_requested_by3);
}
const relatedRematch_requested_by4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Matche4 = await Matches.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Matche4?.setRematch_requested_by)
{
await
Matche4.
setRematch_requested_by(relatedRematch_requested_by4);
}
}
async function associateMatchRoundWithMatch() {
const relatedMatch0 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchRound0 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MatchRound0?.setMatch)
{
await
MatchRound0.
setMatch(relatedMatch0);
}
const relatedMatch1 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchRound1 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MatchRound1?.setMatch)
{
await
MatchRound1.
setMatch(relatedMatch1);
}
const relatedMatch2 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchRound2 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MatchRound2?.setMatch)
{
await
MatchRound2.
setMatch(relatedMatch2);
}
const relatedMatch3 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchRound3 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (MatchRound3?.setMatch)
{
await
MatchRound3.
setMatch(relatedMatch3);
}
const relatedMatch4 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchRound4 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (MatchRound4?.setMatch)
{
await
MatchRound4.
setMatch(relatedMatch4);
}
}
async function associateMatchRoundWithChallenge() {
const relatedChallenge0 = await CodingChallenges.findOne({
offset: Math.floor(Math.random() * (await CodingChallenges.count())),
});
const MatchRound0 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MatchRound0?.setChallenge)
{
await
MatchRound0.
setChallenge(relatedChallenge0);
}
const relatedChallenge1 = await CodingChallenges.findOne({
offset: Math.floor(Math.random() * (await CodingChallenges.count())),
});
const MatchRound1 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MatchRound1?.setChallenge)
{
await
MatchRound1.
setChallenge(relatedChallenge1);
}
const relatedChallenge2 = await CodingChallenges.findOne({
offset: Math.floor(Math.random() * (await CodingChallenges.count())),
});
const MatchRound2 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MatchRound2?.setChallenge)
{
await
MatchRound2.
setChallenge(relatedChallenge2);
}
const relatedChallenge3 = await CodingChallenges.findOne({
offset: Math.floor(Math.random() * (await CodingChallenges.count())),
});
const MatchRound3 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (MatchRound3?.setChallenge)
{
await
MatchRound3.
setChallenge(relatedChallenge3);
}
const relatedChallenge4 = await CodingChallenges.findOne({
offset: Math.floor(Math.random() * (await CodingChallenges.count())),
});
const MatchRound4 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (MatchRound4?.setChallenge)
{
await
MatchRound4.
setChallenge(relatedChallenge4);
}
}
async function associateMatchRoundWithWinner() {
const relatedWinner0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MatchRound0 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MatchRound0?.setWinner)
{
await
MatchRound0.
setWinner(relatedWinner0);
}
const relatedWinner1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MatchRound1 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MatchRound1?.setWinner)
{
await
MatchRound1.
setWinner(relatedWinner1);
}
const relatedWinner2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MatchRound2 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MatchRound2?.setWinner)
{
await
MatchRound2.
setWinner(relatedWinner2);
}
const relatedWinner3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MatchRound3 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (MatchRound3?.setWinner)
{
await
MatchRound3.
setWinner(relatedWinner3);
}
const relatedWinner4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MatchRound4 = await MatchRounds.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (MatchRound4?.setWinner)
{
await
MatchRound4.
setWinner(relatedWinner4);
}
}
async function associateRoundSubmissionWithRound() {
const relatedRound0 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const RoundSubmission0 = await RoundSubmissions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (RoundSubmission0?.setRound)
{
await
RoundSubmission0.
setRound(relatedRound0);
}
const relatedRound1 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const RoundSubmission1 = await RoundSubmissions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (RoundSubmission1?.setRound)
{
await
RoundSubmission1.
setRound(relatedRound1);
}
const relatedRound2 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const RoundSubmission2 = await RoundSubmissions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (RoundSubmission2?.setRound)
{
await
RoundSubmission2.
setRound(relatedRound2);
}
const relatedRound3 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const RoundSubmission3 = await RoundSubmissions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (RoundSubmission3?.setRound)
{
await
RoundSubmission3.
setRound(relatedRound3);
}
const relatedRound4 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const RoundSubmission4 = await RoundSubmissions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (RoundSubmission4?.setRound)
{
await
RoundSubmission4.
setRound(relatedRound4);
}
}
async function associateRoundSubmissionWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const RoundSubmission0 = await RoundSubmissions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (RoundSubmission0?.setUser)
{
await
RoundSubmission0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const RoundSubmission1 = await RoundSubmissions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (RoundSubmission1?.setUser)
{
await
RoundSubmission1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const RoundSubmission2 = await RoundSubmissions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (RoundSubmission2?.setUser)
{
await
RoundSubmission2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const RoundSubmission3 = await RoundSubmissions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (RoundSubmission3?.setUser)
{
await
RoundSubmission3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const RoundSubmission4 = await RoundSubmissions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (RoundSubmission4?.setUser)
{
await
RoundSubmission4.
setUser(relatedUser4);
}
}
async function associateMatchEventWithMatch() {
const relatedMatch0 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchEvent0 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MatchEvent0?.setMatch)
{
await
MatchEvent0.
setMatch(relatedMatch0);
}
const relatedMatch1 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchEvent1 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MatchEvent1?.setMatch)
{
await
MatchEvent1.
setMatch(relatedMatch1);
}
const relatedMatch2 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchEvent2 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MatchEvent2?.setMatch)
{
await
MatchEvent2.
setMatch(relatedMatch2);
}
const relatedMatch3 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchEvent3 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (MatchEvent3?.setMatch)
{
await
MatchEvent3.
setMatch(relatedMatch3);
}
const relatedMatch4 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const MatchEvent4 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (MatchEvent4?.setMatch)
{
await
MatchEvent4.
setMatch(relatedMatch4);
}
}
async function associateMatchEventWithRound() {
const relatedRound0 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const MatchEvent0 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MatchEvent0?.setRound)
{
await
MatchEvent0.
setRound(relatedRound0);
}
const relatedRound1 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const MatchEvent1 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MatchEvent1?.setRound)
{
await
MatchEvent1.
setRound(relatedRound1);
}
const relatedRound2 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const MatchEvent2 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MatchEvent2?.setRound)
{
await
MatchEvent2.
setRound(relatedRound2);
}
const relatedRound3 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const MatchEvent3 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (MatchEvent3?.setRound)
{
await
MatchEvent3.
setRound(relatedRound3);
}
const relatedRound4 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const MatchEvent4 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (MatchEvent4?.setRound)
{
await
MatchEvent4.
setRound(relatedRound4);
}
}
async function associateMatchEventWithActor() {
const relatedActor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MatchEvent0 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MatchEvent0?.setActor)
{
await
MatchEvent0.
setActor(relatedActor0);
}
const relatedActor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MatchEvent1 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MatchEvent1?.setActor)
{
await
MatchEvent1.
setActor(relatedActor1);
}
const relatedActor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MatchEvent2 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MatchEvent2?.setActor)
{
await
MatchEvent2.
setActor(relatedActor2);
}
const relatedActor3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MatchEvent3 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (MatchEvent3?.setActor)
{
await
MatchEvent3.
setActor(relatedActor3);
}
const relatedActor4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const MatchEvent4 = await MatchEvents.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (MatchEvent4?.setActor)
{
await
MatchEvent4.
setActor(relatedActor4);
}
}
async function associateChatMessageWithMatch() {
const relatedMatch0 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const ChatMessage0 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ChatMessage0?.setMatch)
{
await
ChatMessage0.
setMatch(relatedMatch0);
}
const relatedMatch1 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const ChatMessage1 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ChatMessage1?.setMatch)
{
await
ChatMessage1.
setMatch(relatedMatch1);
}
const relatedMatch2 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const ChatMessage2 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ChatMessage2?.setMatch)
{
await
ChatMessage2.
setMatch(relatedMatch2);
}
const relatedMatch3 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const ChatMessage3 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ChatMessage3?.setMatch)
{
await
ChatMessage3.
setMatch(relatedMatch3);
}
const relatedMatch4 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const ChatMessage4 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ChatMessage4?.setMatch)
{
await
ChatMessage4.
setMatch(relatedMatch4);
}
}
async function associateChatMessageWithSender() {
const relatedSender0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatMessage0 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ChatMessage0?.setSender)
{
await
ChatMessage0.
setSender(relatedSender0);
}
const relatedSender1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatMessage1 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ChatMessage1?.setSender)
{
await
ChatMessage1.
setSender(relatedSender1);
}
const relatedSender2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatMessage2 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ChatMessage2?.setSender)
{
await
ChatMessage2.
setSender(relatedSender2);
}
const relatedSender3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatMessage3 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ChatMessage3?.setSender)
{
await
ChatMessage3.
setSender(relatedSender3);
}
const relatedSender4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ChatMessage4 = await ChatMessages.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ChatMessage4?.setSender)
{
await
ChatMessage4.
setSender(relatedSender4);
}
}
async function associateSpectatorSessionWithMatch() {
const relatedMatch0 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const SpectatorSession0 = await SpectatorSessions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SpectatorSession0?.setMatch)
{
await
SpectatorSession0.
setMatch(relatedMatch0);
}
const relatedMatch1 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const SpectatorSession1 = await SpectatorSessions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SpectatorSession1?.setMatch)
{
await
SpectatorSession1.
setMatch(relatedMatch1);
}
const relatedMatch2 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const SpectatorSession2 = await SpectatorSessions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SpectatorSession2?.setMatch)
{
await
SpectatorSession2.
setMatch(relatedMatch2);
}
const relatedMatch3 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const SpectatorSession3 = await SpectatorSessions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SpectatorSession3?.setMatch)
{
await
SpectatorSession3.
setMatch(relatedMatch3);
}
const relatedMatch4 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const SpectatorSession4 = await SpectatorSessions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (SpectatorSession4?.setMatch)
{
await
SpectatorSession4.
setMatch(relatedMatch4);
}
}
async function associateSpectatorSessionWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SpectatorSession0 = await SpectatorSessions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (SpectatorSession0?.setUser)
{
await
SpectatorSession0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SpectatorSession1 = await SpectatorSessions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (SpectatorSession1?.setUser)
{
await
SpectatorSession1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SpectatorSession2 = await SpectatorSessions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (SpectatorSession2?.setUser)
{
await
SpectatorSession2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SpectatorSession3 = await SpectatorSessions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (SpectatorSession3?.setUser)
{
await
SpectatorSession3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const SpectatorSession4 = await SpectatorSessions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (SpectatorSession4?.setUser)
{
await
SpectatorSession4.
setUser(relatedUser4);
}
}
async function associatePointsTransactionWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PointsTransaction0 = await PointsTransactions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PointsTransaction0?.setUser)
{
await
PointsTransaction0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PointsTransaction1 = await PointsTransactions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PointsTransaction1?.setUser)
{
await
PointsTransaction1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PointsTransaction2 = await PointsTransactions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PointsTransaction2?.setUser)
{
await
PointsTransaction2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PointsTransaction3 = await PointsTransactions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PointsTransaction3?.setUser)
{
await
PointsTransaction3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PointsTransaction4 = await PointsTransactions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PointsTransaction4?.setUser)
{
await
PointsTransaction4.
setUser(relatedUser4);
}
}
async function associatePointsTransactionWithMatch() {
const relatedMatch0 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const PointsTransaction0 = await PointsTransactions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PointsTransaction0?.setMatch)
{
await
PointsTransaction0.
setMatch(relatedMatch0);
}
const relatedMatch1 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const PointsTransaction1 = await PointsTransactions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PointsTransaction1?.setMatch)
{
await
PointsTransaction1.
setMatch(relatedMatch1);
}
const relatedMatch2 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const PointsTransaction2 = await PointsTransactions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PointsTransaction2?.setMatch)
{
await
PointsTransaction2.
setMatch(relatedMatch2);
}
const relatedMatch3 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const PointsTransaction3 = await PointsTransactions.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PointsTransaction3?.setMatch)
{
await
PointsTransaction3.
setMatch(relatedMatch3);
}
const relatedMatch4 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const PointsTransaction4 = await PointsTransactions.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PointsTransaction4?.setMatch)
{
await
PointsTransaction4.
setMatch(relatedMatch4);
}
}
async function associateShopPurchasWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ShopPurchas0 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ShopPurchas0?.setUser)
{
await
ShopPurchas0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ShopPurchas1 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ShopPurchas1?.setUser)
{
await
ShopPurchas1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ShopPurchas2 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ShopPurchas2?.setUser)
{
await
ShopPurchas2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ShopPurchas3 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ShopPurchas3?.setUser)
{
await
ShopPurchas3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ShopPurchas4 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ShopPurchas4?.setUser)
{
await
ShopPurchas4.
setUser(relatedUser4);
}
}
async function associateShopPurchasWithShop_item() {
const relatedShop_item0 = await ShopItems.findOne({
offset: Math.floor(Math.random() * (await ShopItems.count())),
});
const ShopPurchas0 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ShopPurchas0?.setShop_item)
{
await
ShopPurchas0.
setShop_item(relatedShop_item0);
}
const relatedShop_item1 = await ShopItems.findOne({
offset: Math.floor(Math.random() * (await ShopItems.count())),
});
const ShopPurchas1 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ShopPurchas1?.setShop_item)
{
await
ShopPurchas1.
setShop_item(relatedShop_item1);
}
const relatedShop_item2 = await ShopItems.findOne({
offset: Math.floor(Math.random() * (await ShopItems.count())),
});
const ShopPurchas2 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ShopPurchas2?.setShop_item)
{
await
ShopPurchas2.
setShop_item(relatedShop_item2);
}
const relatedShop_item3 = await ShopItems.findOne({
offset: Math.floor(Math.random() * (await ShopItems.count())),
});
const ShopPurchas3 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ShopPurchas3?.setShop_item)
{
await
ShopPurchas3.
setShop_item(relatedShop_item3);
}
const relatedShop_item4 = await ShopItems.findOne({
offset: Math.floor(Math.random() * (await ShopItems.count())),
});
const ShopPurchas4 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ShopPurchas4?.setShop_item)
{
await
ShopPurchas4.
setShop_item(relatedShop_item4);
}
}
async function associateShopPurchasWithMatch() {
const relatedMatch0 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const ShopPurchas0 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ShopPurchas0?.setMatch)
{
await
ShopPurchas0.
setMatch(relatedMatch0);
}
const relatedMatch1 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const ShopPurchas1 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ShopPurchas1?.setMatch)
{
await
ShopPurchas1.
setMatch(relatedMatch1);
}
const relatedMatch2 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const ShopPurchas2 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ShopPurchas2?.setMatch)
{
await
ShopPurchas2.
setMatch(relatedMatch2);
}
const relatedMatch3 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const ShopPurchas3 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ShopPurchas3?.setMatch)
{
await
ShopPurchas3.
setMatch(relatedMatch3);
}
const relatedMatch4 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const ShopPurchas4 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ShopPurchas4?.setMatch)
{
await
ShopPurchas4.
setMatch(relatedMatch4);
}
}
async function associateShopPurchasWithRound() {
const relatedRound0 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const ShopPurchas0 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ShopPurchas0?.setRound)
{
await
ShopPurchas0.
setRound(relatedRound0);
}
const relatedRound1 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const ShopPurchas1 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ShopPurchas1?.setRound)
{
await
ShopPurchas1.
setRound(relatedRound1);
}
const relatedRound2 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const ShopPurchas2 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ShopPurchas2?.setRound)
{
await
ShopPurchas2.
setRound(relatedRound2);
}
const relatedRound3 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const ShopPurchas3 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (ShopPurchas3?.setRound)
{
await
ShopPurchas3.
setRound(relatedRound3);
}
const relatedRound4 = await MatchRounds.findOne({
offset: Math.floor(Math.random() * (await MatchRounds.count())),
});
const ShopPurchas4 = await ShopPurchases.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (ShopPurchas4?.setRound)
{
await
ShopPurchas4.
setRound(relatedRound4);
}
}
async function associatePlayerStatWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PlayerStat0 = await PlayerStats.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PlayerStat0?.setUser)
{
await
PlayerStat0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PlayerStat1 = await PlayerStats.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PlayerStat1?.setUser)
{
await
PlayerStat1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PlayerStat2 = await PlayerStats.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PlayerStat2?.setUser)
{
await
PlayerStat2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PlayerStat3 = await PlayerStats.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (PlayerStat3?.setUser)
{
await
PlayerStat3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PlayerStat4 = await PlayerStats.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (PlayerStat4?.setUser)
{
await
PlayerStat4.
setUser(relatedUser4);
}
}
async function associateReplayWithMatch() {
const relatedMatch0 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const Replay0 = await Replays.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Replay0?.setMatch)
{
await
Replay0.
setMatch(relatedMatch0);
}
const relatedMatch1 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const Replay1 = await Replays.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Replay1?.setMatch)
{
await
Replay1.
setMatch(relatedMatch1);
}
const relatedMatch2 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const Replay2 = await Replays.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Replay2?.setMatch)
{
await
Replay2.
setMatch(relatedMatch2);
}
const relatedMatch3 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const Replay3 = await Replays.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Replay3?.setMatch)
{
await
Replay3.
setMatch(relatedMatch3);
}
const relatedMatch4 = await Matches.findOne({
offset: Math.floor(Math.random() * (await Matches.count())),
});
const Replay4 = await Replays.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Replay4?.setMatch)
{
await
Replay4.
setMatch(relatedMatch4);
}
}
async function associateNotificationWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification0 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Notification0?.setUser)
{
await
Notification0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification1 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Notification1?.setUser)
{
await
Notification1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification2 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Notification2?.setUser)
{
await
Notification2.
setUser(relatedUser2);
}
const relatedUser3 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification3 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 3
});
if (Notification3?.setUser)
{
await
Notification3.
setUser(relatedUser3);
}
const relatedUser4 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Notification4 = await Notifications.findOne({
order: [['id', 'ASC']],
offset: 4
});
if (Notification4?.setUser)
{
await
Notification4.
setUser(relatedUser4);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await PasswordResets.bulkCreate(PasswordResetsData);
await Friendships.bulkCreate(FriendshipsData);
await CodingChallenges.bulkCreate(CodingChallengesData);
await MatchmakingQueues.bulkCreate(MatchmakingQueuesData);
await Matches.bulkCreate(MatchesData);
await MatchRounds.bulkCreate(MatchRoundsData);
await RoundSubmissions.bulkCreate(RoundSubmissionsData);
await MatchEvents.bulkCreate(MatchEventsData);
await ChatMessages.bulkCreate(ChatMessagesData);
await SpectatorSessions.bulkCreate(SpectatorSessionsData);
await RankTiers.bulkCreate(RankTiersData);
await PointsTransactions.bulkCreate(PointsTransactionsData);
await ShopItems.bulkCreate(ShopItemsData);
await ShopPurchases.bulkCreate(ShopPurchasesData);
await PlayerStats.bulkCreate(PlayerStatsData);
await Replays.bulkCreate(ReplaysData);
await Notifications.bulkCreate(NotificationsData);
await Promise.all([
// Similar logic for "relation_many"
await associatePasswordResetWithUser(),
await associateFriendshipWithRequester(),
await associateFriendshipWithAddressee(),
await associateCodingChallengeWithCreated_by_user(),
await associateMatcheWithQueue(),
await associateMatcheWithPlayer_one(),
await associateMatcheWithPlayer_two(),
await associateMatcheWithWinner(),
await associateMatcheWithRematch_requested_by(),
await associateMatchRoundWithMatch(),
await associateMatchRoundWithChallenge(),
await associateMatchRoundWithWinner(),
await associateRoundSubmissionWithRound(),
await associateRoundSubmissionWithUser(),
await associateMatchEventWithMatch(),
await associateMatchEventWithRound(),
await associateMatchEventWithActor(),
await associateChatMessageWithMatch(),
await associateChatMessageWithSender(),
await associateSpectatorSessionWithMatch(),
await associateSpectatorSessionWithUser(),
await associatePointsTransactionWithUser(),
await associatePointsTransactionWithMatch(),
await associateShopPurchasWithUser(),
await associateShopPurchasWithShop_item(),
await associateShopPurchasWithMatch(),
await associateShopPurchasWithRound(),
await associatePlayerStatWithUser(),
await associateReplayWithMatch(),
await associateNotificationWithUser(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('password_resets', null, {});
await queryInterface.bulkDelete('friendships', null, {});
await queryInterface.bulkDelete('coding_challenges', null, {});
await queryInterface.bulkDelete('matchmaking_queues', null, {});
await queryInterface.bulkDelete('matches', null, {});
await queryInterface.bulkDelete('match_rounds', null, {});
await queryInterface.bulkDelete('round_submissions', null, {});
await queryInterface.bulkDelete('match_events', null, {});
await queryInterface.bulkDelete('chat_messages', null, {});
await queryInterface.bulkDelete('spectator_sessions', null, {});
await queryInterface.bulkDelete('rank_tiers', null, {});
await queryInterface.bulkDelete('points_transactions', null, {});
await queryInterface.bulkDelete('shop_items', null, {});
await queryInterface.bulkDelete('shop_purchases', null, {});
await queryInterface.bulkDelete('player_stats', null, {});
await queryInterface.bulkDelete('replays', null, {});
await queryInterface.bulkDelete('notifications', null, {});
},
};