feat(farm): bulk remove plants by rarity#74
Open
kaajjaak wants to merge 1 commit into
Open
Conversation
Add a server-side `removeByRarity` action to the shared farm service so clearing all plants of a given rarity is one atomic call instead of N per-plot requests. A single CTE uproots every live, planted plot of the target rarity under FOR UPDATE and captures each plot's pre-clear gold_invested, so the 50% refund is summed from exactly the rows cleared (no read-then-write race, no refund drift); the clear, gold credit, and ledger row all commit together. Dead plants are excluded, matching the single-plot Remove (they must be Cleared). Wired into both transports (web NextAuth route and Anki bearer route) and exposed in the farm UI via a new RemoveByRarityPanel with per-rarity counts, estimated refund, and a two-step confirm.
|
@kaajjaak is attempting to deploy a commit to the Ari Horesh's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
Adds a one-click way to remove all live plants of a given rarity from the farm, instead of firing one request per plot.
Server
New
removeByRarity(userId, rarity)in the sharedlib/pet/farmService.ts, alongside the existingwaterAll/plantAll/harvestAll:FOR UPDATEand captures each plot's pre-cleargold_invested, so the 50% refund is summed from exactly the rows that were cleared — no read-then-write window, no refund drift if the farm is mutated concurrently.uprootPlot(those must be Cleared).PetServiceError(400)on bad input.Wired into both transports so they can't drift:
pages/api/pet/farm.ts(web / NextAuth)pages/api/anki/pet/farm.ts(Anki / bearer)via
action: "removeByRarity"with araritybody field.UI
New
components/pet/farm/RemoveByRarityPanel.tsx+ a "Remove by Rarity" toolbar button on/pet/farm(shown only when live plants exist):PixelButton/PixelBadge/GoldDisplayprimitives and thedangerink.Testing
tsc --noEmitpasses (0 errors).