A project management app derived from Mind-Vision-Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 line
7.6KB

  1. <?php
  2. declare(strict_types=1);
  3. use App\Repositories\ActivityRepository;
  4. use App\Repositories\ProjectRepository;
  5. use App\Repositories\TaskRepository;
  6. function seed_projects(int $projectTotal = 6, bool $resetExisting = false): void
  7. {
  8. $projectTotal = max(1, $projectTotal);
  9. migration_manager()->runPending();
  10. $database = database();
  11. if ($resetExisting) {
  12. $database->execute('DELETE FROM activity_log');
  13. $database->execute('DELETE FROM tasks');
  14. $database->execute('DELETE FROM project_members');
  15. $database->execute('DELETE FROM projects');
  16. }
  17. $projects = [
  18. [
  19. 'name' => 'Atlas Portfolio Rollout',
  20. 'client_name' => 'Atlas Financial',
  21. 'description' => 'A multi-quarter portfolio site refresh with content migration, editorial workflow, and KPI reporting.',
  22. 'status' => 'active',
  23. 'start_date' => '2026-02-10',
  24. 'due_date' => '2026-06-30',
  25. 'budget_cents' => 1450000,
  26. 'owner_name' => 'Maya Chen',
  27. 'color_token' => 'teal',
  28. 'members_text' => "Maya Chen\nJordan Ellis\nPriya Singh",
  29. 'tasks' => [
  30. ['title' => 'Finalize content inventory', 'description' => 'Audit all portfolio assets and map old URLs to the new structure.', 'status' => 'done', 'priority' => 'high', 'assignee' => 'Maya Chen', 'estimate_hours' => 12, 'due_date' => '2026-03-05'],
  31. ['title' => 'Build editorial review queue', 'description' => 'Create approvals and publish scheduling for content editors.', 'status' => 'in-progress', 'priority' => 'urgent', 'assignee' => 'Jordan Ellis', 'estimate_hours' => 28, 'due_date' => '2026-05-18'],
  32. ['title' => 'Launch executive dashboard', 'description' => 'Surface conversion, retention, and campaign metrics for leadership.', 'status' => 'review', 'priority' => 'high', 'assignee' => 'Priya Singh', 'estimate_hours' => 24, 'due_date' => '2026-05-22'],
  33. ['title' => 'Prepare stakeholder training', 'description' => 'Document the content workflow and publish timeline for the business team.', 'status' => 'backlog', 'priority' => 'normal', 'assignee' => 'Maya Chen', 'estimate_hours' => 10, 'due_date' => '2026-06-05'],
  34. ],
  35. ],
  36. [
  37. 'name' => 'Northstar Launch Pad',
  38. 'client_name' => 'Northstar Logistics',
  39. 'description' => 'A cross-department launch program covering operations, onboarding, and service readiness.',
  40. 'status' => 'at-risk',
  41. 'start_date' => '2026-03-01',
  42. 'due_date' => '2026-05-28',
  43. 'budget_cents' => 980000,
  44. 'owner_name' => 'Diego Flores',
  45. 'color_token' => 'amber',
  46. 'members_text' => "Diego Flores\nAvery Brooks\nNina Patel",
  47. 'tasks' => [
  48. ['title' => 'Resolve deployment blocker', 'description' => 'Investigate the shipping API timeout and document the fix.', 'status' => 'blocked', 'priority' => 'urgent', 'assignee' => 'Avery Brooks', 'estimate_hours' => 16, 'due_date' => '2026-05-10'],
  49. ['title' => 'Coordinate ops handoff', 'description' => 'Align training, support, and fulfillment teams before launch.', 'status' => 'in-progress', 'priority' => 'high', 'assignee' => 'Diego Flores', 'estimate_hours' => 18, 'due_date' => '2026-05-19'],
  50. ['title' => 'Validate onboarding scripts', 'description' => 'Check each script against the latest workflow and signoff notes.', 'status' => 'backlog', 'priority' => 'normal', 'assignee' => 'Nina Patel', 'estimate_hours' => 8, 'due_date' => '2026-05-21'],
  51. ],
  52. ],
  53. [
  54. 'name' => 'Studio Systems Upgrade',
  55. 'client_name' => 'Bluebird Studios',
  56. 'description' => 'An internal tooling rebuild that unifies scheduling, budgeting, and show reporting.',
  57. 'status' => 'planned',
  58. 'start_date' => '2026-04-15',
  59. 'due_date' => '2026-08-01',
  60. 'budget_cents' => 650000,
  61. 'owner_name' => 'Elena Rossi',
  62. 'color_token' => 'violet',
  63. 'members_text' => "Elena Rossi\nSam Walker",
  64. 'tasks' => [
  65. ['title' => 'Map legacy workflows', 'description' => 'Document existing scheduling and finance handoffs.', 'status' => 'backlog', 'priority' => 'normal', 'assignee' => 'Elena Rossi', 'estimate_hours' => 9, 'due_date' => '2026-05-30'],
  66. ['title' => 'Define reporting schema', 'description' => 'Outline the data that finance and production teams need.', 'status' => 'backlog', 'priority' => 'high', 'assignee' => 'Sam Walker', 'estimate_hours' => 14, 'due_date' => '2026-06-10'],
  67. ],
  68. ],
  69. [
  70. 'name' => 'Summit Care Portal',
  71. 'client_name' => 'Summit Health',
  72. 'description' => 'A patient-facing portal modernization with secure messaging and appointment flow improvements.',
  73. 'status' => 'paused',
  74. 'start_date' => '2026-01-12',
  75. 'due_date' => '2026-07-15',
  76. 'budget_cents' => 2100000,
  77. 'owner_name' => 'Ari Johnson',
  78. 'color_token' => 'blue',
  79. 'members_text' => "Ari Johnson\nTaylor Nguyen\nRita Gomez",
  80. 'tasks' => [
  81. ['title' => 'Stabilize auth workflow', 'description' => 'Review the sign-in edge cases before resuming development.', 'status' => 'done', 'priority' => 'high', 'assignee' => 'Ari Johnson', 'estimate_hours' => 20, 'due_date' => '2026-03-28'],
  82. ['title' => 'Resume design review', 'description' => 'Pick up the paused UX feedback from the accessibility team.', 'status' => 'blocked', 'priority' => 'normal', 'assignee' => 'Taylor Nguyen', 'estimate_hours' => 6, 'due_date' => '2026-06-01'],
  83. ],
  84. ],
  85. ];
  86. $projectRepo = new ProjectRepository($database);
  87. $taskRepo = new TaskRepository($database);
  88. $activityRepo = new ActivityRepository($database);
  89. foreach (array_slice($projects, 0, $projectTotal) as $project) {
  90. $projectId = $projectRepo->create([
  91. 'name' => $project['name'],
  92. 'code' => '',
  93. 'client_name' => $project['client_name'],
  94. 'description' => $project['description'],
  95. 'status' => $project['status'],
  96. 'start_date' => $project['start_date'],
  97. 'due_date' => $project['due_date'],
  98. 'budget_cents' => $project['budget_cents'],
  99. 'owner_name' => $project['owner_name'],
  100. 'color_token' => $project['color_token'],
  101. 'members' => array_map(
  102. static function (string $name, int $index): array {
  103. return [
  104. 'full_name' => $name,
  105. 'role' => $index === 0 ? 'Project Lead' : 'Contributor',
  106. 'allocation_percent' => $index === 0 ? 40 : 20,
  107. ];
  108. },
  109. preg_split('/[\r\n]+/', $project['members_text']) ?: [],
  110. array_keys(preg_split('/[\r\n]+/', $project['members_text']) ?: [])
  111. ),
  112. ]);
  113. foreach ($project['tasks'] as $task) {
  114. $taskId = $taskRepo->create($projectId, $task);
  115. $activityRepo->record(
  116. 'task_seeded',
  117. 'Seeded task ' . $task['title'],
  118. 'Sample project data loaded for the dashboard.',
  119. $projectId,
  120. $taskId
  121. );
  122. }
  123. }
  124. }
  125. if (PHP_SAPI === 'cli' && realpath($_SERVER['SCRIPT_FILENAME'] ?? '') === __FILE__) {
  126. $count = isset($argv[1]) ? max(1, (int) $argv[1]) : 6;
  127. seed_projects($count, in_array('--reset', $argv, true));
  128. }

Powered by TurnKey Linux.