Skip to content

Add discount info to feed items - #75

Merged
lordlabakdas merged 1 commit into
masterfrom
feature/feed-discount-info
Aug 31, 2026
Merged

lordlabakdas merged 1 commit into
masterfrom
feature/feed-discount-info

Conversation

@lordlabakdas

@lordlabakdas lordlabakdas commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • FeedItemResponse gains discount_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-text message.
  • New models/service/store_feed_service.py::enrich_discount_info() batches the Coupon/Promotion/FlashSale lookups by ref_id (no N+1), wired into both GET /feed (shopper) and GET /stores/{id}/updates (store-owner history) so the response model is honestly populated everywhere it's used.
  • announcement/sponsored posts, and any post whose referenced row was deleted, just get None/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 passed
  • black/isort/ruff on touched files (pre-existing E712 pattern elsewhere untouched)

🤖 Generated with Claude Code

https://claude.ai/code/session_01DVPH3PqWcbNooDtAW5SAth

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
@lordlabakdas
lordlabakdas merged commit 103dbd0 into master Aug 31, 2026
6 checks passed
@lordlabakdas
lordlabakdas deleted the feature/feed-discount-info branch August 31, 2026 12:46
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