| @@ -80,8 +80,10 @@ | ||
| 80 | 80 | $boardIds = []; |
| 81 | 81 | if (is_array($rawBoardIds)) { |
| 82 | 82 | $boardIds = array_filter(array_map('intval', $rawBoardIds)); |
| 83 | 83 | } |
| 84 | + | |
| 85 | + $perPage = max(1, min(absint($request->getSafe('per_page', 'intval', 15)), 50)); | |
| 84 | 86 | |
| 85 | 87 | $requestData = [ |
| 86 | 88 | 'page' => $request->getSafe('page', 'intval', 1), |
| 87 | 89 | 'taskType' => $request->getSafe('taskType', 'sanitize_text_field'), |
| @@ -87,8 +89,9 @@ | ||
| 87 | 89 | 'taskType' => $request->getSafe('taskType', 'sanitize_text_field'), |
| 88 | 90 | 'boardIds' => $boardIds, |
| 89 | 91 | 'orderBy' => $request->getSafe('orderBy', 'sanitize_text_field'), |
| 90 | 92 | 'order' => $request->getSafe('order', 'sanitize_text_field'), |
| 93 | + 'per_page' => $perPage | |
| 91 | 94 | ]; |
| 92 | 95 | try { |
| 93 | 96 | return $this->sendSuccess( |
| 94 | 97 | $this->userService->getMemberAssociatedTasks($user_id, $requestData) |
| @@ -97,8 +100,28 @@ | ||
| 97 | 100 | return $this->sendError($e->getMessage(), 404); |
| 98 | 101 | } |
| 99 | 102 | } |
| 100 | 103 | |
| 104 | + /** | |
| 105 | + * Return profile task counts using the same categories shown on the dashboard. | |
| 106 | + */ | |
| 107 | + public function getMemberTaskCounts(Request $request, $user_id) | |
| 108 | + { | |
| 109 | + $user_id = absint($user_id); | |
| 110 | + $rawBoardIds = $request->getSafe('boardIds'); | |
| 111 | + $boardIds = is_array($rawBoardIds) | |
| 112 | + ? array_filter(array_map('intval', $rawBoardIds)) | |
| 113 | + : []; | |
| 114 | + | |
| 115 | + try { | |
| 116 | + return $this->sendSuccess([ | |
| 117 | + 'counts' => $this->userService->getMemberTaskCounts($user_id, $boardIds), | |
| 118 | + ], 200); | |
| 119 | + } catch (\Exception $e) { | |
| 120 | + return $this->sendError($e->getMessage(), 404); | |
| 121 | + } | |
| 122 | + } | |
| 123 | + | |
| 101 | 124 | public function getMemberRelatedAcitivies(Request $request, $user_id) |
| 102 | 125 | { |
| 103 | 126 | $user_id = absint($user_id); |
| 104 | 127 | $page = $request->getSafe('page', 'intval', 1); |
| @@ -153,8 +176,18 @@ | ||
| 153 | 176 | ], 200); |
| 154 | 177 | } catch (\Exception $e) { |
| 155 | 178 | return $this->sendError($e->getMessage(), 404); |
| 156 | 179 | } |
| 180 | + } | |
| 181 | + | |
| 182 | + public function getMemberStats($user_id) | |
| 183 | + { | |
| 184 | + $user_id = absint($user_id); | |
| 185 | + | |
| 186 | + return $this->sendSuccess( | |
| 187 | + $this->userService->getMemberStats($user_id), | |
| 188 | + 200 | |
| 189 | + ); | |
| 157 | 190 | } |
| 158 | 191 | |
| 159 | 192 | public function updateDisplayName(Request $request, $user_id) |
| 160 | 193 | { |