2490 lines
52 KiB
JavaScript
2490 lines
52 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Teams = db.teams;
|
|
|
|
const TeamMembers = db.team_members;
|
|
|
|
const Projects = db.projects;
|
|
|
|
const Tasks = db.tasks;
|
|
|
|
const Comments = db.comments;
|
|
|
|
const Attachments = db.attachments;
|
|
|
|
const Notifications = db.notifications;
|
|
|
|
const Reports = db.reports;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const TeamsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Core Team",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Cross functional core team handling product strategy and delivery",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visibility": "Private",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"members_count": 5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Mobile Team",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Mobile engineers building native apps",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visibility": "Public",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"members_count": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Design Team",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Designers focused on UX and UI",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visibility": "Public",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"members_count": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const TeamMembersData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"role": "Admin",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"joined_on": new Date('2025-06-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"display_label": "Alice Johnson - Core Team",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"role": "Member",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"joined_on": new Date('2025-06-15T10:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"display_label": "Bob Smith - Core Team",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"role": "Admin",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"joined_on": new Date('2025-05-20T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"display_label": "Carol Nguyen - Design Team",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ProjectsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Website Redesign",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Modernize the public website with updated branding and improved performance",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2025-09-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-02-28T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"budget": 25000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress": 45,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Mobile App V2",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Second major version of the mobile app with offline support",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2025-08-15T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-04-30T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Planned",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"budget": 40000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress": 10,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Design System",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Create a shared design system and component library",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2025-07-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2025-12-31T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"budget": 15000.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress": 60,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const TasksData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Landing Page Mockups",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Create high fidelity mockups for the new landing page",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Done",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "High",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_date": new Date('2026-01-15T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2025-12-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"estimated_hours": 40.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Implement Auth API",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Develop authentication endpoints and token management",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "ToDo",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "High",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_date": new Date('2026-02-01T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2025-11-20T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"estimated_hours": 80.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": true,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Mobile Offline Sync",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Design and implement offline data synchronization for mobile",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "Blocked",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "High",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_date": new Date('2026-03-15T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-01-10T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"estimated_hours": 120.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed": false,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const CommentsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Initial mockups uploaded for review",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-12-05T10:20:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Auth endpoints draft PR is ready for review",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-11-25T15:40:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Component library includes button and form primitives",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-10-12T09:30:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const AttachmentsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"caption": "Landing page mockups v1",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"uploaded_on": new Date('2025-12-05T10:25:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"caption": "Auth API specification",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"uploaded_on": new Date('2025-11-20T14:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"caption": "Component demo recording",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"uploaded_on": new Date('2025-10-15T11:10:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const NotificationsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message": "New review requested for Landing Page Mockups",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"read": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2025-12-05T10:30:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message": "Please review the Auth API draft",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"read": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2025-11-25T15:45:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message": "E2E tests are blocked in staging",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"read": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-01-03T08:05:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ReportsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Website Redesign Q4 Progress",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2026-01-01T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Progress update covering design and implementation milestones",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Mobile App V2 Roadmap",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-10-01T08:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Roadmap and major deliverables for mobile version two",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Design System Audit",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"created_on": new Date('2025-12-01T11:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Audit of current components and recommended improvements",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateTeamWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Team0 = await Teams.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Team0?.setOwner)
|
|
{
|
|
await
|
|
Team0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Team1 = await Teams.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Team1?.setOwner)
|
|
{
|
|
await
|
|
Team1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Team2 = await Teams.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Team2?.setOwner)
|
|
{
|
|
await
|
|
Team2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateTeamMemberWithTeam() {
|
|
|
|
const relatedTeam0 = await Teams.findOne({
|
|
offset: Math.floor(Math.random() * (await Teams.count())),
|
|
});
|
|
const TeamMember0 = await TeamMembers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (TeamMember0?.setTeam)
|
|
{
|
|
await
|
|
TeamMember0.
|
|
setTeam(relatedTeam0);
|
|
}
|
|
|
|
const relatedTeam1 = await Teams.findOne({
|
|
offset: Math.floor(Math.random() * (await Teams.count())),
|
|
});
|
|
const TeamMember1 = await TeamMembers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (TeamMember1?.setTeam)
|
|
{
|
|
await
|
|
TeamMember1.
|
|
setTeam(relatedTeam1);
|
|
}
|
|
|
|
const relatedTeam2 = await Teams.findOne({
|
|
offset: Math.floor(Math.random() * (await Teams.count())),
|
|
});
|
|
const TeamMember2 = await TeamMembers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (TeamMember2?.setTeam)
|
|
{
|
|
await
|
|
TeamMember2.
|
|
setTeam(relatedTeam2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateTeamMemberWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const TeamMember0 = await TeamMembers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (TeamMember0?.setUser)
|
|
{
|
|
await
|
|
TeamMember0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const TeamMember1 = await TeamMembers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (TeamMember1?.setUser)
|
|
{
|
|
await
|
|
TeamMember1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const TeamMember2 = await TeamMembers.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (TeamMember2?.setUser)
|
|
{
|
|
await
|
|
TeamMember2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateProjectWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Project0 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Project0?.setOwner)
|
|
{
|
|
await
|
|
Project0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Project1 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Project1?.setOwner)
|
|
{
|
|
await
|
|
Project1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Project2 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Project2?.setOwner)
|
|
{
|
|
await
|
|
Project2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateProjectWithTeam() {
|
|
|
|
const relatedTeam0 = await Teams.findOne({
|
|
offset: Math.floor(Math.random() * (await Teams.count())),
|
|
});
|
|
const Project0 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Project0?.setTeam)
|
|
{
|
|
await
|
|
Project0.
|
|
setTeam(relatedTeam0);
|
|
}
|
|
|
|
const relatedTeam1 = await Teams.findOne({
|
|
offset: Math.floor(Math.random() * (await Teams.count())),
|
|
});
|
|
const Project1 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Project1?.setTeam)
|
|
{
|
|
await
|
|
Project1.
|
|
setTeam(relatedTeam1);
|
|
}
|
|
|
|
const relatedTeam2 = await Teams.findOne({
|
|
offset: Math.floor(Math.random() * (await Teams.count())),
|
|
});
|
|
const Project2 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Project2?.setTeam)
|
|
{
|
|
await
|
|
Project2.
|
|
setTeam(relatedTeam2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateTaskWithAssignee() {
|
|
|
|
const relatedAssignee0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task0 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Task0?.setAssignee)
|
|
{
|
|
await
|
|
Task0.
|
|
setAssignee(relatedAssignee0);
|
|
}
|
|
|
|
const relatedAssignee1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task1 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Task1?.setAssignee)
|
|
{
|
|
await
|
|
Task1.
|
|
setAssignee(relatedAssignee1);
|
|
}
|
|
|
|
const relatedAssignee2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task2 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Task2?.setAssignee)
|
|
{
|
|
await
|
|
Task2.
|
|
setAssignee(relatedAssignee2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateTaskWithReporter() {
|
|
|
|
const relatedReporter0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task0 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Task0?.setReporter)
|
|
{
|
|
await
|
|
Task0.
|
|
setReporter(relatedReporter0);
|
|
}
|
|
|
|
const relatedReporter1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task1 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Task1?.setReporter)
|
|
{
|
|
await
|
|
Task1.
|
|
setReporter(relatedReporter1);
|
|
}
|
|
|
|
const relatedReporter2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task2 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Task2?.setReporter)
|
|
{
|
|
await
|
|
Task2.
|
|
setReporter(relatedReporter2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateTaskWithProject() {
|
|
|
|
const relatedProject0 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Task0 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Task0?.setProject)
|
|
{
|
|
await
|
|
Task0.
|
|
setProject(relatedProject0);
|
|
}
|
|
|
|
const relatedProject1 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Task1 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Task1?.setProject)
|
|
{
|
|
await
|
|
Task1.
|
|
setProject(relatedProject1);
|
|
}
|
|
|
|
const relatedProject2 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Task2 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Task2?.setProject)
|
|
{
|
|
await
|
|
Task2.
|
|
setProject(relatedProject2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateCommentWithTask() {
|
|
|
|
const relatedTask0 = await Tasks.findOne({
|
|
offset: Math.floor(Math.random() * (await Tasks.count())),
|
|
});
|
|
const Comment0 = await Comments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Comment0?.setTask)
|
|
{
|
|
await
|
|
Comment0.
|
|
setTask(relatedTask0);
|
|
}
|
|
|
|
const relatedTask1 = await Tasks.findOne({
|
|
offset: Math.floor(Math.random() * (await Tasks.count())),
|
|
});
|
|
const Comment1 = await Comments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Comment1?.setTask)
|
|
{
|
|
await
|
|
Comment1.
|
|
setTask(relatedTask1);
|
|
}
|
|
|
|
const relatedTask2 = await Tasks.findOne({
|
|
offset: Math.floor(Math.random() * (await Tasks.count())),
|
|
});
|
|
const Comment2 = await Comments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Comment2?.setTask)
|
|
{
|
|
await
|
|
Comment2.
|
|
setTask(relatedTask2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateCommentWithAuthor() {
|
|
|
|
const relatedAuthor0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Comment0 = await Comments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Comment0?.setAuthor)
|
|
{
|
|
await
|
|
Comment0.
|
|
setAuthor(relatedAuthor0);
|
|
}
|
|
|
|
const relatedAuthor1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Comment1 = await Comments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Comment1?.setAuthor)
|
|
{
|
|
await
|
|
Comment1.
|
|
setAuthor(relatedAuthor1);
|
|
}
|
|
|
|
const relatedAuthor2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Comment2 = await Comments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Comment2?.setAuthor)
|
|
{
|
|
await
|
|
Comment2.
|
|
setAuthor(relatedAuthor2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateAttachmentWithTask() {
|
|
|
|
const relatedTask0 = await Tasks.findOne({
|
|
offset: Math.floor(Math.random() * (await Tasks.count())),
|
|
});
|
|
const Attachment0 = await Attachments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Attachment0?.setTask)
|
|
{
|
|
await
|
|
Attachment0.
|
|
setTask(relatedTask0);
|
|
}
|
|
|
|
const relatedTask1 = await Tasks.findOne({
|
|
offset: Math.floor(Math.random() * (await Tasks.count())),
|
|
});
|
|
const Attachment1 = await Attachments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Attachment1?.setTask)
|
|
{
|
|
await
|
|
Attachment1.
|
|
setTask(relatedTask1);
|
|
}
|
|
|
|
const relatedTask2 = await Tasks.findOne({
|
|
offset: Math.floor(Math.random() * (await Tasks.count())),
|
|
});
|
|
const Attachment2 = await Attachments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Attachment2?.setTask)
|
|
{
|
|
await
|
|
Attachment2.
|
|
setTask(relatedTask2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateAttachmentWithUploaded_by() {
|
|
|
|
const relatedUploaded_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Attachment0 = await Attachments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Attachment0?.setUploaded_by)
|
|
{
|
|
await
|
|
Attachment0.
|
|
setUploaded_by(relatedUploaded_by0);
|
|
}
|
|
|
|
const relatedUploaded_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Attachment1 = await Attachments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Attachment1?.setUploaded_by)
|
|
{
|
|
await
|
|
Attachment1.
|
|
setUploaded_by(relatedUploaded_by1);
|
|
}
|
|
|
|
const relatedUploaded_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Attachment2 = await Attachments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Attachment2?.setUploaded_by)
|
|
{
|
|
await
|
|
Attachment2.
|
|
setUploaded_by(relatedUploaded_by2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateNotificationWithRecipient() {
|
|
|
|
const relatedRecipient0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Notification0 = await Notifications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Notification0?.setRecipient)
|
|
{
|
|
await
|
|
Notification0.
|
|
setRecipient(relatedRecipient0);
|
|
}
|
|
|
|
const relatedRecipient1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Notification1 = await Notifications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Notification1?.setRecipient)
|
|
{
|
|
await
|
|
Notification1.
|
|
setRecipient(relatedRecipient1);
|
|
}
|
|
|
|
const relatedRecipient2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Notification2 = await Notifications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Notification2?.setRecipient)
|
|
{
|
|
await
|
|
Notification2.
|
|
setRecipient(relatedRecipient2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateNotificationWithRelated_task() {
|
|
|
|
const relatedRelated_task0 = await Tasks.findOne({
|
|
offset: Math.floor(Math.random() * (await Tasks.count())),
|
|
});
|
|
const Notification0 = await Notifications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Notification0?.setRelated_task)
|
|
{
|
|
await
|
|
Notification0.
|
|
setRelated_task(relatedRelated_task0);
|
|
}
|
|
|
|
const relatedRelated_task1 = await Tasks.findOne({
|
|
offset: Math.floor(Math.random() * (await Tasks.count())),
|
|
});
|
|
const Notification1 = await Notifications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Notification1?.setRelated_task)
|
|
{
|
|
await
|
|
Notification1.
|
|
setRelated_task(relatedRelated_task1);
|
|
}
|
|
|
|
const relatedRelated_task2 = await Tasks.findOne({
|
|
offset: Math.floor(Math.random() * (await Tasks.count())),
|
|
});
|
|
const Notification2 = await Notifications.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Notification2?.setRelated_task)
|
|
{
|
|
await
|
|
Notification2.
|
|
setRelated_task(relatedRelated_task2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateReportWithProject() {
|
|
|
|
const relatedProject0 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Report0 = await Reports.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Report0?.setProject)
|
|
{
|
|
await
|
|
Report0.
|
|
setProject(relatedProject0);
|
|
}
|
|
|
|
const relatedProject1 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Report1 = await Reports.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Report1?.setProject)
|
|
{
|
|
await
|
|
Report1.
|
|
setProject(relatedProject1);
|
|
}
|
|
|
|
const relatedProject2 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const Report2 = await Reports.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Report2?.setProject)
|
|
{
|
|
await
|
|
Report2.
|
|
setProject(relatedProject2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateReportWithGenerated_by() {
|
|
|
|
const relatedGenerated_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Report0 = await Reports.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Report0?.setGenerated_by)
|
|
{
|
|
await
|
|
Report0.
|
|
setGenerated_by(relatedGenerated_by0);
|
|
}
|
|
|
|
const relatedGenerated_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Report1 = await Reports.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Report1?.setGenerated_by)
|
|
{
|
|
await
|
|
Report1.
|
|
setGenerated_by(relatedGenerated_by1);
|
|
}
|
|
|
|
const relatedGenerated_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Report2 = await Reports.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Report2?.setGenerated_by)
|
|
{
|
|
await
|
|
Report2.
|
|
setGenerated_by(relatedGenerated_by2);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Teams.bulkCreate(TeamsData);
|
|
|
|
|
|
|
|
|
|
await TeamMembers.bulkCreate(TeamMembersData);
|
|
|
|
|
|
|
|
|
|
await Projects.bulkCreate(ProjectsData);
|
|
|
|
|
|
|
|
|
|
await Tasks.bulkCreate(TasksData);
|
|
|
|
|
|
|
|
|
|
await Comments.bulkCreate(CommentsData);
|
|
|
|
|
|
|
|
|
|
await Attachments.bulkCreate(AttachmentsData);
|
|
|
|
|
|
|
|
|
|
await Notifications.bulkCreate(NotificationsData);
|
|
|
|
|
|
|
|
|
|
await Reports.bulkCreate(ReportsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateTeamWithOwner(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateTeamMemberWithTeam(),
|
|
|
|
|
|
|
|
|
|
await associateTeamMemberWithUser(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateProjectWithOwner(),
|
|
|
|
|
|
|
|
|
|
await associateProjectWithTeam(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateTaskWithAssignee(),
|
|
|
|
|
|
|
|
|
|
await associateTaskWithReporter(),
|
|
|
|
|
|
|
|
|
|
await associateTaskWithProject(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCommentWithTask(),
|
|
|
|
|
|
|
|
|
|
await associateCommentWithAuthor(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateAttachmentWithTask(),
|
|
|
|
|
|
|
|
|
|
await associateAttachmentWithUploaded_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateNotificationWithRecipient(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateNotificationWithRelated_task(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateReportWithProject(),
|
|
|
|
|
|
|
|
|
|
await associateReportWithGenerated_by(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('teams', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('team_members', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('projects', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('tasks', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('comments', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('attachments', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('notifications', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('reports', null, {});
|
|
|
|
|
|
},
|
|
}; |