chore: slim Filament per-render queries and gate CI coverage via pcov#228
Merged
Conversation
Implements plans 005 and 006 from the advisory audit: - The instance list fired six separate COUNT queries per render for its tab badges; all badges now derive from one grouped status-count query, pinned by a new badge-correctness test with mixed-status fixtures. - Dashboard StatsOverview ran three uncached full-table COUNT(*) per render; the totals are now cached for 60 seconds. - The store-app infolist re-counted allocatedInstances although getEloquentQuery() already eager-counts it; reuse the withCount value. - CI loaded xdebug but never collected coverage — paying the slowdown for nothing. Switch to pcov and gate with --min=35: baseline measured at 37.15% lines (via a php:8.4-cli + pcov container run), floor set two points under per the maintainer decision. Ratchet upward deliberately; never lower silently.
dan2k3k4
force-pushed
the
chore/filament-slimming-ci-coverage
branch
from
July 17, 2026 15:33
21cdca5 to
2017ef2
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PR 3 of 6 executing the advisory plan set (
plans/, committed in #226). Implements plans 005 + 006.Changes
COUNT(*)per render → 1 grouped query; badges derived in PHP. NewInstanceListTabBadgesTestseeds mixed statuses and pins every badge number (incl. the in-progress bucket sum and the empty-table case).StatsOverview: 3 uncached full-table counts per dashboard render → cached 60s (staleness accepted by maintainer decision).withCountvaluegetEloquentQuery()already loads instead of re-counting.coverage: xdebug(loaded, never used — pure slowdown) →coverage: pcov.php artisan test --coverage --min=35. Baseline honestly measured at 37.15% lines via aphp:8.4-cli+ pcov container against this branch; floor = baseline−2 per the grilling decision. The commit/workflow comment documents the ratchet rule.Testing
php artisan test— 435 passed (2 new)./vendor/bin/phpstan analyse— no errors; Pint cleandocker run --rm -v $PWD:/app -w /app php:8.4-cli sh -c "pecl install pcov && docker-php-ext-enable pcov && php -d memory_limit=1G vendor/bin/phpunit --coverage-text"memory_limit=-1in CI, so the coverage collector's memory appetite is covered there.Greptile Summary
This PR implements two optimization plans: Filament query slimming (Plan 005) and gating CI coverage via pcov (Plan 006). It collapses 6 per-tab
COUNT(*)badge queries into a single grouped status query with PHP-side derivation, caches dashboard stat counts for 60 s, and reuses awithCountvalue in the store-app infolist.getTabs()now issues oneGROUP BY statusquery and derives all five badge values in PHP, including a->unique()guard that restores the set semanticswhereInpreviously enforced for the duplicatedNEWstatus.StatsOverview::getStats()wraps all threecount()calls inCache::remember('admin-stats-overview', 60, …), accepting 60 s of staleness as explicitly signed off by the maintainer.--coverage --min=35to the test step, with baseline documented as 37.15%.Confidence Score: 5/5
Safe to merge — the optimisations are mechanical query reductions with no change to business logic, all previously flagged correctness issues have been addressed, and a new test pins the exact badge values including the deduplication case.
The badge consolidation is correct:
->unique()restores the set semantics thatwhereInused to enforce for the duplicatedNEWstatus, and the new test seeds aNEWinstance alongside aPENDING_DEPLOYinstance and assertsin_progress === 2, which would fail if the deduplication were absent. ThewithCount-based read in the store-app infolist is safe because Filament's view and edit record paths always resolve records throughgetEloquentQuery().No files require special attention.
Important Files Changed
->unique()correctly deduplicates NEW from the in-progress set; all edge cases now covered by the new test.allocated_instances_countfrom thewithCountalready applied ingetEloquentQuery()instead of firing a separate relationship count; Filament's view/edit record path always goes throughgetEloquentQuery(), so the attribute is always populated.Sequence Diagram
%%{init: {'theme': 'neutral'}}%% sequenceDiagram participant Browser participant getTabs as getTabs() participant DB Note over Browser,DB: Before (6 COUNT queries per render) Browser->>getTabs: render tab list getTabs->>DB: "COUNT(*) WHERE status != REMOVED" getTabs->>DB: "COUNT(*) WHERE status IN (inProgress)" getTabs->>DB: "COUNT(*) WHERE status = RUNNING_HEALTHY_CLAIMED" getTabs->>DB: "COUNT(*) WHERE status = RUNNING_HEALTHY_UNCLAIMED" getTabs->>DB: "COUNT(*) WHERE status = REMOVED" getTabs->>DB: "COUNT(*) all" DB-->>getTabs: 6 results getTabs-->>Browser: tabs with badges Note over Browser,DB: After (1 grouped query + PHP derivation) Browser->>getTabs: render tab list getTabs->>DB: "SELECT status COUNT(*) GROUP BY status" DB-->>getTabs: one row per distinct status getTabs->>getTabs: "derive active = total minus removed" getTabs->>getTabs: derive in_progress via unique and sum getTabs-->>Browser: tabs with badges%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% sequenceDiagram participant Browser participant getTabs as getTabs() participant DB Note over Browser,DB: Before (6 COUNT queries per render) Browser->>getTabs: render tab list getTabs->>DB: "COUNT(*) WHERE status != REMOVED" getTabs->>DB: "COUNT(*) WHERE status IN (inProgress)" getTabs->>DB: "COUNT(*) WHERE status = RUNNING_HEALTHY_CLAIMED" getTabs->>DB: "COUNT(*) WHERE status = RUNNING_HEALTHY_UNCLAIMED" getTabs->>DB: "COUNT(*) WHERE status = REMOVED" getTabs->>DB: "COUNT(*) all" DB-->>getTabs: 6 results getTabs-->>Browser: tabs with badges Note over Browser,DB: After (1 grouped query + PHP derivation) Browser->>getTabs: render tab list getTabs->>DB: "SELECT status COUNT(*) GROUP BY status" DB-->>getTabs: one row per distinct status getTabs->>getTabs: "derive active = total minus removed" getTabs->>getTabs: derive in_progress via unique and sum getTabs-->>Browser: tabs with badgesComments Outside Diff (1)
app/Filament/Admin/Resources/PolydockAppInstanceResource/Pages/ListPolydockAppInstances.php, line 95-102 (link)NEWstatus double-counted in thein_progressbadge$inProgressStatusesprependsPolydockAppInstanceStatus::NEWexplicitly at line 96, but$stageCreateStatuses(spread at line 97) starts with the sameNEWconstant. That meansNEWappears twice in the collected slice. The oldwhereInscope was immune because SQL deduplicates values inside anIN (…)clause, but the new PHPsum()loop iterates every element, so any instance inNEWstatus is counted twice in the badge. The test seed doesn't exerciseNEW, so the test suite still passes despite the inflated count.Reviews (2): Last reviewed commit: "chore: slim Filament per-render queries ..." | Re-trigger Greptile