feat: add bulk delete endpoint for offline network clients#399
feat: add bulk delete endpoint for offline network clients#399full-bars wants to merge 2 commits into
Conversation
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.
|
Ready for review @xcolwell |
|
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. |
|
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 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. |
|
...At least, to my understanding based on the research I did... I could be wrong, hence the request for review. |
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
RemoveNetworkClientsmodel function and aPOST /network/remove-clientsAPI handler. This processes the deletions efficiently in a single, atomic PostgreSQLANY($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.