Skip to content

feat: add bulk delete endpoint for offline network clients#399

Open
full-bars wants to merge 2 commits into
urnetwork:mainfrom
full-bars:feat/bulk-delete-offline-clients
Open

feat: add bulk delete endpoint for offline network clients#399
full-bars wants to merge 2 commits into
urnetwork:mainfrom
full-bars:feat/bulk-delete-offline-clients

Conversation

@full-bars
Copy link
Copy Markdown

This PR introduces a bulk deletion endpoint for network clients to resolve the performance bottleneck where the dashboard was forced to issue hundreds of sequential HTTP requests to clean up offline clients.

I added a new RemoveNetworkClients model function and a POST /network/remove-clients API handler. This processes the deletions efficiently in a single, atomic PostgreSQL ANY($1) update operation.

Network scoping (network_id = $2) is strictly enforced to prevent insecure direct object references, and I've included a unit test to verify the UUID array binding logic.

full-bars added 2 commits June 4, 2026 14:38
I added a `RemoveNetworkClients` model function and a `POST /network/remove-clients` API handler to support bulk deletion. This replaces the need for the client to issue hundreds of sequential HTTP requests by processing the deletions efficiently in a single PostgreSQL `ANY()` update operation.
@full-bars
Copy link
Copy Markdown
Author

Ready for review @xcolwell

@Ryanmello07
Copy link
Copy Markdown

To my understanding bulk delete couldn't be added due to how payouts were calculated.

However the issue that causes is user's dashboards being too large.

Possible compromise would be adding a bulk request delete endpoint which queues the server for items to be delete, it will immediately hide and remove access to the clients from the /clients endpoint (and others) for the user (to solve for the issue) while still keeping the copy for the server, however eventually will be fully deleted once the clients are fully dead and useless.

@full-bars
Copy link
Copy Markdown
Author

Great minds think alike! That is exactly how the new /network/remove-clients bulk endpoint was implemented in this PR.

Instead of performing a hard database deletion, the endpoint processes the batch via a fast:

UPDATE network_client
SET active = false
WHERE client_id = ANY($1);

Because the dashboard's /clients query strictly filters for active = true, the clients are immediately hidden from the user's UI (solving the dashboard bloat issue instantly). However, the row remains fully intact in the database, meaning payout calculations are completely unaffected.

Eventually, the existing RemoveDisconnectedNetworkClients background task will sweep through and hard-delete these active = false clients once they are fully expired and useless.

So this PR completely satisfies the payout constraints while giving users the bulk-delete UX they need.

@full-bars
Copy link
Copy Markdown
Author

...At least, to my understanding based on the research I did... I could be wrong, hence the request for review.

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.

2 participants