Conversation
The env list/detail endpoints now return each environment's deployment count (EnvWithStats = Env + num_deployments), computed without loading the deployments: counts are grouped by cluster in the database and summed per environment (Deployment::count_by_env / count_in_env). To keep the count live, a new trigger emits a synthetic `envs` refresh event on the generic `db_notifications` channel whenever a deployment change affects a count -- INSERT, DELETE, or a move between clusters (status and config updates are ignored). The frontend, which already loads and subscribes to envs, refetches the affected env and shows the new count. Stacked on the generic-trigger env_id fix, whose env-tagged events and wildcard subscription matching are what let the synthetic envs event reach subscribers. Verified against PostgreSQL that the trigger emits only on count-affecting changes (and for both environments on a move), and that the OpenAPI schema exposes num_deployments on the env responses.
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.
Live per-environment deployment counts
The env list/detail endpoints now return each environment's deployment count, and it stays live — when a deployment is added/removed the count updates wherever an env is shown (switcher, overview, headers), matching Platz's reactive feel — without the frontend loading any deployments.
How
EnvWithStats = Env + num_deployments. The count is computed without loading deployments — grouped by cluster in the database and summed per environment (Deployment::count_by_envfor the list,count_in_envfor detail), scoped to the caller's environments.envstable, so a new trigger emits a syntheticenvsrefresh event on the genericdb_notificationschannel for the affected environment(s). The frontend — which already loads and subscribes toenvs— refetches that env and shows the new count. Frequent status/config updates are ignored, so the event only fires when a count actually changes.Dependency
Stacked on #112 (base branch). The synthetic
envsevent carries anenv_idand relies on #112's wildcard subscription matching to reach the globally-loadedenvscollection; the live behavior needs #112 merged first. Once #112 merges, I'll retarget this atmain.The frontend side (read
num_deployments, restore the live switcher counts) is in the frontend websocket-scalability PR.Testing
num_deploymentson the env responses (EnvWithStats=allOf [Env, { num_deployments }]), so the SDK picks it up on regen.cargo build/cargo fmt/cargo clippyclean.https://claude.ai/code/session_019WuF56UqDxdJkYmk4zXD88
Generated by Claude Code