Save to database #13
@@ -184,7 +184,7 @@ PHP `max_execution_time` fatal can't be caught by `try/catch` at all, so
|
||||
- [ ] `.env` — document `CONTRIBUTIONS_RETENTION_DAYS` (empty by default),
|
||||
same style as the existing `ALLOWED_HOSTS` comment.
|
||||
|
||||
## 9. `app:contributions:refetch` console command
|
||||
## 9. `graph:contributions:refetch` console command
|
||||
|
||||
Manual escape hatch for forcing a full or ranged re-fetch (e.g. after
|
||||
adding a new host, or if the store needs rebuilding) — bypasses step 5's
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use App\Kernel;
|
||||
use GitContributionGraph\Kernel;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
|
||||
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
|
||||
|
||||
+2
-2
@@ -16,12 +16,12 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "src/"
|
||||
"GitContributionGraph\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"App\\Tests\\": "tests/"
|
||||
"GitContributionGraph\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"require-dev": {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
controllers:
|
||||
resource:
|
||||
path: ../src/Controller/
|
||||
namespace: App\Controller
|
||||
namespace: GitContributionGraph\Controller
|
||||
type: attribute
|
||||
|
||||
@@ -16,32 +16,32 @@ services:
|
||||
autoconfigure: true
|
||||
public: false
|
||||
|
||||
App\:
|
||||
GitContributionGraph\:
|
||||
resource: "../src/"
|
||||
exclude:
|
||||
- "../src/Kernel.php"
|
||||
|
||||
_instanceof:
|
||||
App\Service\Provider\ProviderInterface:
|
||||
GitContributionGraph\Service\Provider\ProviderInterface:
|
||||
tags: ["app.provider"]
|
||||
|
||||
App\Service\Provider\GitHubProvider:
|
||||
GitContributionGraph\Service\Provider\GitHubProvider:
|
||||
arguments:
|
||||
$username: "%env(GITHUB_USER)%"
|
||||
$token: "%env(GITHUB_TOKEN)%"
|
||||
|
||||
App\Service\Provider\GitLabProvider:
|
||||
GitContributionGraph\Service\Provider\GitLabProvider:
|
||||
arguments:
|
||||
$username: "%env(GITLAB_USER)%"
|
||||
$token: "%env(GITLAB_TOKEN)%"
|
||||
$baseUrl: "%env(GITLAB_URL)%"
|
||||
|
||||
App\Service\Provider\GiteaProvider:
|
||||
GitContributionGraph\Service\Provider\GiteaProvider:
|
||||
arguments:
|
||||
$username: "%env(GITEA_USER)%"
|
||||
$token: "%env(GITEA_TOKEN)%"
|
||||
$baseUrl: "%env(GITEA_URL)%"
|
||||
App\Service\ContributionStore:
|
||||
GitContributionGraph\Service\ContributionStore:
|
||||
arguments:
|
||||
$dbPath: "%kernel.project_dir%/var/data/contributions.db"
|
||||
$retentionDays: "%env(int:CONTRIBUTIONS_RETENTION_DAYS)%"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Kernel;
|
||||
use GitContributionGraph\Kernel;
|
||||
|
||||
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Kernel;
|
||||
use GitContributionGraph\Kernel;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
require_once dirname(__DIR__).'/vendor/autoload.php';
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GitContributionGraph\Command;
|
||||
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Attribute\Option;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
|
||||
|
||||
#[AsCommand(name: 'graph:contributions:refetch')]
|
||||
class RefetchContributionsCommand extends Command
|
||||
{
|
||||
private SymfonyStyle $io;
|
||||
public function __construct(
|
||||
#[AutowireIterator('app.provider')]
|
||||
private readonly iterable $providers,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
public function initialize(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->io = new SymfonyStyle($input, $output);
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
//TODO: check if its possible to add the preview with real strings from the providers.
|
||||
#[Option("(repeatable/comma-split, restricts to named provider(s), default = all configured", "provider", "p", "")]
|
||||
string $providers = ""
|
||||
) {
|
||||
$requested = $providers === '' ? null : explode(',', $providers);
|
||||
$byName = [];
|
||||
|
||||
foreach ($this->providers as $provider) {
|
||||
$byName[$provider->getName()] = $provider;
|
||||
}
|
||||
|
||||
if ($requested !== null) {
|
||||
foreach ($requested as $name) {
|
||||
if (!isset($byName[$name])) {
|
||||
$this->io->error("Unknown provider: {$name}");
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
$byName = array_intersect_key($byName, array_flip($requested));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
namespace GitContributionGraph\Controller;
|
||||
|
||||
use App\Service\ContributionAggregator;
|
||||
use App\Service\Provider\ProviderHealthChecker;
|
||||
use App\Service\Renderer\SvgRenderer;
|
||||
use GitContributionGraph\Service\ContributionAggregator;
|
||||
use GitContributionGraph\Service\Provider\ProviderHealthChecker;
|
||||
use GitContributionGraph\Service\Renderer\SvgRenderer;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
namespace GitContributionGraph\Entity;
|
||||
|
||||
final class Contribution
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
namespace GitContributionGraph\Entity;
|
||||
|
||||
/**
|
||||
* @implements \IteratorAggregate<int, Contribution>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
namespace GitContributionGraph;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
||||
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
namespace GitContributionGraph\Service;
|
||||
|
||||
use App\Service\Provider\ProviderInterface;
|
||||
use GitContributionGraph\Service\Provider\ProviderInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
namespace GitContributionGraph\Service;
|
||||
|
||||
use App\Entity\Contribution;
|
||||
use App\Entity\ContributionCollection;
|
||||
use GitContributionGraph\Entity\Contribution;
|
||||
use GitContributionGraph\Entity\ContributionCollection;
|
||||
use PDO;
|
||||
|
||||
class ContributionStore
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Provider;
|
||||
namespace GitContributionGraph\Service\Provider;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Provider;
|
||||
namespace GitContributionGraph\Service\Provider;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Provider;
|
||||
namespace GitContributionGraph\Service\Provider;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Provider;
|
||||
namespace GitContributionGraph\Service\Provider;
|
||||
|
||||
use Symfony\Contracts\HttpClient\Exception\HttpExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Provider;
|
||||
namespace GitContributionGraph\Service\Provider;
|
||||
|
||||
enum ProviderErrorCode: string
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Provider;
|
||||
namespace GitContributionGraph\Service\Provider;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Provider;
|
||||
namespace GitContributionGraph\Service\Provider;
|
||||
|
||||
interface ProviderInterface
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Provider;
|
||||
namespace GitContributionGraph\Service\Provider;
|
||||
|
||||
final class ProviderStatus
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Provider;
|
||||
namespace GitContributionGraph\Service\Provider;
|
||||
|
||||
enum ProviderStatusType: string
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Renderer;
|
||||
namespace GitContributionGraph\Service\Renderer;
|
||||
|
||||
/**
|
||||
* Renders a GitHub-style contribution heatmap as an inline SVG.
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Entity;
|
||||
namespace GitContributionGraph\Tests\Unit\Entity;
|
||||
|
||||
use App\Entity\Contribution;
|
||||
use App\Entity\ContributionCollection;
|
||||
use GitContributionGraph\Entity\Contribution;
|
||||
use GitContributionGraph\Entity\ContributionCollection;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Entity;
|
||||
namespace GitContributionGraph\Tests\Unit\Entity;
|
||||
|
||||
use App\Entity\Contribution;
|
||||
use GitContributionGraph\Entity\Contribution;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Service;
|
||||
namespace GitContributionGraph\Tests\Unit\Service;
|
||||
|
||||
use App\Service\ContributionAggregator;
|
||||
use App\Service\Provider\ProviderInterface;
|
||||
use GitContributionGraph\Service\ContributionAggregator;
|
||||
use GitContributionGraph\Service\Provider\ProviderInterface;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Service;
|
||||
namespace GitContributionGraph\Tests\Unit\Service;
|
||||
|
||||
use App\Service\ContributionStore;
|
||||
use GitContributionGraph\Service\ContributionStore;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Service\Provider;
|
||||
namespace GitContributionGraph\Tests\Unit\Service\Provider;
|
||||
|
||||
use App\Service\Provider\GitHubProvider;
|
||||
use GitContributionGraph\Service\Provider\GitHubProvider;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Service\Provider;
|
||||
namespace GitContributionGraph\Tests\Unit\Service\Provider;
|
||||
|
||||
use App\Service\Provider\GitLabProvider;
|
||||
use GitContributionGraph\Service\Provider\GitLabProvider;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Service\Provider;
|
||||
namespace GitContributionGraph\Tests\Unit\Service\Provider;
|
||||
|
||||
use App\Service\Provider\GiteaProvider;
|
||||
use GitContributionGraph\Service\Provider\GiteaProvider;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Service\Provider;
|
||||
namespace GitContributionGraph\Tests\Unit\Service\Provider;
|
||||
|
||||
use App\Service\Provider\ProbeTrait;
|
||||
use App\Service\Provider\ProviderErrorCode;
|
||||
use App\Service\Provider\ProviderInterface;
|
||||
use App\Service\Provider\ProviderStatusType;
|
||||
use GitContributionGraph\Service\Provider\ProbeTrait;
|
||||
use GitContributionGraph\Service\Provider\ProviderErrorCode;
|
||||
use GitContributionGraph\Service\Provider\ProviderInterface;
|
||||
use GitContributionGraph\Service\Provider\ProviderStatusType;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Service\Provider;
|
||||
namespace GitContributionGraph\Tests\Unit\Service\Provider;
|
||||
|
||||
use App\Service\Provider\ProviderErrorCode;
|
||||
use App\Service\Provider\ProviderHealthChecker;
|
||||
use App\Service\Provider\ProviderInterface;
|
||||
use App\Service\Provider\ProviderStatus;
|
||||
use App\Service\Provider\ProviderStatusType;
|
||||
use GitContributionGraph\Service\Provider\ProviderErrorCode;
|
||||
use GitContributionGraph\Service\Provider\ProviderHealthChecker;
|
||||
use GitContributionGraph\Service\Provider\ProviderInterface;
|
||||
use GitContributionGraph\Service\Provider\ProviderStatus;
|
||||
use GitContributionGraph\Service\Provider\ProviderStatusType;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Service\Provider;
|
||||
namespace GitContributionGraph\Tests\Unit\Service\Provider;
|
||||
|
||||
use App\Service\Provider\ProviderErrorCode;
|
||||
use App\Service\Provider\ProviderStatus;
|
||||
use App\Service\Provider\ProviderStatusType;
|
||||
use GitContributionGraph\Service\Provider\ProviderErrorCode;
|
||||
use GitContributionGraph\Service\Provider\ProviderStatus;
|
||||
use GitContributionGraph\Service\Provider\ProviderStatusType;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Service\Renderer;
|
||||
namespace GitContributionGraph\Tests\Unit\Service\Renderer;
|
||||
|
||||
use App\Service\Renderer\SvgRenderer;
|
||||
use GitContributionGraph\Service\Renderer\SvgRenderer;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
|
||||
Reference in New Issue
Block a user