Repository navigation
feat(prompts): retarget a selection of prompts in one go - #786
Merged
Merged
Conversation
Locations became editable per prompt in #783, one card at a time. A brand with 310 prompts needed 310 edits to start tracking Germany, which is the operation multi-location targeting exists for. The brand's prompt page gets a Locations dialog beside Analyze Prompts: pick add or remove, pick the locations, pick the prompts. It adds and removes rather than assigning a list, because a selection can hold prompts targeting different places and assigning one list to all of them would erase that targeting without saying so. Adding a location a prompt already has costs nothing, and a removal that would leave a prompt with no location at all skips it and says how many stayed — a prompt with no location cannot be tracked, and refusing the whole batch over one single-location prompt would be worse than reporting it. Cost is on screen before the click: how many prompts change, how many locations that adds, and where it lands against the plan. The dialog prices the change with planBulkLocationChange and the server action enforces it with the same function, so the preview and the guard cannot disagree. The cap is measured once for the batch and the write goes out as a single statement (apply_prompt_locations, 00074, applied). Looping the single-prompt action would check the cap per prompt and could stop half-way, leaving a partly-retargeted selection and a bill for whatever landed first. Current locations are re-read server-side: quota arithmetic must not rest on numbers the client sent.
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
#783 made a prompt's tracking locations editable — one card at a time. A brand with 310 prompts needed 310 edits to start tracking Germany, which is precisely the operation multi-location targeting exists for.
The brand's prompt page now has a Locations dialog beside Analyze Prompts (same select-from-a-list shape that dialog already uses): choose add or remove, choose the locations, choose the prompts.
Add/remove, not assign. A selection can hold prompts targeting different places, so assigning one list to all of them would erase that targeting silently. Adding a location a prompt already has costs nothing and writes nothing.
No prompt is left with zero locations. A removal that would empty a prompt skips it and reports how many stayed — a prompt with no location cannot be tracked at all, and refusing the whole batch because one prompt of forty is single-location would be worse than saying which ones held.
Cost is on screen before the click: how many prompts change, how many locations that adds, and where that lands against the plan cap. The dialog prices it with
planBulkLocationChangeand the server action enforces it with the same function, so the preview and the guard cannot disagree.The batch cannot land half-applied. The cap is measured once for the whole selection and the write goes out as one statement (
apply_prompt_locations, migration00074, already applied). Looping the single-prompt action would check the cap once per prompt and could stop part-way through — a partly-retargeted selection plus a bill for whatever landed before the limit bit. Current locations are re-read server-side rather than taken from the caller: the quota arithmetic must not rest on numbers the client supplied.Two smaller things fell out of it: the reads chunk their id lists at 100 (a few hundred UUIDs in a PostgREST query string overruns the request line long before the row cap matters), and
LocationPickergained optionallabel/countNoun/allowEmptyprops so the dialog can reuse it for choosing locations rather than holding a prompt's own.Related issue
Follow-up to #691 — the bulk editing gap left after #783.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd web && yarn test— 191 pass, including 9 new cases for the planner (append order, already-present no-op, the never-empty rule, batch pricing, case normalization).IS_CLOUDunset): no cap is shown or enforced.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)