Skip to content

fix(analytics): derive role breakdown from filtered node rows #560

Closed

Description

@dborup

Problem

Analytics → Nodes can display a filtered Network Status total next to an unfiltered Role Breakdown. The role totals therefore describe a different population when a region or area is selected.

Evidence in this fork

Code-level assessment of master ff1acc02255b5c6ab852e4cf931f85dbe3043ef9 on 24 October 2026; this is not a new browser reproduction or a claim about live counts.

  • public/analytics.js:2593–2598 loads nodes using both region and area filters.
  • public/analytics.js:2623–2624 reads the total from the response and the role breakdown from nodesResp.counts.
  • public/analytics.js:2657–2662 renders those role counts.
  • cmd/server/db.go:1218–1224 filters node membership by region, but :1264–1265 deliberately returns GetAllRoleCounts() as the separate count metadata.

The current issue and PR inventories were checked for equivalent work; no dedicated match was found. Recheck current master and competing work before implementation.

Requested change

Compute the Analytics Role Breakdown from the already loaded, filtered node rows so it represents the same population as that view's Network Status. Use a single bounded pass through those rows and preserve the existing role names and presentation.

Confirm that the loader has supplied the complete filtered population before labelling the breakdown complete. If an existing pagination/load cap prevents that, expose the limitation rather than quietly substituting a partial count for a full total.

Do not globally change /api/nodes count metadata: other consumers may rely on its existing global meaning. Do not add another API request, a request per node, or a backend/schema change to solve this display inconsistency. Preserve the fork's existing filtered pagination, identity visibility, request-generation guards and listener cleanup.

Acceptance and regression coverage

  • Use synthetic API data whose global counts intentionally disagrees with the returned filtered rows; assert the rendered role totals come from the rows.
  • Cover region-only, area-only and combined filters, the unfiltered view, empty results and all supported roles. A genuinely empty filtered result must render zero/empty consistently, not fall back to global counts.
  • Change filters while an earlier request is pending and confirm its late response cannot overwrite the current breakdown.
  • Assert the existing global API count contract is unchanged and the fix adds no network calls.
  • Exercise the real Analytics → Nodes flow in a local browser, including a filter change, rather than testing a copied implementation.
  • Show the focused regression red on unchanged code and green with the fix. Include the O(n) work and existing loaded-node bound in the eventual PR's performance explanation.

Source for comparison

Literal provenance only; adapt the proposal to our fork rather than copying upstream API assumptions.

Source repository: Kpa-clawbot/CoreScope
Issue number: 2213

Activity

  1. added a commit that references this issue on Oct 25, 2026
    31aa66a
  2. dborup commented on Oct 25, 2026

    @dborup
    OwnerAuthor

    Fixed by #580 (merged as bb91292a9df725986bbe301d41b4438312a32c84).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions