Save to database #13

Merged
haylan merged 42 commits from save-to-database into main 2026-07-12 21:51:57 +00:00
Showing only changes of commit f52a3449c6 - Show all commits
+8 -6
View File
@@ -6,17 +6,19 @@ Order matters — later steps assume earlier ones are done.
## 1. Audit cleanup
- [ ] **Remove `eightpoints/guzzle-bundle` + `idci/graphql-client-bundle`.**
- [x] **Remove `eightpoints/guzzle-bundle` + `idci/graphql-client-bundle`.**
They exist only to build one near-static GitHub GraphQL query string
(`GitHubProvider.php:59-74`); the bundle's own HTTP transport is already
bypassed (comment at `GitHubProvider.php:76-77`). Replace
bypassed (comment at `GitHubProvider.php:76-77`).
- [ ] Replace
`$graphqlClient->buildQuery(...)->getGraphQLQuery()` with a plain
`sprintf`/heredoc query string. Delete the two packages from
`composer.json`, `config/bundles.php`, and delete
`config/packages/eight_points_guzzle.yaml` +
`config/packages/idci_graphql_client.yaml`. Run `composer update` and
commit the regenerated `composer.lock`.
- [ ] **Dedupe `baseUrl` normalization.** `GitLabProvider.php` (lines 41,
- [x] **Dedupe `baseUrl` normalization.** `GitLabProvider.php` (lines 41,
53) and `GiteaProvider.php` (lines 42, 54) each call
`rtrim($this->baseUrl..., '/')` twice — once in `ping()`, once in
`fetch()`. Compute it once as a `private readonly string $baseUrl` in
@@ -35,16 +37,16 @@ Order matters — later steps assume earlier ones are done.
## 3. `ContributionStore` (SQLite via native PDO)
- [ ] New `src/Service/ContributionStore.php`. PDO SQLite, DB file at
- [x] New `src/Service/ContributionStore.php`. PDO SQLite, DB file at
`%kernel.project_dir%/var/data/contributions.db` (configurable
constructor arg), table created lazily:
```sql
CREATE TABLE IF NOT EXISTS contributions (
provider TEXT NOT NULL,
date TEXT NOT NULL,
count INTEGER NOT NULL,
count INTEGER NOT NULL CHECK (count >= 0),
PRIMARY KEY (provider, date)
);
) WITHOUT ROWID, STRICT;
```
- [ ] `latestDate(string $provider): ?string` — `SELECT MAX(date) WHERE provider = ?`.
- [ ] `merge(string $provider, array $dateCounts): void` — upsert via