diff --git a/BACKEND/app/Helper/Cache/UserJiraCacheHelper.php b/BACKEND/app/Helper/Cache/UserJiraCacheHelper.php new file mode 100644 index 0000000..8727191 --- /dev/null +++ b/BACKEND/app/Helper/Cache/UserJiraCacheHelper.php @@ -0,0 +1,40 @@ +getUsersByEmails($user_db); + if ($users) { + Cache::put(self::$key, json_encode($users), (60 * CacheConstant::$expired) ); + $users = json_encode($users); + } else { + $users = null; + } + } + if ($users == null) { + $GLOBALS[self::$globals] = null; + + } else { + $GLOBALS[self::$globals] = json_decode($users); + } + return $GLOBALS[self::$globals]; + } + + public static function cleanCacheSetting(){ + Cache::forget(self::$key); + } +} diff --git a/BACKEND/app/Services/JiraService.php b/BACKEND/app/Services/JiraService.php index 9032c62..668b9f7 100644 --- a/BACKEND/app/Services/JiraService.php +++ b/BACKEND/app/Services/JiraService.php @@ -2,6 +2,7 @@ namespace App\Services; +use App\Helper\Cache\UserJiraCacheHelper; use App\Models\User; use GuzzleHttp\Client; use GuzzleHttp\Promise\Utils; @@ -225,14 +226,12 @@ class JiraService public function getAllUserDoing() { - $all_users = User::all(); - $users = $this->getUsersByEmails($all_users); - // $projects = $this->getAllProjects(); + $users = UserJiraCacheHelper::getCacheSetting(); $groupedIssues = []; $users_data = []; $user_warning = []; foreach ($users as $user) { - $user = $user[0]; + $user = (array)$user[0]; $users_data[$user['displayName']]['user'] = $user; $users_data[$user['displayName']]['total_spent'] = 0; $users_data[$user['displayName']]['total_est'] = 0; @@ -287,7 +286,6 @@ class JiraService return ['projects' => $groupedIssues, 'users' => $users_data, 'warningList' => $user_warning]; - // return $projects; } public function getDetailIssueByKey($issueKey)