2485 lines
47 KiB
JavaScript
2485 lines
47 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Conversations = db.conversations;
|
|
|
|
const Messages = db.messages;
|
|
|
|
const Projects = db.projects;
|
|
|
|
const AppTemplates = db.app_templates;
|
|
|
|
const FeatureRequests = db.feature_requests;
|
|
|
|
const AuditEvents = db.audit_events;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const ConversationsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "App Preview Kickoff",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"channel": "mobile",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "open",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"started_at": new Date('2026-05-20T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_message_at": new Date('2026-05-20T10:12:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message_count": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"language": "zh-CN",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Template Setup Questions",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"channel": "mobile",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "archived",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"started_at": new Date('2026-05-21T16:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_message_at": new Date('2026-05-21T16:25:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message_count": 5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"language": "en",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "RBAC and Audit Logging",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"channel": "web",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "archived",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"started_at": new Date('2026-05-22T09:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_message_at": new Date('2026-05-22T09:50:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message_count": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"language": "en",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Seed Data Expectations",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"channel": "mobile",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "archived",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"started_at": new Date('2026-05-18T11:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"last_message_at": new Date('2026-05-18T11:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"message_count": 6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"language": "en",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const MessagesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sender_type": "assistant",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Conversation initiated",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-20T10:00:05Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content_format": "html",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_edited": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sender_type": "system",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "你是什么模型?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-20T10:01:10Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content_format": "html",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_edited": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sender_type": "system",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "I am AI Engineer. I can help you build a CRUD app with auth, roles, permissions, admin UI, and React plus Node templates.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-20T10:02:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content_format": "markdown",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_edited": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sender_type": "assistant",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Please confirm the default stack and design choices for a new project.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"sent_at": new Date('2026-05-21T16:02:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content_format": "plain_text",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"is_edited": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ProjectsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "App Preview Workspace",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Internal workspace to validate the default CRUD template, RBAC, and seed data generation.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "paused",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_at": new Date('2026-05-15T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_at": new Date('2026-06-15T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Onboarding Improvements",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Track improvements to welcome flow, login page illustration, and initial user experience.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_at": new Date('2026-06-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_at": new Date('2026-06-30T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Template Catalog Review",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Review supported frontend and backend templates and ensure metadata is complete.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "planning",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_at": new Date('2026-05-10T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_at": new Date('2026-05-28T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Security and Compliance",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Ensure audit logging, permission boundaries, and data retention policies align with internal standards.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_at": new Date('2026-04-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_at": new Date('2026-07-01T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const AppTemplatesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "React Node Starter",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"frontend_stack": "angular",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"backend_stack": "node",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_auth": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_admin_ui": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_rbac": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Default starter with CRUD scaffolding and basic RBAC.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "React API Only",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"frontend_stack": "vue",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"backend_stack": "nestjs",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_auth": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_admin_ui": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_rbac": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Headless setup focused on APIs and auth.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Angular Material Starter",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"frontend_stack": "angular",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"backend_stack": "nestjs",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_auth": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_admin_ui": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_rbac": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Angular frontend using Material design system.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"name": "Vue Node Starter",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"frontend_stack": "react",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"backend_stack": "node",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_auth": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_admin_ui": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"includes_rbac": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Vue starter with admin UI and roles permissions.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const FeatureRequestsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Add welcome website page",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Provide a simple public landing page with short description and sign in link.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "high",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "rejected",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"requested_at": new Date('2026-05-19T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"target_at": new Date('2026-06-10T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Kanban view for feature requests",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Enable Kanban board using status column with drag and drop updates.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "medium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "rejected",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"requested_at": new Date('2026-05-20T15:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"target_at": new Date('2026-05-30T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Export audit events to CSV",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Allow exporting filtered audit events for compliance reviews.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "medium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "new",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"requested_at": new Date('2026-05-22T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"target_at": new Date('2026-06-20T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Improve message editor",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"details": "Support Markdown preview and better formatting controls for multiline message content.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": "low",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "done",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"requested_at": new Date('2026-05-23T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"target_at": new Date('2026-06-05T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const AuditEventsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"action": "update",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_type": "messages",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_key": "taylor.chen@acmecorp.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-21T09:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "203.0.113.10",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "Chrome 124 on macOS",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "User login successful",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"action": "permission_change",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_type": "app_templates",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_key": "Add welcome website page",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-19T12:00:05Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "203.0.113.22",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "Chrome 124 on Windows",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Created feature request for landing page",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"action": "permission_change",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_type": "users",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_key": "Kanban view for feature requests",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-20T16:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "203.0.113.10",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "Chrome 124 on macOS",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Updated status to in progress",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"action": "update",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_type": "conversations",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"entity_key": "casey.nguyen@acmecorp.com",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"occurred_at": new Date('2026-05-18T08:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"ip_address": "203.0.113.55",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"user_agent": "Firefox 126 on macOS",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"summary": "Adjusted user role and permissions",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateConversationWithOwner() {
|
|
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Conversation0 = await Conversations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Conversation0?.setOwner)
|
|
{
|
|
await
|
|
Conversation0.
|
|
setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Conversation1 = await Conversations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Conversation1?.setOwner)
|
|
{
|
|
await
|
|
Conversation1.
|
|
setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Conversation2 = await Conversations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Conversation2?.setOwner)
|
|
{
|
|
await
|
|
Conversation2.
|
|
setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Conversation3 = await Conversations.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Conversation3?.setOwner)
|
|
{
|
|
await
|
|
Conversation3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateMessageWithConversation() {
|
|
|
|
const relatedConversation0 = await Conversations.findOne({
|
|
offset: Math.floor(Math.random() * (await Conversations.count())),
|
|
});
|
|
const Message0 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Message0?.setConversation)
|
|
{
|
|
await
|
|
Message0.
|
|
setConversation(relatedConversation0);
|
|
}
|
|
|
|
const relatedConversation1 = await Conversations.findOne({
|
|
offset: Math.floor(Math.random() * (await Conversations.count())),
|
|
});
|
|
const Message1 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Message1?.setConversation)
|
|
{
|
|
await
|
|
Message1.
|
|
setConversation(relatedConversation1);
|
|
}
|
|
|
|
const relatedConversation2 = await Conversations.findOne({
|
|
offset: Math.floor(Math.random() * (await Conversations.count())),
|
|
});
|
|
const Message2 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Message2?.setConversation)
|
|
{
|
|
await
|
|
Message2.
|
|
setConversation(relatedConversation2);
|
|
}
|
|
|
|
const relatedConversation3 = await Conversations.findOne({
|
|
offset: Math.floor(Math.random() * (await Conversations.count())),
|
|
});
|
|
const Message3 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Message3?.setConversation)
|
|
{
|
|
await
|
|
Message3.
|
|
setConversation(relatedConversation3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateMessageWithSender() {
|
|
|
|
const relatedSender0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Message0 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Message0?.setSender)
|
|
{
|
|
await
|
|
Message0.
|
|
setSender(relatedSender0);
|
|
}
|
|
|
|
const relatedSender1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Message1 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Message1?.setSender)
|
|
{
|
|
await
|
|
Message1.
|
|
setSender(relatedSender1);
|
|
}
|
|
|
|
const relatedSender2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Message2 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Message2?.setSender)
|
|
{
|
|
await
|
|
Message2.
|
|
setSender(relatedSender2);
|
|
}
|
|
|
|
const relatedSender3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Message3 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Message3?.setSender)
|
|
{
|
|
await
|
|
Message3.
|
|
setSender(relatedSender3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateMessageWithParent_message() {
|
|
|
|
const relatedParent_message0 = await Messages.findOne({
|
|
offset: Math.floor(Math.random() * (await Messages.count())),
|
|
});
|
|
const Message0 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Message0?.setParent_message)
|
|
{
|
|
await
|
|
Message0.
|
|
setParent_message(relatedParent_message0);
|
|
}
|
|
|
|
const relatedParent_message1 = await Messages.findOne({
|
|
offset: Math.floor(Math.random() * (await Messages.count())),
|
|
});
|
|
const Message1 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Message1?.setParent_message)
|
|
{
|
|
await
|
|
Message1.
|
|
setParent_message(relatedParent_message1);
|
|
}
|
|
|
|
const relatedParent_message2 = await Messages.findOne({
|
|
offset: Math.floor(Math.random() * (await Messages.count())),
|
|
});
|
|
const Message2 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Message2?.setParent_message)
|
|
{
|
|
await
|
|
Message2.
|
|
setParent_message(relatedParent_message2);
|
|
}
|
|
|
|
const relatedParent_message3 = await Messages.findOne({
|
|
offset: Math.floor(Math.random() * (await Messages.count())),
|
|
});
|
|
const Message3 = await Messages.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Message3?.setParent_message)
|
|
{
|
|
await
|
|
Message3.
|
|
setParent_message(relatedParent_message3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Project3 = await Projects.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Project3?.setOwner)
|
|
{
|
|
await
|
|
Project3.
|
|
setOwner(relatedOwner3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateFeatureRequestWithRequested_by() {
|
|
|
|
const relatedRequested_by0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeatureRequest0 = await FeatureRequests.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeatureRequest0?.setRequested_by)
|
|
{
|
|
await
|
|
FeatureRequest0.
|
|
setRequested_by(relatedRequested_by0);
|
|
}
|
|
|
|
const relatedRequested_by1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeatureRequest1 = await FeatureRequests.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeatureRequest1?.setRequested_by)
|
|
{
|
|
await
|
|
FeatureRequest1.
|
|
setRequested_by(relatedRequested_by1);
|
|
}
|
|
|
|
const relatedRequested_by2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeatureRequest2 = await FeatureRequests.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeatureRequest2?.setRequested_by)
|
|
{
|
|
await
|
|
FeatureRequest2.
|
|
setRequested_by(relatedRequested_by2);
|
|
}
|
|
|
|
const relatedRequested_by3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const FeatureRequest3 = await FeatureRequests.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeatureRequest3?.setRequested_by)
|
|
{
|
|
await
|
|
FeatureRequest3.
|
|
setRequested_by(relatedRequested_by3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateFeatureRequestWithProject() {
|
|
|
|
const relatedProject0 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const FeatureRequest0 = await FeatureRequests.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (FeatureRequest0?.setProject)
|
|
{
|
|
await
|
|
FeatureRequest0.
|
|
setProject(relatedProject0);
|
|
}
|
|
|
|
const relatedProject1 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const FeatureRequest1 = await FeatureRequests.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (FeatureRequest1?.setProject)
|
|
{
|
|
await
|
|
FeatureRequest1.
|
|
setProject(relatedProject1);
|
|
}
|
|
|
|
const relatedProject2 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const FeatureRequest2 = await FeatureRequests.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (FeatureRequest2?.setProject)
|
|
{
|
|
await
|
|
FeatureRequest2.
|
|
setProject(relatedProject2);
|
|
}
|
|
|
|
const relatedProject3 = await Projects.findOne({
|
|
offset: Math.floor(Math.random() * (await Projects.count())),
|
|
});
|
|
const FeatureRequest3 = await FeatureRequests.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (FeatureRequest3?.setProject)
|
|
{
|
|
await
|
|
FeatureRequest3.
|
|
setProject(relatedProject3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateAuditEventWithActor() {
|
|
|
|
const relatedActor0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditEvent0 = await AuditEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (AuditEvent0?.setActor)
|
|
{
|
|
await
|
|
AuditEvent0.
|
|
setActor(relatedActor0);
|
|
}
|
|
|
|
const relatedActor1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditEvent1 = await AuditEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (AuditEvent1?.setActor)
|
|
{
|
|
await
|
|
AuditEvent1.
|
|
setActor(relatedActor1);
|
|
}
|
|
|
|
const relatedActor2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditEvent2 = await AuditEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (AuditEvent2?.setActor)
|
|
{
|
|
await
|
|
AuditEvent2.
|
|
setActor(relatedActor2);
|
|
}
|
|
|
|
const relatedActor3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const AuditEvent3 = await AuditEvents.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (AuditEvent3?.setActor)
|
|
{
|
|
await
|
|
AuditEvent3.
|
|
setActor(relatedActor3);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Conversations.bulkCreate(ConversationsData);
|
|
|
|
|
|
|
|
|
|
await Messages.bulkCreate(MessagesData);
|
|
|
|
|
|
|
|
|
|
await Projects.bulkCreate(ProjectsData);
|
|
|
|
|
|
|
|
|
|
await AppTemplates.bulkCreate(AppTemplatesData);
|
|
|
|
|
|
|
|
|
|
await FeatureRequests.bulkCreate(FeatureRequestsData);
|
|
|
|
|
|
|
|
|
|
await AuditEvents.bulkCreate(AuditEventsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateConversationWithOwner(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateMessageWithConversation(),
|
|
|
|
|
|
|
|
|
|
await associateMessageWithSender(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateMessageWithParent_message(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateProjectWithOwner(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateFeatureRequestWithRequested_by(),
|
|
|
|
|
|
|
|
|
|
await associateFeatureRequestWithProject(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateAuditEventWithActor(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('conversations', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('messages', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('projects', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('app_templates', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('feature_requests', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('audit_events', null, {});
|
|
|
|
|
|
},
|
|
}; |