const db = require('../models'); const Users = db.users; const Channels = db.channels; const Playlists = db.playlists; const Tags = db.tags; const Videos = db.videos; const VideoComments = db.video_comments; const CommentReactions = db.comment_reactions; const VideoSuggestions = db.video_suggestions; const Reports = db.reports; const ModerationActions = db.moderation_actions; const ChannelsData = [ { "name": "Grace Hopper", "youtube_handle": "Ada Lovelace", "youtube_channel_url": "Grace Hopper", "description": "Ada Lovelace", // type code here for "images" field // type code here for "images" field "is_active": false, }, { "name": "Ada Lovelace", "youtube_handle": "Alan Turing", "youtube_channel_url": "Marie Curie", "description": "Alan Turing", // type code here for "images" field // type code here for "images" field "is_active": true, }, { "name": "Ada Lovelace", "youtube_handle": "Marie Curie", "youtube_channel_url": "Grace Hopper", "description": "Marie Curie", // type code here for "images" field // type code here for "images" field "is_active": false, }, { "name": "Ada Lovelace", "youtube_handle": "Grace Hopper", "youtube_channel_url": "Ada Lovelace", "description": "Marie Curie", // type code here for "images" field // type code here for "images" field "is_active": false, }, ]; const PlaylistsData = [ { // type code here for "relation_one" field "title": "Marie Curie", "youtube_playlist_url": "Ada Lovelace", "description": "Alan Turing", // type code here for "images" field "sort_order": 5, "is_public": false, }, { // type code here for "relation_one" field "title": "Alan Turing", "youtube_playlist_url": "Grace Hopper", "description": "Grace Hopper", // type code here for "images" field "sort_order": 6, "is_public": true, }, { // type code here for "relation_one" field "title": "Ada Lovelace", "youtube_playlist_url": "Alan Turing", "description": "Alan Turing", // type code here for "images" field "sort_order": 7, "is_public": false, }, { // type code here for "relation_one" field "title": "Alan Turing", "youtube_playlist_url": "Alan Turing", "description": "Grace Hopper", // type code here for "images" field "sort_order": 6, "is_public": false, }, ]; const TagsData = [ { "name": "Grace Hopper", "slug": "Alan Turing", }, { "name": "Marie Curie", "slug": "Alan Turing", }, { "name": "Marie Curie", "slug": "Alan Turing", }, { "name": "Ada Lovelace", "slug": "Alan Turing", }, ]; const VideosData = [ { // type code here for "relation_one" field // type code here for "relation_one" field "title": "Grace Hopper", "youtube_video_url": "Marie Curie", "youtube_video_key": "Marie Curie", "description": "Marie Curie", // type code here for "images" field "published_at": new Date(Date.now()), "synced_at": new Date(Date.now()), "visibility": "private", "duration_seconds": 2, "view_count": 4, "youtube_like_count": 6, "comment_count": 2, // type code here for "relation_many" field "allow_in_app_comments": true, }, { // type code here for "relation_one" field // type code here for "relation_one" field "title": "Alan Turing", "youtube_video_url": "Ada Lovelace", "youtube_video_key": "Marie Curie", "description": "Marie Curie", // type code here for "images" field "published_at": new Date(Date.now()), "synced_at": new Date(Date.now()), "visibility": "private", "duration_seconds": 1, "view_count": 5, "youtube_like_count": 7, "comment_count": 8, // type code here for "relation_many" field "allow_in_app_comments": false, }, { // type code here for "relation_one" field // type code here for "relation_one" field "title": "Ada Lovelace", "youtube_video_url": "Marie Curie", "youtube_video_key": "Alan Turing", "description": "Grace Hopper", // type code here for "images" field "published_at": new Date(Date.now()), "synced_at": new Date(Date.now()), "visibility": "public", "duration_seconds": 4, "view_count": 8, "youtube_like_count": 1, "comment_count": 1, // type code here for "relation_many" field "allow_in_app_comments": false, }, { // type code here for "relation_one" field // type code here for "relation_one" field "title": "Grace Hopper", "youtube_video_url": "Alan Turing", "youtube_video_key": "Alan Turing", "description": "Grace Hopper", // type code here for "images" field "published_at": new Date(Date.now()), "synced_at": new Date(Date.now()), "visibility": "unlisted", "duration_seconds": 2, "view_count": 5, "youtube_like_count": 4, "comment_count": 3, // type code here for "relation_many" field "allow_in_app_comments": false, }, ]; const VideoCommentsData = [ { // type code here for "relation_one" field // type code here for "relation_one" field // type code here for "relation_one" field "content": "Marie Curie", "status": "rejected", "like_count": 7, "report_count": 2, "submitted_at": new Date(Date.now()), "moderated_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field // type code here for "relation_one" field "content": "Ada Lovelace", "status": "pending", "like_count": 2, "report_count": 7, "submitted_at": new Date(Date.now()), "moderated_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field // type code here for "relation_one" field "content": "Ada Lovelace", "status": "hidden", "like_count": 7, "report_count": 8, "submitted_at": new Date(Date.now()), "moderated_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field // type code here for "relation_one" field "content": "Alan Turing", "status": "approved", "like_count": 6, "report_count": 4, "submitted_at": new Date(Date.now()), "moderated_at": new Date(Date.now()), }, ]; const CommentReactionsData = [ { // type code here for "relation_one" field // type code here for "relation_one" field "reaction": "dislike", "reacted_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field "reaction": "dislike", "reacted_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field "reaction": "like", "reacted_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field "reaction": "like", "reacted_at": new Date(Date.now()), }, ]; const VideoSuggestionsData = [ { // type code here for "relation_one" field // type code here for "relation_one" field "title": "Alan Turing", "youtube_video_url": "Alan Turing", "notes": "Grace Hopper", "status": "reviewing", "submitted_at": new Date(Date.now()), "reviewed_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field "title": "Grace Hopper", "youtube_video_url": "Alan Turing", "notes": "Alan Turing", "status": "accepted", "submitted_at": new Date(Date.now()), "reviewed_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field "title": "Ada Lovelace", "youtube_video_url": "Grace Hopper", "notes": "Ada Lovelace", "status": "accepted", "submitted_at": new Date(Date.now()), "reviewed_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field "title": "Grace Hopper", "youtube_video_url": "Marie Curie", "notes": "Grace Hopper", "status": "new", "submitted_at": new Date(Date.now()), "reviewed_at": new Date(Date.now()), }, ]; const ReportsData = [ { // type code here for "relation_one" field // type code here for "relation_one" field "reason": "violence", "details": "Alan Turing", "status": "resolved", "reported_at": new Date(Date.now()), "resolved_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field "reason": "spam", "details": "Ada Lovelace", "status": "resolved", "reported_at": new Date(Date.now()), "resolved_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field "reason": "harassment", "details": "Ada Lovelace", "status": "dismissed", "reported_at": new Date(Date.now()), "resolved_at": new Date(Date.now()), }, { // type code here for "relation_one" field // type code here for "relation_one" field "reason": "harassment", "details": "Alan Turing", "status": "resolved", "reported_at": new Date(Date.now()), "resolved_at": new Date(Date.now()), }, ]; const ModerationActionsData = [ { // 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 "action_type": "ban_user", "reason": "Marie Curie", "performed_at": new Date(Date.now()), }, { // 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 "action_type": "unhide_comment", "reason": "Marie Curie", "performed_at": new Date(Date.now()), }, { // 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 "action_type": "unban_user", "reason": "Marie Curie", "performed_at": new Date(Date.now()), }, { // 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 "action_type": "accept_suggestion", "reason": "Marie Curie", "performed_at": new Date(Date.now()), }, ]; // Similar logic for "relation_many" async function associatePlaylistWithChannel() { const relatedChannel0 = await Channels.findOne({ offset: Math.floor(Math.random() * (await Channels.count())), }); const Playlist0 = await Playlists.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Playlist0?.setChannel) { await Playlist0. setChannel(relatedChannel0); } const relatedChannel1 = await Channels.findOne({ offset: Math.floor(Math.random() * (await Channels.count())), }); const Playlist1 = await Playlists.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Playlist1?.setChannel) { await Playlist1. setChannel(relatedChannel1); } const relatedChannel2 = await Channels.findOne({ offset: Math.floor(Math.random() * (await Channels.count())), }); const Playlist2 = await Playlists.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Playlist2?.setChannel) { await Playlist2. setChannel(relatedChannel2); } const relatedChannel3 = await Channels.findOne({ offset: Math.floor(Math.random() * (await Channels.count())), }); const Playlist3 = await Playlists.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Playlist3?.setChannel) { await Playlist3. setChannel(relatedChannel3); } } async function associateVideoWithChannel() { const relatedChannel0 = await Channels.findOne({ offset: Math.floor(Math.random() * (await Channels.count())), }); const Video0 = await Videos.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Video0?.setChannel) { await Video0. setChannel(relatedChannel0); } const relatedChannel1 = await Channels.findOne({ offset: Math.floor(Math.random() * (await Channels.count())), }); const Video1 = await Videos.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Video1?.setChannel) { await Video1. setChannel(relatedChannel1); } const relatedChannel2 = await Channels.findOne({ offset: Math.floor(Math.random() * (await Channels.count())), }); const Video2 = await Videos.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Video2?.setChannel) { await Video2. setChannel(relatedChannel2); } const relatedChannel3 = await Channels.findOne({ offset: Math.floor(Math.random() * (await Channels.count())), }); const Video3 = await Videos.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Video3?.setChannel) { await Video3. setChannel(relatedChannel3); } } async function associateVideoWithPlaylist() { const relatedPlaylist0 = await Playlists.findOne({ offset: Math.floor(Math.random() * (await Playlists.count())), }); const Video0 = await Videos.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Video0?.setPlaylist) { await Video0. setPlaylist(relatedPlaylist0); } const relatedPlaylist1 = await Playlists.findOne({ offset: Math.floor(Math.random() * (await Playlists.count())), }); const Video1 = await Videos.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Video1?.setPlaylist) { await Video1. setPlaylist(relatedPlaylist1); } const relatedPlaylist2 = await Playlists.findOne({ offset: Math.floor(Math.random() * (await Playlists.count())), }); const Video2 = await Videos.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Video2?.setPlaylist) { await Video2. setPlaylist(relatedPlaylist2); } const relatedPlaylist3 = await Playlists.findOne({ offset: Math.floor(Math.random() * (await Playlists.count())), }); const Video3 = await Videos.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Video3?.setPlaylist) { await Video3. setPlaylist(relatedPlaylist3); } } // Similar logic for "relation_many" async function associateVideoCommentWithVideo() { const relatedVideo0 = await Videos.findOne({ offset: Math.floor(Math.random() * (await Videos.count())), }); const VideoComment0 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 0 }); if (VideoComment0?.setVideo) { await VideoComment0. setVideo(relatedVideo0); } const relatedVideo1 = await Videos.findOne({ offset: Math.floor(Math.random() * (await Videos.count())), }); const VideoComment1 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 1 }); if (VideoComment1?.setVideo) { await VideoComment1. setVideo(relatedVideo1); } const relatedVideo2 = await Videos.findOne({ offset: Math.floor(Math.random() * (await Videos.count())), }); const VideoComment2 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 2 }); if (VideoComment2?.setVideo) { await VideoComment2. setVideo(relatedVideo2); } const relatedVideo3 = await Videos.findOne({ offset: Math.floor(Math.random() * (await Videos.count())), }); const VideoComment3 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 3 }); if (VideoComment3?.setVideo) { await VideoComment3. setVideo(relatedVideo3); } } async function associateVideoCommentWithAuthor() { const relatedAuthor0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const VideoComment0 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 0 }); if (VideoComment0?.setAuthor) { await VideoComment0. setAuthor(relatedAuthor0); } const relatedAuthor1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const VideoComment1 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 1 }); if (VideoComment1?.setAuthor) { await VideoComment1. setAuthor(relatedAuthor1); } const relatedAuthor2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const VideoComment2 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 2 }); if (VideoComment2?.setAuthor) { await VideoComment2. setAuthor(relatedAuthor2); } const relatedAuthor3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const VideoComment3 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 3 }); if (VideoComment3?.setAuthor) { await VideoComment3. setAuthor(relatedAuthor3); } } async function associateVideoCommentWithParent_comment() { const relatedParent_comment0 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const VideoComment0 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 0 }); if (VideoComment0?.setParent_comment) { await VideoComment0. setParent_comment(relatedParent_comment0); } const relatedParent_comment1 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const VideoComment1 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 1 }); if (VideoComment1?.setParent_comment) { await VideoComment1. setParent_comment(relatedParent_comment1); } const relatedParent_comment2 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const VideoComment2 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 2 }); if (VideoComment2?.setParent_comment) { await VideoComment2. setParent_comment(relatedParent_comment2); } const relatedParent_comment3 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const VideoComment3 = await VideoComments.findOne({ order: [['id', 'ASC']], offset: 3 }); if (VideoComment3?.setParent_comment) { await VideoComment3. setParent_comment(relatedParent_comment3); } } async function associateCommentReactionWithComment() { const relatedComment0 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const CommentReaction0 = await CommentReactions.findOne({ order: [['id', 'ASC']], offset: 0 }); if (CommentReaction0?.setComment) { await CommentReaction0. setComment(relatedComment0); } const relatedComment1 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const CommentReaction1 = await CommentReactions.findOne({ order: [['id', 'ASC']], offset: 1 }); if (CommentReaction1?.setComment) { await CommentReaction1. setComment(relatedComment1); } const relatedComment2 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const CommentReaction2 = await CommentReactions.findOne({ order: [['id', 'ASC']], offset: 2 }); if (CommentReaction2?.setComment) { await CommentReaction2. setComment(relatedComment2); } const relatedComment3 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const CommentReaction3 = await CommentReactions.findOne({ order: [['id', 'ASC']], offset: 3 }); if (CommentReaction3?.setComment) { await CommentReaction3. setComment(relatedComment3); } } async function associateCommentReactionWithUser() { const relatedUser0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const CommentReaction0 = await CommentReactions.findOne({ order: [['id', 'ASC']], offset: 0 }); if (CommentReaction0?.setUser) { await CommentReaction0. setUser(relatedUser0); } const relatedUser1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const CommentReaction1 = await CommentReactions.findOne({ order: [['id', 'ASC']], offset: 1 }); if (CommentReaction1?.setUser) { await CommentReaction1. setUser(relatedUser1); } const relatedUser2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const CommentReaction2 = await CommentReactions.findOne({ order: [['id', 'ASC']], offset: 2 }); if (CommentReaction2?.setUser) { await CommentReaction2. setUser(relatedUser2); } const relatedUser3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const CommentReaction3 = await CommentReactions.findOne({ order: [['id', 'ASC']], offset: 3 }); if (CommentReaction3?.setUser) { await CommentReaction3. setUser(relatedUser3); } } async function associateVideoSuggestionWithSuggested_by() { const relatedSuggested_by0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const VideoSuggestion0 = await VideoSuggestions.findOne({ order: [['id', 'ASC']], offset: 0 }); if (VideoSuggestion0?.setSuggested_by) { await VideoSuggestion0. setSuggested_by(relatedSuggested_by0); } const relatedSuggested_by1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const VideoSuggestion1 = await VideoSuggestions.findOne({ order: [['id', 'ASC']], offset: 1 }); if (VideoSuggestion1?.setSuggested_by) { await VideoSuggestion1. setSuggested_by(relatedSuggested_by1); } const relatedSuggested_by2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const VideoSuggestion2 = await VideoSuggestions.findOne({ order: [['id', 'ASC']], offset: 2 }); if (VideoSuggestion2?.setSuggested_by) { await VideoSuggestion2. setSuggested_by(relatedSuggested_by2); } const relatedSuggested_by3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const VideoSuggestion3 = await VideoSuggestions.findOne({ order: [['id', 'ASC']], offset: 3 }); if (VideoSuggestion3?.setSuggested_by) { await VideoSuggestion3. setSuggested_by(relatedSuggested_by3); } } async function associateVideoSuggestionWithRelated_video() { const relatedRelated_video0 = await Videos.findOne({ offset: Math.floor(Math.random() * (await Videos.count())), }); const VideoSuggestion0 = await VideoSuggestions.findOne({ order: [['id', 'ASC']], offset: 0 }); if (VideoSuggestion0?.setRelated_video) { await VideoSuggestion0. setRelated_video(relatedRelated_video0); } const relatedRelated_video1 = await Videos.findOne({ offset: Math.floor(Math.random() * (await Videos.count())), }); const VideoSuggestion1 = await VideoSuggestions.findOne({ order: [['id', 'ASC']], offset: 1 }); if (VideoSuggestion1?.setRelated_video) { await VideoSuggestion1. setRelated_video(relatedRelated_video1); } const relatedRelated_video2 = await Videos.findOne({ offset: Math.floor(Math.random() * (await Videos.count())), }); const VideoSuggestion2 = await VideoSuggestions.findOne({ order: [['id', 'ASC']], offset: 2 }); if (VideoSuggestion2?.setRelated_video) { await VideoSuggestion2. setRelated_video(relatedRelated_video2); } const relatedRelated_video3 = await Videos.findOne({ offset: Math.floor(Math.random() * (await Videos.count())), }); const VideoSuggestion3 = await VideoSuggestions.findOne({ order: [['id', 'ASC']], offset: 3 }); if (VideoSuggestion3?.setRelated_video) { await VideoSuggestion3. setRelated_video(relatedRelated_video3); } } async function associateReportWithComment() { const relatedComment0 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const Report0 = await Reports.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Report0?.setComment) { await Report0. setComment(relatedComment0); } const relatedComment1 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const Report1 = await Reports.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Report1?.setComment) { await Report1. setComment(relatedComment1); } const relatedComment2 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const Report2 = await Reports.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Report2?.setComment) { await Report2. setComment(relatedComment2); } const relatedComment3 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const Report3 = await Reports.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Report3?.setComment) { await Report3. setComment(relatedComment3); } } async function associateReportWithReported_by() { const relatedReported_by0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Report0 = await Reports.findOne({ order: [['id', 'ASC']], offset: 0 }); if (Report0?.setReported_by) { await Report0. setReported_by(relatedReported_by0); } const relatedReported_by1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Report1 = await Reports.findOne({ order: [['id', 'ASC']], offset: 1 }); if (Report1?.setReported_by) { await Report1. setReported_by(relatedReported_by1); } const relatedReported_by2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Report2 = await Reports.findOne({ order: [['id', 'ASC']], offset: 2 }); if (Report2?.setReported_by) { await Report2. setReported_by(relatedReported_by2); } const relatedReported_by3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Report3 = await Reports.findOne({ order: [['id', 'ASC']], offset: 3 }); if (Report3?.setReported_by) { await Report3. setReported_by(relatedReported_by3); } } async function associateModerationActionWithPerformed_by() { const relatedPerformed_by0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ModerationAction0 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 0 }); if (ModerationAction0?.setPerformed_by) { await ModerationAction0. setPerformed_by(relatedPerformed_by0); } const relatedPerformed_by1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ModerationAction1 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 1 }); if (ModerationAction1?.setPerformed_by) { await ModerationAction1. setPerformed_by(relatedPerformed_by1); } const relatedPerformed_by2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ModerationAction2 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 2 }); if (ModerationAction2?.setPerformed_by) { await ModerationAction2. setPerformed_by(relatedPerformed_by2); } const relatedPerformed_by3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ModerationAction3 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 3 }); if (ModerationAction3?.setPerformed_by) { await ModerationAction3. setPerformed_by(relatedPerformed_by3); } } async function associateModerationActionWithTarget_user() { const relatedTarget_user0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ModerationAction0 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 0 }); if (ModerationAction0?.setTarget_user) { await ModerationAction0. setTarget_user(relatedTarget_user0); } const relatedTarget_user1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ModerationAction1 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 1 }); if (ModerationAction1?.setTarget_user) { await ModerationAction1. setTarget_user(relatedTarget_user1); } const relatedTarget_user2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ModerationAction2 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 2 }); if (ModerationAction2?.setTarget_user) { await ModerationAction2. setTarget_user(relatedTarget_user2); } const relatedTarget_user3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const ModerationAction3 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 3 }); if (ModerationAction3?.setTarget_user) { await ModerationAction3. setTarget_user(relatedTarget_user3); } } async function associateModerationActionWithTarget_comment() { const relatedTarget_comment0 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const ModerationAction0 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 0 }); if (ModerationAction0?.setTarget_comment) { await ModerationAction0. setTarget_comment(relatedTarget_comment0); } const relatedTarget_comment1 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const ModerationAction1 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 1 }); if (ModerationAction1?.setTarget_comment) { await ModerationAction1. setTarget_comment(relatedTarget_comment1); } const relatedTarget_comment2 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const ModerationAction2 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 2 }); if (ModerationAction2?.setTarget_comment) { await ModerationAction2. setTarget_comment(relatedTarget_comment2); } const relatedTarget_comment3 = await VideoComments.findOne({ offset: Math.floor(Math.random() * (await VideoComments.count())), }); const ModerationAction3 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 3 }); if (ModerationAction3?.setTarget_comment) { await ModerationAction3. setTarget_comment(relatedTarget_comment3); } } async function associateModerationActionWithTarget_suggestion() { const relatedTarget_suggestion0 = await VideoSuggestions.findOne({ offset: Math.floor(Math.random() * (await VideoSuggestions.count())), }); const ModerationAction0 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 0 }); if (ModerationAction0?.setTarget_suggestion) { await ModerationAction0. setTarget_suggestion(relatedTarget_suggestion0); } const relatedTarget_suggestion1 = await VideoSuggestions.findOne({ offset: Math.floor(Math.random() * (await VideoSuggestions.count())), }); const ModerationAction1 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 1 }); if (ModerationAction1?.setTarget_suggestion) { await ModerationAction1. setTarget_suggestion(relatedTarget_suggestion1); } const relatedTarget_suggestion2 = await VideoSuggestions.findOne({ offset: Math.floor(Math.random() * (await VideoSuggestions.count())), }); const ModerationAction2 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 2 }); if (ModerationAction2?.setTarget_suggestion) { await ModerationAction2. setTarget_suggestion(relatedTarget_suggestion2); } const relatedTarget_suggestion3 = await VideoSuggestions.findOne({ offset: Math.floor(Math.random() * (await VideoSuggestions.count())), }); const ModerationAction3 = await ModerationActions.findOne({ order: [['id', 'ASC']], offset: 3 }); if (ModerationAction3?.setTarget_suggestion) { await ModerationAction3. setTarget_suggestion(relatedTarget_suggestion3); } } module.exports = { up: async (queryInterface, Sequelize) => { await Channels.bulkCreate(ChannelsData); await Playlists.bulkCreate(PlaylistsData); await Tags.bulkCreate(TagsData); await Videos.bulkCreate(VideosData); await VideoComments.bulkCreate(VideoCommentsData); await CommentReactions.bulkCreate(CommentReactionsData); await VideoSuggestions.bulkCreate(VideoSuggestionsData); await Reports.bulkCreate(ReportsData); await ModerationActions.bulkCreate(ModerationActionsData); await Promise.all([ // Similar logic for "relation_many" await associatePlaylistWithChannel(), await associateVideoWithChannel(), await associateVideoWithPlaylist(), // Similar logic for "relation_many" await associateVideoCommentWithVideo(), await associateVideoCommentWithAuthor(), await associateVideoCommentWithParent_comment(), await associateCommentReactionWithComment(), await associateCommentReactionWithUser(), await associateVideoSuggestionWithSuggested_by(), await associateVideoSuggestionWithRelated_video(), await associateReportWithComment(), await associateReportWithReported_by(), await associateModerationActionWithPerformed_by(), await associateModerationActionWithTarget_user(), await associateModerationActionWithTarget_comment(), await associateModerationActionWithTarget_suggestion(), ]); }, down: async (queryInterface, Sequelize) => { await queryInterface.bulkDelete('channels', null, {}); await queryInterface.bulkDelete('playlists', null, {}); await queryInterface.bulkDelete('tags', null, {}); await queryInterface.bulkDelete('videos', null, {}); await queryInterface.bulkDelete('video_comments', null, {}); await queryInterface.bulkDelete('comment_reactions', null, {}); await queryInterface.bulkDelete('video_suggestions', null, {}); await queryInterface.bulkDelete('reports', null, {}); await queryInterface.bulkDelete('moderation_actions', null, {}); }, };