Skip to content

fix: bump costco-go to v0.3.10 (word-overlap discount matching)#24

Merged
eshaffer321 merged 1 commit into
mainfrom
fix/costco-go-v0.3.10
May 31, 2026
Merged

fix: bump costco-go to v0.3.10 (word-overlap discount matching)#24
eshaffer321 merged 1 commit into
mainfrom
fix/costco-go-v0.3.10

Conversation

@eshaffer321
Copy link
Copy Markdown
Owner

Changes

Bumps costco-go from v0.3.9v0.3.10.

Why

After merging #23 (which introduced NetDiscounts), the orphaned-discount warning was still firing on real receipt 21134301000462605131128:

[WARN] found orphaned discount with no matching parent item discount_item=379938 parent_item_ref=AAA BATTERY discount_amount=-2.5

A verbose debug dump of the raw receipt items revealed the actual data:

item_number=1627198  desc01="DURACELL AAA"   ← the actual product
item_number=379938   desc01="/AAA BATTERY"   ← the coupon

"DURACELL AAA" shares no substring with "AAA BATTERY", so neither the exact-description nor the substring fallbacks in v0.3.9 could match them.

Fix (in costco-go v0.3.10)

Added a 4th matching strategy — word-overlap scoring — that scores candidate items by how many significant words (≥3 chars) from the coupon reference appear in the item description, then picks the highest-scoring match. The shared token AAA (len=3) bridges "DURACELL AAA" and "AAA BATTERY".

Also tightened the v0.3.9 substring reverse-contains guard (len(desc) >= len(ref)/2) to prevent short item descriptions from vacuously matching long coupon tokens.

Checklist

  • Tests passing (go test ./... -race)
  • go.mod / go.sum updated

v0.3.10 adds a word-overlap fallback to NetDiscounts that resolves the
DURACELL AAA / AAA BATTERY case: the coupon's /AAA BATTERY token and
the product description 'DURACELL AAA' share no substring relationship,
but both contain the word 'AAA', which is now used to match them.

Also tightens the v0.3.9 substring reverse-contains guard so a short
item description can't vacuously match a long coupon reference.
@eshaffer321 eshaffer321 merged commit 2e6d90e into main May 31, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant