Skip to content

Feature/leaderboard pagination#369

Open
Truphile wants to merge 6 commits into
Bitcoindefi:mainfrom
Truphile:feature/leaderboard-pagination
Open

Feature/leaderboard pagination#369
Truphile wants to merge 6 commits into
Bitcoindefi:mainfrom
Truphile:feature/leaderboard-pagination

Conversation

@Truphile

Copy link
Copy Markdown

I have implemented the agent clustering logic and fully integrated it into
the system's SSE stream and frontend map according to your criteria.
Here is what was done:

  1. Clustering Algorithm: Created position-cluster.ts which provides the
    clusterPositions method using the Haversine formula to cluster agents
    within the given gridSizeKm (default: 5km).
  2. SSE Stream Updates: Created a new route.ts SSE endpoint which
    tracks the query parameter ?cluster=true&gridSize=5 . When clustering is
    toggled on, it emits a agent.positions.clustered.snapshot event initially
    and agent.positions.clustered full state events whenever any internal
    position change is detected by subscribeAgentPositionDeltas . When
    cluster=false , it behaves equivalently to the legacy individual delta
    stream.
  3. Map Component UI: Refactored the Map structure to support reading query
    parameters.
    • Added ?cluster=true query check using useSearchParams() inside
    AgentsMap.tsx.
    • In LeafletMap.tsx, when clustering is active, it conditionally
    renders custom blue circle markers featuring a numeric badge using L.
    divIcon displaying the exact cluster count .
  4. Unit Tests: Wrote tests covering the clustering logic at position-
    cluster.test.ts
    satisfying the "3 agents within 2km -> 1 cluster of 3" criteria.

closes #267

@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent position clustering: group nearby agents on the map to reduce SSE noise

1 participant