-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '#2-add-getting-data-from-github-api' of https://github.…
…com/blumilksoftware/gha-analyzer into #51-getting-and-displaying-data-from-db
- Loading branch information
Showing
17 changed files
with
208 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Jobs; | ||
|
||
use App\DTO\OrganizationDTO; | ||
use App\Http\Integrations\GithubConnector; | ||
use App\Models\Organization; | ||
use App\Services\FetchRepositoriesService; | ||
use App\Services\FetchWorkflowJobsService; | ||
use App\Services\FetchWorkflowRunsService; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Support\Facades\Log; | ||
use Saloon\RateLimitPlugin\Helpers\ApiRateLimited; | ||
|
||
class FetchDataFromApi implements ShouldQueue | ||
{ | ||
use Dispatchable; | ||
use InteractsWithQueue; | ||
use Queueable; | ||
use SerializesModels; | ||
|
||
public function __construct( | ||
protected int $organizationId, | ||
protected GithubConnector $githubConnector, | ||
protected FetchRepositoriesService $fetchRepositoriesService, | ||
protected FetchWorkflowRunsService $fetchWorkflowRunsService, | ||
protected FetchWorkflowJobsService $fetchWorkflowJobsService, | ||
) {} | ||
|
||
public function handle(): void | ||
{ | ||
$organization = Organization::query()->where("id", $this->organizationId)->firstOrFail(); | ||
$organizationDto = new OrganizationDTO( | ||
$organization->name, | ||
$organization->github_id, | ||
$organization->avatar_url, | ||
); | ||
|
||
$repositories = collect(); | ||
$repositories = $this->fetchRepositoriesService->fetchRepositories($organizationDto); | ||
|
||
$workflowRuns = collect(); | ||
|
||
foreach ($repositories as $repositoryDto) { | ||
$workflowRuns = $workflowRuns->union($this->fetchWorkflowRunsService->fetchWorkflowRuns($repositoryDto)); | ||
} | ||
|
||
foreach ($workflowRuns as $workflowRunDto) { | ||
$this->fetchWorkflowJobsService->fetchWorkflowJobs($workflowRunDto); | ||
} | ||
} | ||
|
||
public function middleware(): array | ||
{ | ||
return [new ApiRateLimited()]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.