Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions config/packages/github_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,45 @@ services:
class: Symfony\Component\HttpClient\Retry\GenericRetryStrategy
arguments:
- [0, 404, 423, 425, 429, 500, 502, 503, 504, 507, 510]


# Register different APIs as services

Github\Api\Issue:
factory: ['@Github\Client', api]
arguments: [issue]

Github\Api\Issue\Comments:
factory: ['@Github\Api\Issue', comments]
calls:
- ['setPerPage', [100]]

Github\Api\Issue\Labels:
factory: ['@Github\Api\Issue', labels]
calls:
- ['setPerPage', [100]]

Github\Api\Issue\Milestones:
factory: ['@Github\Api\Issue', milestones]

Github\Api\Issue\Timeline:
factory: ['@Github\Api\Issue', timeline]
calls:
- [configure]

Github\Api\PullRequest:
factory: ['@Github\Client', api]
arguments: [pullRequest]

Github\Api\PullRequest\Review:
factory: ['@Github\Api\PullRequest', reviews]

Github\Api\Repo:
factory: ['@Github\Client', api]
arguments: [repo]

Github\Api\Search:
factory: ['@Github\Client', api]
arguments: [search]
calls:
- ['setPerPage', [100]]
26 changes: 0 additions & 26 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,6 @@ services:
resource: '../src/Subscriber/*'
autoconfigure: false

Github\Api\Issue:
factory: ['@Github\Client', api]
arguments: [issue]

Github\Api\PullRequest:
factory: ['@Github\Client', api]
arguments: [pullRequest]

Github\Api\Repo:
factory: ['@Github\Client', api]
arguments: [repo]

Github\Api\Search:
factory: ['@Github\Client', api]
arguments: [search]

Github\Api\Issue\Labels:
factory: ['@Github\Api\Issue', labels]
calls:
- ['setPerPage', [100]]

Github\Api\Issue\Milestones:
factory: ['@Github\Api\Issue', milestones]

Github\Api\Issue\Comments:
factory: ['@Github\Api\Issue', comments]

App\Api\Issue\IssueApi: '@App\Api\Issue\GithubIssueApi'
App\Api\Label\LabelApi: '@App\Api\Label\GithubLabelApi'
Expand Down
2 changes: 1 addition & 1 deletion config/services_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ services:
App\Api\Issue\IssueApi: '@App\Api\Issue\NullIssueApi'
App\Api\Label\LabelApi: '@App\Api\Label\StaticLabelApi'
App\Api\Milestone\MilestoneApi: '@App\Api\Milestone\StaticMilestoneApi'
App\Api\PullRequest\PullRequestApi: '@App\Api\PullRequest\GithubPullRequestApi'
App\Api\PullRequest\PullRequestApi: '@App\Api\PullRequest\NullPullRequestApi'
App\Api\Status\StatusApi: '@App\Api\Status\NullStatusApi'
3 changes: 0 additions & 3 deletions src/Api/PullRequest/GithubPullRequestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
*/
class GithubPullRequestApi implements PullRequestApi
{
/**
* @var Repo
*/
private $github;
private $pullRequest;
private $search;
Expand Down
2 changes: 1 addition & 1 deletion src/Command/RunTaskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
try {
$this->taskRunner->run($task);
} catch (\Exception $e) {
$this->logger->error('Failed running task', ['excpetion' => $e]);
$this->logger->error('Failed running task', ['exception' => $e]);
$output->writeln($e->getMessage());
}
}
Expand Down
31 changes: 31 additions & 0 deletions src/Service/TaskScheduler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace App\Service;

use App\Entity\Task;
use App\Model\Repository;
use App\Repository\TaskRepository;

/**
* Schedule a job to run later.
*
* @author Tobias Nyholm <[email protected]>
*/
class TaskScheduler
{
private $taskRepo;

public function __construct(TaskRepository $taskRepo)
{
$this->taskRepo = $taskRepo;
}

public function runLater(Repository $repository, $number, int $action, \DateTimeImmutable $checkAt)
{
$task = new Task($repository->getFullName(), $number, $action, $checkAt);
$this->taskRepo->persist($task);
$this->taskRepo->flush();
}
}