Fix quest assignment and post-based claim flow#30
Merged
Conversation
926e33c to
76922b9
Compare
MelonChicken
approved these changes
Jun 9, 2026
MelonChicken
left a comment
Collaborator
There was a problem hiding this comment.
I think this is the possible way to conduct quests.
LGTM and The test also worked in my local machine
This was referenced Jun 10, 2026
Closed
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
Updates the quest flow so that quest claiming is based on a specific completed post.
Previously, the quest claim logic checked all posts from the current user. However, after discussion of handling submission of posts and quest completion check, changes to code were made to follow the flow as below.
POST /api/posts(For now when testing, have to send it manually.)POST /api/quests/:id/claim(For now when testing, have to send it manually.)post_idChanges
GET /api/quests/todayto return user quest data joined with quest template data.user_quest_id,status,completed_post_id, andcompleted_atto the today quests response.POST /api/quests/:id/claimto acceptpost_idin the request body.status = claimedcompleted_post_idcompleted_atAPI behavior
Get today’s quests
Example Response
[ { "user_quest_id": 9, "user_id": 5, "quest_id": 1, "assigned_date": "2026-06-09", "status": "assigned", "completed_post_id": null, "completed_at": null, "title": "Write about food", "description": "Write a memory post with the food tag.", "quest_type": "post_tag", "required_tag": "food", "required_word_count": 0, "required_image": 0, "reward_will": 10, "is_active": 1 } ]Claim quest
Example Request Body
{ "post_id": 8 }Example Response
{ "userQuest": { "user_quest_id": 9, "user_id": 5, "quest_id": 1, "assigned_date": "2026-06-09", "status": "claimed", "completed_post_id": 8, "completed_at": "2026-06-09", "title": "Write about food", "description": "Write a memory post with the food tag.", "quest_type": "post_tag", "required_tag": "food", "required_word_count": 0, "required_image": 0, "reward_will": 10, "is_active": 1 }, "user": { "user_id": 5, "nickname": "tester", "will_balance": 11 }, "reward_will": 10 }Testing
Start server with...
Then, use Postman for further testing.
Register/login to get JWT token, and always keep that JWT token in the authorization header.
Expected Output
1. Get today's quests.
200 OKuser_quest_id,status, and quest requirement fields.2. Create a matching post
201 CreatedRequest body
{ "user_id": 5, "title": "Food memory", "content": "Today I ate something nice and wrote a small memory about it.", "tag": "food", "visibility": "public", "image_url": null, "created_at": "2026-06-09T00:00:00.000Z", "updated_at": "2026-06-09T00:00:00.000Z" }3. Claim quest using created post id
201 Createdclaimedcompleted_post_idbecame thepost_id(given by user)reward_willRequest body
4. Try claiming the same quest again
409 Conflict5. Verify today's quest after claim
200 OKstatusandcompleted_post_idandcompleted_atExpected Frontend Behavior
Frontend follow this flow.
POST /api/postsGET /api/quests/today