CouponHubBot: show /list visibility status in /added - #386
Merged
Conversation
Owners couldn't tell from /added whether an "available" coupon was currently shown in /list, still queued behind same-denomination coupons, or not yet valid. Adds CouponListStatus (BotHelpers.fs) that mirrors pickCouponsForList's selection logic exactly, plus a formatCouponListStatusSuffix renderer; wires both into handleAdded so its verdict always matches what /list actually shows. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NZuqUZZ4jkpgh6MFbQ6TVV
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.
Problem
Owners running
/addedcould see a coupon wasavailablebut had no way to tell whether it was actually being shown in/listright now, still waiting in a same-denomination queue, or not yet valid.pickCouponsForList(BotHelpers.fs) selects: all coupons expiring today (Dublin) + the 2 soonest-expiringmin_check=25coupons + 1 each ofmin_check40/50/100 + fill-to-6 — so anavailablecoupon can easily sit outside the current/listselection with zero visible signal.Change
Adds
CouponListStatus(BotHelpers.fs), computed from the same pool/listreads (db.GetAvailableCoupons()) and the samepickCouponsForListselection, so the verdict shown in/addedalways matches what/listactually displays.handleAdded(CommandHandler.fs) now fetches that pool/selection before rendering and replaces the old inlinetaken/reported-only suffix withcouponListStatus+formatCouponListStatusSuffix.Status taxonomy and example
/addedoutput lines:Shown(в списке)1. ID:42 — 10€ из 50€, 1 января, четверг (в списке)Taken(взят)2. ID:43 — 10€ из 50€, 5 января, понедельник (взят)Reported(отмечен использованным)3. ID:44 — 10€ из 50€, 10 января, суббота (отмечен использованным)NotYetValid vf(начнёт действовать с {date})4. ID:45 — 20€ из 100€, 20 февраля, пятница (начнёт действовать с 11 января, воскресенье)Waiting(ahead, mc)(в очереди: впереди {ahead} {купон/купона/купонов} из {mc}€, точно будет в списке в день истечения)5. ID:46 — 5€ из 25€, 30 января, пятница (в очереди: впереди 2 купона из 25€, точно будет в списке в день истечения)WaitingGeneric(incl.Waiting(0,_))(в очереди, точно будет в списке в день истечения)6. ID:47 — 5€ из 15€, 30 января, пятница (в очереди, точно будет в списке в день истечения)WaitingUnknown(defensive, should be unreachable)(в очереди)7. ID:48 — 10€ из 50€, 15 января, четверг (в очереди)"в день истечения" is honest, not aspirational:
GetVoidableCouponsByOwnerandGetAvailableCouponsfilter with the sametodayUtc()and differ only onvalid_from, andpickCouponsForList'sexpiringTodayrule unconditionally includes every valid, available coupon on its own Dublin expiry date — so every waiting coupon is guaranteed to appear in/listby the day it expires.No DB/migration changes —
valid_fromwas already onCoupon, both queries already existed.Test plan
dotnet build src/CouponHubBot— clean, 0 warnings/errorsdotnet test tests/CouponHubBot.Tests— 214/214 passed (208 pre-existing + 6 new), including existing/added//listtests unmodifiedAddedStatusTests.fs(6 tests): today→Shown, 3rd fiver→Waiting(ahead=2), futurevalid_from→NotYetValid, taken/reported regression, waiting-suffix day-of-expiry phrase, out-of-catalogmin_check→WaitingGeneric🤖 Generated with Claude Code
https://claude.ai/code/session_01NZuqUZZ4jkpgh6MFbQ6TVV