update sort status list

This commit is contained in:
JOSEPH LE 2024-07-01 16:24:41 +07:00
parent 4ec269cafb
commit 30d6645355
1 changed files with 15 additions and 1 deletions

View File

@ -193,11 +193,22 @@ class JiraController extends Controller
], 200);
}
private function customSort($a, $b, $order) {
$pos_a = array_search(strtolower($a), $order);
$pos_b = array_search(strtolower($b), $order);
if ($pos_a === false || $pos_b === false) {
return 0;
}
return $pos_a - $pos_b;
}
private function formatWorkLogsByUser($workLogs)
{
// Assuming each workLog has a 'user' field
$tasksByUser = [];
$predefinedOrder = ['closed', 'done', 'customer_test', 'testing', 'in progress', 'to do', 'backlog'];
foreach ($workLogs as $log) {
$user = $log['username'];
@ -223,6 +234,9 @@ class JiraController extends Controller
'time_spent' => $issue['fields']['timespent'],
'worklogs' => $filteredWorklogs,
];
uksort($tasksByUser[$user]["allStatus"], function($a, $b) use ($predefinedOrder) {
return $this->customSort($a, $b, $predefinedOrder);
});
}
}
return $tasksByUser;