same stuff?
This commit is contained in:
+15
-7
@@ -19,16 +19,15 @@ two-file version, the grouping is real.
|
|||||||
| `mutation_set_recovery_contact.go` (+ tests) | Recovery | — | `state.Recovery`, `state.UpdatedAt` |
|
| `mutation_set_recovery_contact.go` (+ tests) | Recovery | — | `state.Recovery`, `state.UpdatedAt` |
|
||||||
| `mutation_subscription_added.go` | Subscription | `state.Items` | `state.Subscriptions`, `state.UpdatedAt` |
|
| `mutation_subscription_added.go` | Subscription | `state.Items` | `state.Subscriptions`, `state.UpdatedAt` |
|
||||||
| `mutation_upsert_subscriptiondetails.go` | Subscription details | `state.Subscriptions` | `state.Subscriptions`, `state.UpdatedAt` |
|
| `mutation_upsert_subscriptiondetails.go` | Subscription details | `state.Subscriptions` | `state.Subscriptions`, `state.UpdatedAt` |
|
||||||
| `mutation_remove_line_item_marking.go` | Markings | `state.Items[idx].Markings` | `state.Items[idx].Markings`, `state.UpdatedAt` |
|
| `mutation_markings.go` (`mutation_line_item_marking.go` and `mutation_remove_line_item_marking.go` merged) | Markings apply/remove | `state.Items[idx].Markings` | `state.Items[idx].Markings`, `state.UpdatedAt` |
|
||||||
| `mutation_line_item_marking.go` | Markings apply | `state.Items[idx].Markings` | `state.Items[idx].Markings`, `state.UpdatedAt` |
|
|
||||||
|
|
||||||
## Delete-test quick check
|
## Delete-test quick check
|
||||||
|
|
||||||
For any proposed grouping (e.g. merge all `marking*` mutations into one
|
For any proposed grouping, ask: does deleting the merged file concentrate
|
||||||
file), ask: does deleting the merged file concentrate complexity, or just
|
complexity, or just move lines? For markings — yes, the shared logic
|
||||||
move lines? For markings — yes, the shared logic (cascade to pricing) makes
|
(cascade to pricing) makes the merge worthwhile, and the merge is now done
|
||||||
the merge worthwhile. For `voucher` vs `custom_fields` — no, those read
|
(see below). For `voucher` vs `custom_fields` — no, those read different
|
||||||
different state and have different error contracts; keep separate.
|
state and have different error contracts; keep separate.
|
||||||
|
|
||||||
### What is already merged
|
### What is already merged
|
||||||
|
|
||||||
@@ -60,6 +59,15 @@ If a future merge lands, follow the same pattern: read the actual source
|
|||||||
to verify the row's claimed state surface, and prune label-noise before
|
to verify the row's claimed state surface, and prune label-noise before
|
||||||
compressing two rows into one.
|
compressing two rows into one.
|
||||||
|
|
||||||
|
`pkg/cart/mutation_markings.go` (added 2025-07) — LineItemMarking and
|
||||||
|
RemoveLineItemMarking both touch `state.Items[idx].Markings` and share
|
||||||
|
the same item-lookup loop (find by ID, mutate `Marking` field). Merge
|
||||||
|
passed the delete-test: the shared write surface and identical error
|
||||||
|
contract ("item with ID %d not found") make the grouping real. No test
|
||||||
|
files existed for either mutation, so the test surface is unchanged.
|
||||||
|
Verified: `go build ./pkg/cart/...` and `go test -count=1 ./pkg/cart/...`
|
||||||
|
clean.
|
||||||
|
|
||||||
### NOT to merge next
|
### NOT to merge next
|
||||||
|
|
||||||
`mutation_change_quantity.go` looks like an obvious candidate for the next
|
`mutation_change_quantity.go` looks like an obvious candidate for the next
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package cart
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
messages "git.k6n.net/mats/go-cart-actor/proto/cart"
|
|
||||||
)
|
|
||||||
|
|
||||||
func LineItemMarking(grain *CartGrain, req *messages.LineItemMarking) error {
|
|
||||||
for i, item := range grain.Items {
|
|
||||||
if item.Id == req.Id {
|
|
||||||
grain.Items[i].Marking = &Marking{
|
|
||||||
Type: req.Type,
|
|
||||||
Text: req.Marking,
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fmt.Errorf("item with ID %d not found", req.Id)
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package cart
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
messages "git.k6n.net/mats/go-cart-actor/proto/cart"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LineItemMarking sets a marking on the line item with the given ID.
|
||||||
|
func LineItemMarking(grain *CartGrain, req *messages.LineItemMarking) error {
|
||||||
|
for i, item := range grain.Items {
|
||||||
|
if item.Id == req.Id {
|
||||||
|
grain.Items[i].Marking = &Marking{
|
||||||
|
Type: req.Type,
|
||||||
|
Text: req.Marking,
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Errorf("item with ID %d not found", req.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveLineItemMarking clears the marking on the line item with the given ID.
|
||||||
|
func RemoveLineItemMarking(grain *CartGrain, req *messages.RemoveLineItemMarking) error {
|
||||||
|
for i, item := range grain.Items {
|
||||||
|
if item.Id == req.Id {
|
||||||
|
grain.Items[i].Marking = nil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Errorf("item with ID %d not found", req.Id)
|
||||||
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package cart
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
messages "git.k6n.net/mats/go-cart-actor/proto/cart"
|
|
||||||
)
|
|
||||||
|
|
||||||
func RemoveLineItemMarking(grain *CartGrain, req *messages.RemoveLineItemMarking) error {
|
|
||||||
|
|
||||||
for i, item := range grain.Items {
|
|
||||||
if item.Id == req.Id {
|
|
||||||
grain.Items[i].Marking = nil
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fmt.Errorf("item with ID %d not found", req.Id)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user