Repository navigation
Add discount info to feed items - #75
Merged
Merged
Conversation
Coupon/promotion/flash-sale feed posts currently carry everything
baked into a free-text message string, which is awkward for the
frontend to redesign around. Add structured fields to FeedItemResponse
instead:
- discount_label: "20% off" / "$5 off" / "$7.5" depending on type
- coupon_code: the coupon code, when the post is a coupon
- expires_at: flash-sale end time, or promotion end-of-day, for a
countdown badge
Batched by type in models/service/store_feed_service.py's new
enrich_discount_info() rather than N+1 per post, and wired into both
GET /feed (shopper) and GET /stores/{id}/updates (store owner history)
so the response model stays honest everywhere it's used.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DVPH3PqWcbNooDtAW5SAth
2 of 3 tasks
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
FeedItemResponsegainsdiscount_label,coupon_code,expires_at(all optional) for coupon/promotion/flash-sale feed posts, so the frontend can render a discount chip and a flash-sale countdown instead of parsing the free-textmessage.models/service/store_feed_service.py::enrich_discount_info()batches the Coupon/Promotion/FlashSale lookups byref_id(no N+1), wired into bothGET /feed(shopper) andGET /stores/{id}/updates(store-owner history) so the response model is honestly populated everywhere it's used.announcement/sponsoredposts, and any post whose referenced row was deleted, just getNone/absent fields.Companion frontend PR (consumes these fields for a feed redesign): lordlabakdas/groceror-fe#53
Test plan
pytest tests/integration/test_store_feed.py -v— 21 passed (new coupon-discount-info test + assertions added to existing promotion/flash-sale/announcement tests)pytest tests/— full suite, 595 passedblack/isort/ruffon touched files (pre-existing E712 pattern elsewhere untouched)🤖 Generated with Claude Code
https://claude.ai/code/session_01DVPH3PqWcbNooDtAW5SAth