test
This commit is contained in:
parent
cd2570bc07
commit
e174146678
|
|
@ -178,6 +178,27 @@ class JiraController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getWeeklyReport()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$startOfWeek = Carbon::now()->startOfWeek()->format('Y-m-d'); // Mặc định là Thứ Hai
|
||||||
|
$endOfWeek = Carbon::now()->endOfWeek()->format('Y-m-d'); // Mặc định là Chủ Nhật
|
||||||
|
// dd($startOfWeek);
|
||||||
|
$results = [];
|
||||||
|
$workLogs = $this->jiraService->getAllUserWorkLogs($startOfWeek, $endOfWeek);
|
||||||
|
foreach($workLogs as $data){
|
||||||
|
$results[$data['username']] = $data['information']['issues'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
$results
|
||||||
|
], 200);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return response()->json(['error' => $e->getMessage()], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function sendReport()
|
public function sendReport()
|
||||||
{
|
{
|
||||||
$dateFormatted = Carbon::yesterday()->setTimezone(env('TIME_ZONE'))->format('Y-m-d');
|
$dateFormatted = Carbon::yesterday()->setTimezone(env('TIME_ZONE'))->format('Y-m-d');
|
||||||
|
|
@ -186,7 +207,7 @@ class JiraController extends Controller
|
||||||
|
|
||||||
$tasksByUser = $this->formatWorkLogsByUser($workLogs);
|
$tasksByUser = $this->formatWorkLogsByUser($workLogs);
|
||||||
// Mail::to(['luanlt632000@gmail.com'])->send(new WorklogReport($tasksByUser));
|
// Mail::to(['luanlt632000@gmail.com'])->send(new WorklogReport($tasksByUser));
|
||||||
Mail::to(['luanlt632000@gmail.com', 'admin@apactech.io'])->send(new WorklogReport($tasksByUser));
|
Mail::to(['joseph@apactech.io', 'admin@apactech.io'])->send(new WorklogReport($tasksByUser));
|
||||||
|
|
||||||
// return "Email sent successfully!";
|
// return "Email sent successfully!";
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,8 @@ Route::middleware('api')
|
||||||
Route::get('/get-all-sprint-by-id-board', [JiraController::class, 'getAllSprintByIdBoard'])->middleware('check.permission:admin.tester');
|
Route::get('/get-all-sprint-by-id-board', [JiraController::class, 'getAllSprintByIdBoard'])->middleware('check.permission:admin.tester');
|
||||||
Route::get('/get-all-issue-by-id-sprint', [JiraController::class, 'getAllIssueByIdSprint']);
|
Route::get('/get-all-issue-by-id-sprint', [JiraController::class, 'getAllIssueByIdSprint']);
|
||||||
|
|
||||||
|
Route::get('/export-weekly-report', [JiraController::class, 'getWeeklyReport']);
|
||||||
|
|
||||||
Route::get('/all-issue-by-project', [JiraController::class, 'fetchIssuesByProject']);
|
Route::get('/all-issue-by-project', [JiraController::class, 'fetchIssuesByProject']);
|
||||||
Route::get('/worklogs', [JiraController::class, 'getAllUserWorkLogs'])->middleware('check.permission:admin.staff');
|
Route::get('/worklogs', [JiraController::class, 'getAllUserWorkLogs'])->middleware('check.permission:admin.staff');
|
||||||
Route::get('/allocation', [JiraController::class, 'getAllUserDoing'])->middleware('check.permission:admin.staff');
|
Route::get('/allocation', [JiraController::class, 'getAllUserDoing'])->middleware('check.permission:admin.staff');
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,9 @@ class JiraService
|
||||||
'Authorization' => $this->authHeader,
|
'Authorization' => $this->authHeader,
|
||||||
'Accept' => 'application/json',
|
'Accept' => 'application/json',
|
||||||
'Content-Type' => 'application/json'
|
'Content-Type' => 'application/json'
|
||||||
]
|
],
|
||||||
|
'timeout' => 60, // Tăng thời gian timeout lên 60 giây
|
||||||
|
'connect_timeout' => 30 // Tăng thời gian chờ kết nối lên 30 giây
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,7 +290,6 @@ class JiraService
|
||||||
$users_data[$user['displayName']]['total_spent'] = $users_data[$user['displayName']]['total_spent'] + $issue['fields']['timespent'];
|
$users_data[$user['displayName']]['total_spent'] = $users_data[$user['displayName']]['total_spent'] + $issue['fields']['timespent'];
|
||||||
$users_data[$user['displayName']]['total_est'] = $users_data[$user['displayName']]['total_est'] + ($issue['fields']['timeoriginalestimate'] ?? 0);
|
$users_data[$user['displayName']]['total_est'] = $users_data[$user['displayName']]['total_est'] + ($issue['fields']['timeoriginalestimate'] ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -325,4 +326,18 @@ class JiraService
|
||||||
$response = $this->client->get('/rest/agile/1.0/sprint/' . $id . '/issue');
|
$response = $this->client->get('/rest/agile/1.0/sprint/' . $id . '/issue');
|
||||||
return json_decode($response->getBody()->getContents(), true);
|
return json_decode($response->getBody()->getContents(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getWeeklyReport()
|
||||||
|
{
|
||||||
|
$body = [
|
||||||
|
'fields' => ['summary', 'status', 'timeoriginalestimate', 'timespent', 'assignee', 'project', 'worklog'],
|
||||||
|
'jql' => 'worklogDate >= startOfWeek() AND worklogDate < startOfWeek(1) order by created DESC',
|
||||||
|
'maxResults' => 1000
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->client->post('/rest/api/3/search', [
|
||||||
|
'body' => json_encode($body)
|
||||||
|
]);
|
||||||
|
return json_decode($response->getBody()->getContents(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue