feat: Implement user promo feed endpoint (/api/user/feed)#43
Merged
RandomProgramm3r merged 2 commits intomainfrom May 9, 2025
Merged
feat: Implement user promo feed endpoint (/api/user/feed)#43RandomProgramm3r merged 2 commits intomainfrom
RandomProgramm3r merged 2 commits intomainfrom
Conversation
This commit introduces the `GET /api/user/feed` endpoint, enabling authenticated users to retrieve a personalized and paginated feed of promo.
Key features include:
- User-specific promo targeting based on their age and country attributes against promo targeting criteria (age_from, age_until, country).
- Dynamic calculation of a promo's 'active' status, considering:
- Validity period (`active_from`, `active_until`) relative to current date (UTC).
- Usage counts (`used_count` vs `max_count`) for 'COMMON' type promos.
- Availability of unactivated codes for 'UNIQUE' type promos.
- Filtering capabilities via query parameters:
- `active` (boolean): Filters promos based on their dynamic active status.
- `category` (string): Allows case-insensitive filtering by promo category.
- Standard limit/offset pagination, including an `X-Total-Count` header that reflects the total number of promos after all filters are applied.
- Serialized promo data provides essential information (e.g., ID, company details, description, image URL) while intentionally omitting the actual promo code values to prevent premature activation.
- Promos in the feed are sorted by their creation date (`created_at`) in descending order by default.
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.
This commit introduces the
GET /api/user/feedendpoint, enabling authenticated users to retrieve a personalized and paginated feed of promo.Key features include:
active_from,active_until) relative to current date (UTC).used_countvsmax_count) for 'COMMON' type promos.active(boolean): Filters promos based on their dynamic active status.category(string): Allows case-insensitive filtering by promo category.X-Total-Countheader that reflects the total number of promos after all filters are applied.created_at) in descending order by default.