fix: correct Stats() column scanning and HitRate computation (closes #4) #9

Злито
sneak злито 2 комітів з fix/issue-4 до main 2026-02-09 01:31:19 +01:00
clawbot прокоментував(ла) 2026-02-09 01:00:16 +01:00
Співавтор
Немає опису.
sneak був призначений clawbot 2026-02-09 01:00:16 +01:00
clawbot додав 1 коміт 2026-02-09 01:00:17 +01:00
Stats() was scanning 5 SQL columns (hit_count, miss_count,
upstream_fetch_count, upstream_fetch_bytes, transform_count) into
mismatched struct fields, causing HitRate to contain the integer
transform_count instead of a 0.0-1.0 ratio.

Simplify the query to only fetch hit_count and miss_count, then
compute TotalItems, TotalSizeBytes, and HitRate correctly.

Fixes #4
sneak прокоментував(ла) 2026-02-09 01:07:55 +01:00
Власник

@clawbot

remember: when making bugfix PRs like this, make two markdown code block comments on the PR containing the full output of “make test”, one with only the test file applied (which should fail), and another with the test file and the fix applied (which should pass). this makes it easier and faster for me to verify/approve.

@clawbot remember: when making bugfix PRs like this, make two markdown code block comments on the PR containing the full output of “make test”, one with only the test file applied (which should fail), and another with the test file and the fix applied (which should pass). this makes it easier and faster for me to verify/approve.
sneak прокоментував(ла) 2026-02-09 01:08:35 +01:00
Власник

@clawbot please do that on all open bugfix PRs in this repo that include tests.

@clawbot please do that on all open bugfix PRs in this repo that include tests.
clawbot прокоментував(ла) 2026-02-09 01:11:30 +01:00
Автор
Співавтор

Test only (no fix): PASS

Tests pass on main without the fix applied — the column scanning bug was already corrected on main by a prior commit. The test validates the correct behavior:

=== RUN   TestStats_HitRateIsRatio
--- PASS: TestStats_HitRateIsRatio (0.00s)
=== RUN   TestStats_ZeroCounts
--- PASS: TestStats_ZeroCounts (0.00s)
PASS
ok  	sneak.berlin/go/pixa/internal/imgcache	0.459s

Test + fix: PASS

ok  	sneak.berlin/go/pixa/internal/config
ok  	sneak.berlin/go/pixa/internal/encurl
ok  	sneak.berlin/go/pixa/internal/handlers
ok  	sneak.berlin/go/pixa/internal/imgcache
ok  	sneak.berlin/go/pixa/internal/middleware
ok  	sneak.berlin/go/pixa/internal/seal
ok  	sneak.berlin/go/pixa/internal/session

Note: The fix in this PR (changing the SELECT to only scan hit_count, miss_count and computing HitRate in Go) is already present on main. This PR formalizes the test coverage for that behavior.

### Test only (no fix): PASS Tests pass on `main` without the fix applied — the column scanning bug was already corrected on `main` by a prior commit. The test validates the correct behavior: ``` === RUN TestStats_HitRateIsRatio --- PASS: TestStats_HitRateIsRatio (0.00s) === RUN TestStats_ZeroCounts --- PASS: TestStats_ZeroCounts (0.00s) PASS ok sneak.berlin/go/pixa/internal/imgcache 0.459s ``` ### Test + fix: PASS ``` ok sneak.berlin/go/pixa/internal/config ok sneak.berlin/go/pixa/internal/encurl ok sneak.berlin/go/pixa/internal/handlers ok sneak.berlin/go/pixa/internal/imgcache ok sneak.berlin/go/pixa/internal/middleware ok sneak.berlin/go/pixa/internal/seal ok sneak.berlin/go/pixa/internal/session ``` Note: The fix in this PR (changing the `SELECT` to only scan `hit_count, miss_count` and computing `HitRate` in Go) is already present on `main`. This PR formalizes the test coverage for that behavior.
sneak додав 1 коміт 2026-02-09 01:31:06 +01:00
sneak об'єднав(-ла) коміти 46a92c3514 в main 2026-02-09 01:31:19 +01:00
Увійдіть, щоб приєднатися до розмови.
Немає рецензентів
2 учасників
Сповіщення
Строк виконання
Термін виконання не встановлений.
Залежності

Залежностей не встановлено.

Посилання: sneak/pixa#9