39139-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-03-11 16:42:42 +00:00

3514 lines
81 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Organizations = db.organizations;
const DiscordServers = db.discord_servers;
const DiscordChannels = db.discord_channels;
const Webhooks = db.webhooks;
const DiscordMembers = db.discord_members;
const OsrsAccounts = db.osrs_accounts;
const ScanRuns = db.scan_runs;
const MessageEvents = db.message_events;
const MemberMatches = db.member_matches;
const ActivityStats = db.activity_stats;
const OrganizationsData = [
{
"name": "Ada Lovelace",
},
{
"name": "Ada Lovelace",
},
{
"name": "Marie Curie",
},
];
const DiscordServersData = [
{
"server_name": "Iron Vanguard",
"server_identifier": "987654321001122334",
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
"server_name": "Rune Fellowship",
"server_identifier": "987654321009988776",
// type code here for "relation_one" field
// type code here for "relation_one" field
},
{
"server_name": "PvM Council",
"server_identifier": "987654321005566778",
// type code here for "relation_one" field
// type code here for "relation_one" field
},
];
const DiscordChannelsData = [
{
// type code here for "relation_one" field
"channel_name": "clan-chat",
"channel_identifier": "112233445566778899",
"is_tracked": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"channel_name": "loot-logs",
"channel_identifier": "223344556677889900",
"is_tracked": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"channel_name": "activity-feed",
"channel_identifier": "334455667788990011",
"is_tracked": true,
// type code here for "relation_one" field
},
];
const WebhooksData = [
{
// type code here for "relation_one" field
"webhook_name": "OSRS Clan Webhook",
"webhook_identifier": "whk_ironvanguard_001",
"is_enabled": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"webhook_name": "Rune Fellowship Feed",
"webhook_identifier": "whk_runefellowship_001",
"is_enabled": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"webhook_name": "PvM Updates Webhook",
"webhook_identifier": "whk_pvmcouncil_001",
"is_enabled": true,
// type code here for "relation_one" field
},
];
const DiscordMembersData = [
{
// type code here for "relation_one" field
"discord_user_identifier": "155500011122233344",
"username": "a_morgan",
"display_name": "Alex M.",
"nickname": "Asterion | Astra",
"name_main": "Asterion",
"name_alt": "Astra",
"last_seen_at": new Date('2026-03-01T19:22:10Z'),
"is_in_server": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"discord_user_identifier": "155500011122233355",
"username": "j_lee",
"display_name": "Jordan L.",
"nickname": "Briar King | Briar Alt",
"name_main": "Briar King",
"name_alt": "Briar Alt",
"last_seen_at": new Date('2026-03-02T09:10:44Z'),
"is_in_server": true,
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
"discord_user_identifier": "155500011122233366",
"username": "p_patel",
"display_name": "Priya P.",
"nickname": "Sable Sun | Sable Skiller",
"name_main": "Sable Sun",
"name_alt": "Sable Skiller",
"last_seen_at": new Date('2026-03-03T14:05:31Z'),
"is_in_server": true,
// type code here for "relation_one" field
},
];
const OsrsAccountsData = [
{
"rsn": "Asterion",
// type code here for "relation_one" field
"account_type": "unknown",
"is_active": true,
// type code here for "relation_one" field
},
{
"rsn": "Astra",
// type code here for "relation_one" field
"account_type": "main",
"is_active": true,
// type code here for "relation_one" field
},
{
"rsn": "Briar King",
// type code here for "relation_one" field
"account_type": "main",
"is_active": true,
// type code here for "relation_one" field
},
];
const ScanRunsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"started_at": new Date('2026-03-01T00:05:00Z'),
"finished_at": new Date('2026-03-01T00:18:40Z'),
"status": "canceled",
"days_back": 30,
"window_start": new Date('2026-01-30T00:00:00Z'),
"window_end": new Date('2026-03-01T00:00:00Z'),
"messages_scanned": 120000,
"messages_matched": 118450,
"messages_unmatched": 1550,
"error_message": "None",
// 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
"started_at": new Date('2026-03-02T01:05:00Z'),
"finished_at": new Date('2026-03-02T01:16:12Z'),
"status": "running",
"days_back": 30,
"window_start": new Date('2026-01-31T00:00:00Z'),
"window_end": new Date('2026-03-02T00:00:00Z'),
"messages_scanned": 64210,
"messages_matched": 63002,
"messages_unmatched": 1208,
"error_message": "None",
// 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
"started_at": new Date('2026-03-03T02:20:00Z'),
"finished_at": new Date('2026-03-03T02:22:10Z'),
"status": "canceled",
"days_back": 30,
"window_start": new Date('2026-02-01T00:00:00Z'),
"window_end": new Date('2026-03-03T00:00:00Z'),
"messages_scanned": 8200,
"messages_matched": 0,
"messages_unmatched": 0,
"error_message": "Discord API rate limit hit during fetch",
// type code here for "relation_one" field
// type code here for "relation_one" field
},
];
const MessageEventsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_identifier": "120001",
"message_timestamp": new Date('2026-02-25T18:12:09Z'),
"raw_content": "Asterion achieved 99 Attack",
"extracted_rsn": "Asterion",
"extract_status": "extracted",
// 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
"message_identifier": "120002",
"message_timestamp": new Date('2026-02-25T18:13:45Z'),
"raw_content": "Briar King received a rare drop",
"extracted_rsn": "Briar King",
"extract_status": "parse_error",
// 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
"message_identifier": "220001",
"message_timestamp": new Date('2026-02-26T09:55:01Z'),
"raw_content": "Sable Sun completed a clue scroll",
"extracted_rsn": "Sable Sun",
"extract_status": "extracted",
// type code here for "relation_one" field
},
];
const MemberMatchesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"match_method": "manual_override",
"confidence": 0.98,
"match_notes": "Matched main name from nickname format",
// 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
"match_method": "nickname_alt",
"confidence": 0.96,
"match_notes": "Matched alt name from nickname format",
// 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
"match_method": "nickname_main",
"confidence": 0.97,
"match_notes": "Exact main name match",
// type code here for "relation_one" field
},
];
const ActivityStatsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
// type code here for "relation_one" field
"message_count": 842,
"first_message_at": new Date('2026-01-31T00:12:14Z'),
"last_message_at": new Date('2026-02-28T23:58:41Z'),
// 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
"message_count": 615,
"first_message_at": new Date('2026-01-31T01:05:09Z'),
"last_message_at": new Date('2026-02-28T22:40:11Z'),
// 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
"message_count": 402,
"first_message_at": new Date('2026-02-01T02:12:33Z'),
"last_message_at": new Date('2026-03-01T18:21:03Z'),
// type code here for "relation_one" field
},
];
// Similar logic for "relation_many"
async function associateUserWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User0 = await Users.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (User0?.setOrganization)
{
await
User0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User1 = await Users.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (User1?.setOrganization)
{
await
User1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const User2 = await Users.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (User2?.setOrganization)
{
await
User2.
setOrganization(relatedOrganization2);
}
}
async function associateDiscordServerWithOwner_user() {
const relatedOwner_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const DiscordServer0 = await DiscordServers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DiscordServer0?.setOwner_user)
{
await
DiscordServer0.
setOwner_user(relatedOwner_user0);
}
const relatedOwner_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const DiscordServer1 = await DiscordServers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DiscordServer1?.setOwner_user)
{
await
DiscordServer1.
setOwner_user(relatedOwner_user1);
}
const relatedOwner_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const DiscordServer2 = await DiscordServers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DiscordServer2?.setOwner_user)
{
await
DiscordServer2.
setOwner_user(relatedOwner_user2);
}
}
async function associateDiscordServerWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscordServer0 = await DiscordServers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DiscordServer0?.setOrganization)
{
await
DiscordServer0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscordServer1 = await DiscordServers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DiscordServer1?.setOrganization)
{
await
DiscordServer1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscordServer2 = await DiscordServers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DiscordServer2?.setOrganization)
{
await
DiscordServer2.
setOrganization(relatedOrganization2);
}
}
async function associateDiscordChannelWithServer() {
const relatedServer0 = await DiscordServers.findOne({
offset: Math.floor(Math.random() * (await DiscordServers.count())),
});
const DiscordChannel0 = await DiscordChannels.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DiscordChannel0?.setServer)
{
await
DiscordChannel0.
setServer(relatedServer0);
}
const relatedServer1 = await DiscordServers.findOne({
offset: Math.floor(Math.random() * (await DiscordServers.count())),
});
const DiscordChannel1 = await DiscordChannels.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DiscordChannel1?.setServer)
{
await
DiscordChannel1.
setServer(relatedServer1);
}
const relatedServer2 = await DiscordServers.findOne({
offset: Math.floor(Math.random() * (await DiscordServers.count())),
});
const DiscordChannel2 = await DiscordChannels.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DiscordChannel2?.setServer)
{
await
DiscordChannel2.
setServer(relatedServer2);
}
}
async function associateDiscordChannelWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscordChannel0 = await DiscordChannels.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DiscordChannel0?.setOrganization)
{
await
DiscordChannel0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscordChannel1 = await DiscordChannels.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DiscordChannel1?.setOrganization)
{
await
DiscordChannel1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscordChannel2 = await DiscordChannels.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DiscordChannel2?.setOrganization)
{
await
DiscordChannel2.
setOrganization(relatedOrganization2);
}
}
async function associateWebhookWithChannel() {
const relatedChannel0 = await DiscordChannels.findOne({
offset: Math.floor(Math.random() * (await DiscordChannels.count())),
});
const Webhook0 = await Webhooks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Webhook0?.setChannel)
{
await
Webhook0.
setChannel(relatedChannel0);
}
const relatedChannel1 = await DiscordChannels.findOne({
offset: Math.floor(Math.random() * (await DiscordChannels.count())),
});
const Webhook1 = await Webhooks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Webhook1?.setChannel)
{
await
Webhook1.
setChannel(relatedChannel1);
}
const relatedChannel2 = await DiscordChannels.findOne({
offset: Math.floor(Math.random() * (await DiscordChannels.count())),
});
const Webhook2 = await Webhooks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Webhook2?.setChannel)
{
await
Webhook2.
setChannel(relatedChannel2);
}
}
async function associateWebhookWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Webhook0 = await Webhooks.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Webhook0?.setOrganization)
{
await
Webhook0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Webhook1 = await Webhooks.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Webhook1?.setOrganization)
{
await
Webhook1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const Webhook2 = await Webhooks.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Webhook2?.setOrganization)
{
await
Webhook2.
setOrganization(relatedOrganization2);
}
}
async function associateDiscordMemberWithServer() {
const relatedServer0 = await DiscordServers.findOne({
offset: Math.floor(Math.random() * (await DiscordServers.count())),
});
const DiscordMember0 = await DiscordMembers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DiscordMember0?.setServer)
{
await
DiscordMember0.
setServer(relatedServer0);
}
const relatedServer1 = await DiscordServers.findOne({
offset: Math.floor(Math.random() * (await DiscordServers.count())),
});
const DiscordMember1 = await DiscordMembers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DiscordMember1?.setServer)
{
await
DiscordMember1.
setServer(relatedServer1);
}
const relatedServer2 = await DiscordServers.findOne({
offset: Math.floor(Math.random() * (await DiscordServers.count())),
});
const DiscordMember2 = await DiscordMembers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DiscordMember2?.setServer)
{
await
DiscordMember2.
setServer(relatedServer2);
}
}
async function associateDiscordMemberWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscordMember0 = await DiscordMembers.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (DiscordMember0?.setOrganization)
{
await
DiscordMember0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscordMember1 = await DiscordMembers.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (DiscordMember1?.setOrganization)
{
await
DiscordMember1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const DiscordMember2 = await DiscordMembers.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (DiscordMember2?.setOrganization)
{
await
DiscordMember2.
setOrganization(relatedOrganization2);
}
}
async function associateOsrsAccountWithLinked_member() {
const relatedLinked_member0 = await DiscordMembers.findOne({
offset: Math.floor(Math.random() * (await DiscordMembers.count())),
});
const OsrsAccount0 = await OsrsAccounts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (OsrsAccount0?.setLinked_member)
{
await
OsrsAccount0.
setLinked_member(relatedLinked_member0);
}
const relatedLinked_member1 = await DiscordMembers.findOne({
offset: Math.floor(Math.random() * (await DiscordMembers.count())),
});
const OsrsAccount1 = await OsrsAccounts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (OsrsAccount1?.setLinked_member)
{
await
OsrsAccount1.
setLinked_member(relatedLinked_member1);
}
const relatedLinked_member2 = await DiscordMembers.findOne({
offset: Math.floor(Math.random() * (await DiscordMembers.count())),
});
const OsrsAccount2 = await OsrsAccounts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (OsrsAccount2?.setLinked_member)
{
await
OsrsAccount2.
setLinked_member(relatedLinked_member2);
}
}
async function associateOsrsAccountWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const OsrsAccount0 = await OsrsAccounts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (OsrsAccount0?.setOrganization)
{
await
OsrsAccount0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const OsrsAccount1 = await OsrsAccounts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (OsrsAccount1?.setOrganization)
{
await
OsrsAccount1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const OsrsAccount2 = await OsrsAccounts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (OsrsAccount2?.setOrganization)
{
await
OsrsAccount2.
setOrganization(relatedOrganization2);
}
}
async function associateScanRunWithServer() {
const relatedServer0 = await DiscordServers.findOne({
offset: Math.floor(Math.random() * (await DiscordServers.count())),
});
const ScanRun0 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ScanRun0?.setServer)
{
await
ScanRun0.
setServer(relatedServer0);
}
const relatedServer1 = await DiscordServers.findOne({
offset: Math.floor(Math.random() * (await DiscordServers.count())),
});
const ScanRun1 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ScanRun1?.setServer)
{
await
ScanRun1.
setServer(relatedServer1);
}
const relatedServer2 = await DiscordServers.findOne({
offset: Math.floor(Math.random() * (await DiscordServers.count())),
});
const ScanRun2 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ScanRun2?.setServer)
{
await
ScanRun2.
setServer(relatedServer2);
}
}
async function associateScanRunWithChannel() {
const relatedChannel0 = await DiscordChannels.findOne({
offset: Math.floor(Math.random() * (await DiscordChannels.count())),
});
const ScanRun0 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ScanRun0?.setChannel)
{
await
ScanRun0.
setChannel(relatedChannel0);
}
const relatedChannel1 = await DiscordChannels.findOne({
offset: Math.floor(Math.random() * (await DiscordChannels.count())),
});
const ScanRun1 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ScanRun1?.setChannel)
{
await
ScanRun1.
setChannel(relatedChannel1);
}
const relatedChannel2 = await DiscordChannels.findOne({
offset: Math.floor(Math.random() * (await DiscordChannels.count())),
});
const ScanRun2 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ScanRun2?.setChannel)
{
await
ScanRun2.
setChannel(relatedChannel2);
}
}
async function associateScanRunWithTriggered_by() {
const relatedTriggered_by0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ScanRun0 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ScanRun0?.setTriggered_by)
{
await
ScanRun0.
setTriggered_by(relatedTriggered_by0);
}
const relatedTriggered_by1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ScanRun1 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ScanRun1?.setTriggered_by)
{
await
ScanRun1.
setTriggered_by(relatedTriggered_by1);
}
const relatedTriggered_by2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ScanRun2 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ScanRun2?.setTriggered_by)
{
await
ScanRun2.
setTriggered_by(relatedTriggered_by2);
}
}
async function associateScanRunWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ScanRun0 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ScanRun0?.setOrganization)
{
await
ScanRun0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ScanRun1 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ScanRun1?.setOrganization)
{
await
ScanRun1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ScanRun2 = await ScanRuns.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ScanRun2?.setOrganization)
{
await
ScanRun2.
setOrganization(relatedOrganization2);
}
}
async function associateMessageEventWithScan_run() {
const relatedScan_run0 = await ScanRuns.findOne({
offset: Math.floor(Math.random() * (await ScanRuns.count())),
});
const MessageEvent0 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MessageEvent0?.setScan_run)
{
await
MessageEvent0.
setScan_run(relatedScan_run0);
}
const relatedScan_run1 = await ScanRuns.findOne({
offset: Math.floor(Math.random() * (await ScanRuns.count())),
});
const MessageEvent1 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MessageEvent1?.setScan_run)
{
await
MessageEvent1.
setScan_run(relatedScan_run1);
}
const relatedScan_run2 = await ScanRuns.findOne({
offset: Math.floor(Math.random() * (await ScanRuns.count())),
});
const MessageEvent2 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MessageEvent2?.setScan_run)
{
await
MessageEvent2.
setScan_run(relatedScan_run2);
}
}
async function associateMessageEventWithChannel() {
const relatedChannel0 = await DiscordChannels.findOne({
offset: Math.floor(Math.random() * (await DiscordChannels.count())),
});
const MessageEvent0 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MessageEvent0?.setChannel)
{
await
MessageEvent0.
setChannel(relatedChannel0);
}
const relatedChannel1 = await DiscordChannels.findOne({
offset: Math.floor(Math.random() * (await DiscordChannels.count())),
});
const MessageEvent1 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MessageEvent1?.setChannel)
{
await
MessageEvent1.
setChannel(relatedChannel1);
}
const relatedChannel2 = await DiscordChannels.findOne({
offset: Math.floor(Math.random() * (await DiscordChannels.count())),
});
const MessageEvent2 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MessageEvent2?.setChannel)
{
await
MessageEvent2.
setChannel(relatedChannel2);
}
}
async function associateMessageEventWithWebhook() {
const relatedWebhook0 = await Webhooks.findOne({
offset: Math.floor(Math.random() * (await Webhooks.count())),
});
const MessageEvent0 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MessageEvent0?.setWebhook)
{
await
MessageEvent0.
setWebhook(relatedWebhook0);
}
const relatedWebhook1 = await Webhooks.findOne({
offset: Math.floor(Math.random() * (await Webhooks.count())),
});
const MessageEvent1 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MessageEvent1?.setWebhook)
{
await
MessageEvent1.
setWebhook(relatedWebhook1);
}
const relatedWebhook2 = await Webhooks.findOne({
offset: Math.floor(Math.random() * (await Webhooks.count())),
});
const MessageEvent2 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MessageEvent2?.setWebhook)
{
await
MessageEvent2.
setWebhook(relatedWebhook2);
}
}
async function associateMessageEventWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const MessageEvent0 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MessageEvent0?.setOrganization)
{
await
MessageEvent0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const MessageEvent1 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MessageEvent1?.setOrganization)
{
await
MessageEvent1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const MessageEvent2 = await MessageEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MessageEvent2?.setOrganization)
{
await
MessageEvent2.
setOrganization(relatedOrganization2);
}
}
async function associateMemberMatcheWithScan_run() {
const relatedScan_run0 = await ScanRuns.findOne({
offset: Math.floor(Math.random() * (await ScanRuns.count())),
});
const MemberMatche0 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MemberMatche0?.setScan_run)
{
await
MemberMatche0.
setScan_run(relatedScan_run0);
}
const relatedScan_run1 = await ScanRuns.findOne({
offset: Math.floor(Math.random() * (await ScanRuns.count())),
});
const MemberMatche1 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MemberMatche1?.setScan_run)
{
await
MemberMatche1.
setScan_run(relatedScan_run1);
}
const relatedScan_run2 = await ScanRuns.findOne({
offset: Math.floor(Math.random() * (await ScanRuns.count())),
});
const MemberMatche2 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MemberMatche2?.setScan_run)
{
await
MemberMatche2.
setScan_run(relatedScan_run2);
}
}
async function associateMemberMatcheWithOsrs_account() {
const relatedOsrs_account0 = await OsrsAccounts.findOne({
offset: Math.floor(Math.random() * (await OsrsAccounts.count())),
});
const MemberMatche0 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MemberMatche0?.setOsrs_account)
{
await
MemberMatche0.
setOsrs_account(relatedOsrs_account0);
}
const relatedOsrs_account1 = await OsrsAccounts.findOne({
offset: Math.floor(Math.random() * (await OsrsAccounts.count())),
});
const MemberMatche1 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MemberMatche1?.setOsrs_account)
{
await
MemberMatche1.
setOsrs_account(relatedOsrs_account1);
}
const relatedOsrs_account2 = await OsrsAccounts.findOne({
offset: Math.floor(Math.random() * (await OsrsAccounts.count())),
});
const MemberMatche2 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MemberMatche2?.setOsrs_account)
{
await
MemberMatche2.
setOsrs_account(relatedOsrs_account2);
}
}
async function associateMemberMatcheWithDiscord_member() {
const relatedDiscord_member0 = await DiscordMembers.findOne({
offset: Math.floor(Math.random() * (await DiscordMembers.count())),
});
const MemberMatche0 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MemberMatche0?.setDiscord_member)
{
await
MemberMatche0.
setDiscord_member(relatedDiscord_member0);
}
const relatedDiscord_member1 = await DiscordMembers.findOne({
offset: Math.floor(Math.random() * (await DiscordMembers.count())),
});
const MemberMatche1 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MemberMatche1?.setDiscord_member)
{
await
MemberMatche1.
setDiscord_member(relatedDiscord_member1);
}
const relatedDiscord_member2 = await DiscordMembers.findOne({
offset: Math.floor(Math.random() * (await DiscordMembers.count())),
});
const MemberMatche2 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MemberMatche2?.setDiscord_member)
{
await
MemberMatche2.
setDiscord_member(relatedDiscord_member2);
}
}
async function associateMemberMatcheWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const MemberMatche0 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (MemberMatche0?.setOrganization)
{
await
MemberMatche0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const MemberMatche1 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (MemberMatche1?.setOrganization)
{
await
MemberMatche1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const MemberMatche2 = await MemberMatches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (MemberMatche2?.setOrganization)
{
await
MemberMatche2.
setOrganization(relatedOrganization2);
}
}
async function associateActivityStatWithScan_run() {
const relatedScan_run0 = await ScanRuns.findOne({
offset: Math.floor(Math.random() * (await ScanRuns.count())),
});
const ActivityStat0 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ActivityStat0?.setScan_run)
{
await
ActivityStat0.
setScan_run(relatedScan_run0);
}
const relatedScan_run1 = await ScanRuns.findOne({
offset: Math.floor(Math.random() * (await ScanRuns.count())),
});
const ActivityStat1 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ActivityStat1?.setScan_run)
{
await
ActivityStat1.
setScan_run(relatedScan_run1);
}
const relatedScan_run2 = await ScanRuns.findOne({
offset: Math.floor(Math.random() * (await ScanRuns.count())),
});
const ActivityStat2 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ActivityStat2?.setScan_run)
{
await
ActivityStat2.
setScan_run(relatedScan_run2);
}
}
async function associateActivityStatWithOsrs_account() {
const relatedOsrs_account0 = await OsrsAccounts.findOne({
offset: Math.floor(Math.random() * (await OsrsAccounts.count())),
});
const ActivityStat0 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ActivityStat0?.setOsrs_account)
{
await
ActivityStat0.
setOsrs_account(relatedOsrs_account0);
}
const relatedOsrs_account1 = await OsrsAccounts.findOne({
offset: Math.floor(Math.random() * (await OsrsAccounts.count())),
});
const ActivityStat1 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ActivityStat1?.setOsrs_account)
{
await
ActivityStat1.
setOsrs_account(relatedOsrs_account1);
}
const relatedOsrs_account2 = await OsrsAccounts.findOne({
offset: Math.floor(Math.random() * (await OsrsAccounts.count())),
});
const ActivityStat2 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ActivityStat2?.setOsrs_account)
{
await
ActivityStat2.
setOsrs_account(relatedOsrs_account2);
}
}
async function associateActivityStatWithDiscord_member() {
const relatedDiscord_member0 = await DiscordMembers.findOne({
offset: Math.floor(Math.random() * (await DiscordMembers.count())),
});
const ActivityStat0 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ActivityStat0?.setDiscord_member)
{
await
ActivityStat0.
setDiscord_member(relatedDiscord_member0);
}
const relatedDiscord_member1 = await DiscordMembers.findOne({
offset: Math.floor(Math.random() * (await DiscordMembers.count())),
});
const ActivityStat1 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ActivityStat1?.setDiscord_member)
{
await
ActivityStat1.
setDiscord_member(relatedDiscord_member1);
}
const relatedDiscord_member2 = await DiscordMembers.findOne({
offset: Math.floor(Math.random() * (await DiscordMembers.count())),
});
const ActivityStat2 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ActivityStat2?.setDiscord_member)
{
await
ActivityStat2.
setDiscord_member(relatedDiscord_member2);
}
}
async function associateActivityStatWithOrganization() {
const relatedOrganization0 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActivityStat0 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ActivityStat0?.setOrganization)
{
await
ActivityStat0.
setOrganization(relatedOrganization0);
}
const relatedOrganization1 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActivityStat1 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ActivityStat1?.setOrganization)
{
await
ActivityStat1.
setOrganization(relatedOrganization1);
}
const relatedOrganization2 = await Organizations.findOne({
offset: Math.floor(Math.random() * (await Organizations.count())),
});
const ActivityStat2 = await ActivityStats.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ActivityStat2?.setOrganization)
{
await
ActivityStat2.
setOrganization(relatedOrganization2);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Organizations.bulkCreate(OrganizationsData);
await DiscordServers.bulkCreate(DiscordServersData);
await DiscordChannels.bulkCreate(DiscordChannelsData);
await Webhooks.bulkCreate(WebhooksData);
await DiscordMembers.bulkCreate(DiscordMembersData);
await OsrsAccounts.bulkCreate(OsrsAccountsData);
await ScanRuns.bulkCreate(ScanRunsData);
await MessageEvents.bulkCreate(MessageEventsData);
await MemberMatches.bulkCreate(MemberMatchesData);
await ActivityStats.bulkCreate(ActivityStatsData);
await Promise.all([
// Similar logic for "relation_many"
await associateUserWithOrganization(),
await associateDiscordServerWithOwner_user(),
await associateDiscordServerWithOrganization(),
await associateDiscordChannelWithServer(),
await associateDiscordChannelWithOrganization(),
await associateWebhookWithChannel(),
await associateWebhookWithOrganization(),
await associateDiscordMemberWithServer(),
await associateDiscordMemberWithOrganization(),
await associateOsrsAccountWithLinked_member(),
await associateOsrsAccountWithOrganization(),
await associateScanRunWithServer(),
await associateScanRunWithChannel(),
await associateScanRunWithTriggered_by(),
await associateScanRunWithOrganization(),
await associateMessageEventWithScan_run(),
await associateMessageEventWithChannel(),
await associateMessageEventWithWebhook(),
await associateMessageEventWithOrganization(),
await associateMemberMatcheWithScan_run(),
await associateMemberMatcheWithOsrs_account(),
await associateMemberMatcheWithDiscord_member(),
await associateMemberMatcheWithOrganization(),
await associateActivityStatWithScan_run(),
await associateActivityStatWithOsrs_account(),
await associateActivityStatWithDiscord_member(),
await associateActivityStatWithOrganization(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('organizations', null, {});
await queryInterface.bulkDelete('discord_servers', null, {});
await queryInterface.bulkDelete('discord_channels', null, {});
await queryInterface.bulkDelete('webhooks', null, {});
await queryInterface.bulkDelete('discord_members', null, {});
await queryInterface.bulkDelete('osrs_accounts', null, {});
await queryInterface.bulkDelete('scan_runs', null, {});
await queryInterface.bulkDelete('message_events', null, {});
await queryInterface.bulkDelete('member_matches', null, {});
await queryInterface.bulkDelete('activity_stats', null, {});
},
};