@@ -12,6 +12,8 @@ class FetchDataFromGitLabUserCountsCommand extends Command
1212
1313 public function handle ()
1414 {
15+ $ tile_data = [];
16+
1517 foreach (config ('dashboard.tiles.gitlab.specific_users ' ) as $ username ) {
1618 $ userResponse = Http::withHeaders ([
1719 'PRIVATE-TOKEN ' => config ('dashboard.tiles.gitlab.api_token ' ),
@@ -22,31 +24,33 @@ public function handle()
2224 if ($ userData ) {
2325 $ userProfile = [
2426 'avatar_url ' => $ userData ['avatar_url ' ] ?? null ,
25- 'name ' => $ userData ['name ' ] ?? $ username ,
27+ 'name ' => preg_filter ( ' /[^A-Z]/ ' , '' , $ userData ['name ' ]) ,
2628 'assigned_merge_requests ' => 0 ,
2729 'review_requested_merge_requests ' => 0 ,
2830 'todos ' => 0 ,
2931 ];
3032
3133 $ userCountResponse = Http::withHeaders ([
3234 'PRIVATE-TOKEN ' => config ('dashboard.tiles.gitlab.api_token ' ),
35+ 'Sudo ' => $ username
3336 ])->get (config ('dashboard.tiles.gitlab.api_url ' ) . "/api/v4/user_counts " );
3437
3538 if ($ userCountResponse ->successful ()) {
3639 $ userCountData = $ userCountResponse ->json ();
3740 $ userProfile ['assigned_merge_requests ' ] = $ userCountData ['assigned_merge_requests ' ] ?? 0 ;
3841 $ userProfile ['review_requested_merge_requests ' ] = $ userCountData ['review_requested_merge_requests ' ] ?? 0 ;
3942 $ userProfile ['todos ' ] = $ userCountData ['todos ' ] ?? 0 ;
43+
44+ $ tile_data [$ username ] = $ userProfile ;
4045 } else {
4146 $ this ->error ('Failed to fetch user count for: ' . $ username . '. Status: ' . $ userCountResponse ->status () . ', Body: ' . $ userCountResponse ->body ());
4247 }
43-
44- GitLabUserCountsStore::make ()->setData ([$ username => $ userProfile ]);
4548 }
4649 } else {
4750 $ this ->error ('Failed to fetch user data for: ' . $ username . '. Status: ' . $ userResponse ->status () . ', Body: ' . $ userResponse ->body ());
4851 }
4952 }
53+ GitLabUserCountsStore::make ()->setData ($ tile_data );
5054
5155 $ this ->info ('Data fetched successfully! ' );
5256 }
0 commit comments