| @@ -62,10 +62,12 @@ | ||
| 62 | 62 | 'counts' => $taskCounts, |
| 63 | 63 | ]; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | + /** Return all board tasks with a cursor captured before reading their state. */ | |
| 66 | 67 | public function getTasksByBoard(Request $request, $board_id) |
| 67 | 68 | { |
| 69 | + $syncStartedAt = current_time('mysql'); | |
| 68 | 70 | $board_id = absint($board_id); |
| 69 | 71 | $board = Board::findOrFail($board_id); |
| 70 | 72 | $includeArchived = $request->getSafe('include_archived', 'boolval', false); |
| 71 | 73 | |
| @@ -93,13 +95,16 @@ | ||
| 93 | 95 | } |
| 94 | 96 | |
| 95 | 97 | return [ |
| 96 | 98 | 'tasks' => $tasks, |
| 99 | + 'synced_at' => $syncStartedAt, | |
| 97 | 100 | ]; |
| 98 | 101 | } |
| 99 | 102 | |
| 103 | + /** Fetch each stage's first page, then batch metadata for the combined card list. */ | |
| 100 | 104 | public function getTasksByBoardStage(Request $request, $board_id) |
| 101 | 105 | { |
| 106 | + $syncStartedAt = current_time('mysql'); | |
| 102 | 107 | $board_id = absint($board_id); |
| 103 | 108 | $board = Board::findOrFail($board_id); |
| 104 | 109 | $includeArchived = $request->getSafe('include_archived', 'boolval', false); |
| 105 | 110 | |
| @@ -117,15 +122,9 @@ | ||
| 117 | 122 | ->orderBy('position', 'ASC') |
| 118 | 123 | ->limit(20) |
| 119 | 124 | ->get(); |
| 120 | 125 | |
| 121 | - // Process each stage's tasks | |
| 122 | - $this->processTasks($stageTasks, $board, [ | |
| 123 | - 'includeContact' => false, | |
| 124 | - 'includeObserverState' => false, | |
| 125 | - 'includeRoadmapPopularity' => false, | |
| 126 | - ]); | |
| 127 | - $tasks = array_merge($tasks, $stageTasks->toArray()); // Merge with the main task list | |
| 126 | + $tasks = array_merge($tasks, $stageTasks->all()); | |
| 128 | 127 | |
| 129 | 128 | $startCursor = $stageTasks->count() ? (float) $stageTasks->first()->position : null; |
| 130 | 129 | $endCursor = $stageTasks->count() ? (float) $stageTasks->last()->position : null; |
| 131 | 130 | $loadedCount = $stageTasks->count(); |
| @@ -144,14 +143,22 @@ | ||
| 144 | 143 | 'end_cursor' => $endCursor, |
| 145 | 144 | ]; |
| 146 | 145 | } |
| 147 | 146 | |
| 147 | + $this->processTasks($tasks, $board, [ | |
| 148 | + 'includeContact' => false, | |
| 149 | + 'includeObserverState' => false, | |
| 150 | + 'includeRoadmapPopularity' => false, | |
| 151 | + ]); | |
| 152 | + | |
| 148 | 153 | return [ |
| 149 | - 'tasks' => $tasks, | |
| 154 | + 'tasks' => (new Task())->newCollection($tasks)->toArray(), | |
| 150 | 155 | 'pagination_by_stage' => $paginationByStage, |
| 156 | + 'synced_at' => $syncStartedAt, | |
| 151 | 157 | ]; |
| 152 | 158 | } |
| 153 | 159 | |
| 160 | + /** Return paginated tasks matching the board filters, including recurrence and templates. */ | |
| 154 | 161 | public function getTableTasks(Request $request, $board_id) |
| 155 | 162 | { |
| 156 | 163 | $board_id = absint($board_id); |
| 157 | 164 | $board = Board::findOrFail($board_id); |
| @@ -163,8 +170,10 @@ | ||
| 163 | 170 | 'search' => $request->getSafe('search', 'sanitize_text_field', ''), |
| 164 | 171 | 'include_archived' => $request->getSafe('include_archived', 'boolval', false), |
| 165 | 172 | 'stage' => $request->get('stage', []), |
| 166 | 173 | 'task_status' => $request->get('task_status', []), |
| 174 | + 'recurring' => $request->get('recurring', []), | |
| 175 | + 'template' => $request->get('template', []), | |
| 167 | 176 | 'priority' => $request->get('priority', []), |
| 168 | 177 | 'assignee' => $request->get('assignee', []), |
| 169 | 178 | 'labels' => $request->get('labels', []), |
| 170 | 179 | 'watchers' => $request->get('watchers', []), |
| @@ -191,8 +200,9 @@ | ||
| 191 | 200 | ], |
| 192 | 201 | ], 200); |
| 193 | 202 | } |
| 194 | 203 | |
| 204 | + /** Return board tasks matching the requested filters, including recurrence and templates. */ | |
| 195 | 205 | public function getFilteredBoardTasks(Request $request, $board_id) |
| 196 | 206 | { |
| 197 | 207 | $board_id = absint($board_id); |
| 198 | 208 | $board = Board::findOrFail($board_id); |
| @@ -200,8 +210,10 @@ | ||
| 200 | 210 | 'search' => $request->getSafe('search', 'sanitize_text_field', ''), |
| 201 | 211 | 'include_archived' => $request->getSafe('include_archived', 'boolval', false), |
| 202 | 212 | 'stage' => $request->get('stage', []), |
| 203 | 213 | 'task_status' => $request->get('task_status', []), |
| 214 | + 'recurring' => $request->get('recurring', []), | |
| 215 | + 'template' => $request->get('template', []), | |
| 204 | 216 | 'priority' => $request->get('priority', []), |
| 205 | 217 | 'assignee' => $request->get('assignee', []), |
| 206 | 218 | 'labels' => $request->get('labels', []), |
| 207 | 219 | 'watchers' => $request->get('watchers', []), |
| @@ -409,8 +421,10 @@ | ||
| 409 | 421 | * @param array $options |
| 410 | 422 | */ |
| 411 | 423 | private function processTasks($tasks, $board, $options = []) |
| 412 | 424 | { |
| 425 | + $this->taskService->loadTaskListMetadata($tasks); | |
| 426 | + | |
| 413 | 427 | $includeContact = Arr::get($options, 'includeContact', true); |
| 414 | 428 | $includeObserverState = Arr::get($options, 'includeObserverState', true); |
| 415 | 429 | $includeRoadmapPopularity = Arr::get($options, 'includeRoadmapPopularity', true); |
| 416 | 430 | $taskIds = []; |