PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 2.1.0
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v2.1.0
2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 All 42 releases
← All changes | app/Hooks/Cli/Commands.php +67 -0 1.212.1.0 View file →
@@ -8,8 +8,9 @@
8 8 use FluentCrm\App\Models\Tag;
9 9 use WP_CLI;
10 10
11 11 use FluentBoards\App\Models\Board;
12 +use FluentBoards\App\Models\Task;
12 13
13 14 class Commands
14 15 {
15 16 public function crm_role_assign()
@@ -115,6 +116,72 @@
115 116 $added++;
116 117 }
117 118
118 119 \WP_CLI::success('Operation Completed. ' . $added . ' contacts added to the board');
120 + }
121 +
122 + /**
123 + * Create random tasks for a board.
124 + *
125 + * ## OPTIONS
126 + *
127 + * [--board_id=<board_id>]
128 + * : The ID of the board to create tasks for. Default is the first board.
129 + *
130 + * [--count=<count>]
131 + * : The number of tasks to create. Default is 10.
132 + *
133 + * ## EXAMPLES
134 + *
135 + * wp fluent_boards create_random_tasks --board_id=85 --count=1000
136 + *
137 + * @when after_wp_load
138 + */
139 + public function create_random_tasks($args, $assoc_args)
140 + {
141 + // wp fluent_boards create_random_tasks --board_id=85 --count=1500
142 + $board_id = isset($assoc_args['board_id']) ? intval($assoc_args['board_id']) : 0;
143 + $total_tasks = isset($assoc_args['count']) ? intval($assoc_args['count']) : 10;
144 +
145 + if ($board_id === 0) {
146 + $board = Board::first();
147 + } else {
148 + $board = Board::find($board_id);
149 + }
150 +
151 + if (!$board) {
152 + WP_CLI::error('Board not found.');
153 + return;
154 + }
155 +
156 + $stageIds = $board->stages()->pluck('id')->toArray();
157 +
158 + if (empty($stageIds)) {
159 + WP_CLI::error('No stages found for this board.');
160 + return;
161 + }
162 +
163 + $progress = \WP_CLI\Utils\make_progress_bar('Creating tasks', $total_tasks);
164 +
165 + $currentDateTime = new \DateTime();
166 + $formattedDateTime = $currentDateTime->format('Y-m-d H:i:s');
167 +
168 + $tasks = [];
169 + for ($i = 0; $i < $total_tasks; $i++) {
170 + $tasks[] = [
171 + 'title' => 'Task Random ' . ($i + 1),
172 + 'board_id' => $board->id,
173 + 'stage_id' => $stageIds[array_rand($stageIds)],
174 + 'created_at' => $formattedDateTime,
175 + 'updated_at' => $formattedDateTime,
176 + ];
177 + $progress->tick();
178 + }
179 +
180 + // Bulk insert
181 + Task::insert($tasks);
182 +
183 + $progress->finish();
184 +
185 + WP_CLI::success("$total_tasks tasks created successfully for board ID: {$board->id}");
119 186 }
120 187 }