feat(orders): a fifth verdict, 'bad', between ok and never again
ci / lint-test (push) Successful in 47s
ci / lint-test (push) Successful in 47s
The jump from "OK" to "Never again" is too big and most disappointments live in the gap (user, 2026-07-28) — so a merely poor meal either flattered itself as OK or got blacklisted. Only 'never' raises the warning on a future order. A blacklist that fires for every mediocre delivery is one nobody reads, so 'bad' records the disappointment without triggering the alarm. Both set order_again = false — you would not choose either again — and that split between "would I order it" and "warn me about it" is the point of the extra level. Migration widens the CHECK; nothing is removed, so no existing row needs mapping.
This commit is contained in:
@@ -341,7 +341,8 @@ async function setRating(transactionId: number, participantId: number, rating: R
|
||||
SET rating = EXCLUDED.rating,
|
||||
order_again = EXCLUDED.order_again,
|
||||
updated_at = now()`,
|
||||
[transactionId, participantId, rating, rating !== "never"]
|
||||
// "bad" and "never" both mean no; only "never" warns on a future order.
|
||||
[transactionId, participantId, rating, rating !== "never" && rating !== "bad"]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,10 +155,12 @@ export async function PUT(
|
||||
)
|
||||
.map((v) => ({ item: v.item.trim(), verdict: v.verdict }));
|
||||
|
||||
// `order_again` is derived when the caller does not say. "never" is the only
|
||||
// rating that answers the question on its own; "ok" is not a refusal.
|
||||
// `order_again` is derived when the caller does not say. "bad" and "never"
|
||||
// both answer no — you would not choose either again — but only "never"
|
||||
// raises the warning on a future order, so the blacklist stays sharp.
|
||||
const orderAgain =
|
||||
body.order_again ?? (rating === null ? null : rating !== "never");
|
||||
body.order_again ??
|
||||
(rating === null ? null : rating !== "never" && rating !== "bad");
|
||||
|
||||
await queryRow(
|
||||
`INSERT INTO order_reviews (transaction_id, participant_id, rating, order_again, note, item_verdicts)
|
||||
|
||||
Reference in New Issue
Block a user