Project

General

Profile

Actions

Feature (development) #14991

open

Feature - Claimable tasks

Added by Peter Mačuga 9 months ago. Updated 9 months ago.

Status:
Testing
Priority:
Normal
Target version:
-
Start date:
07/29/2024
Due date:
% Done:

100%

Estimated time:
custom category:
Backend
Co-assignee:
Sprint:
the LISTING (Feb 26 - Feb 29)

Description

The goal of this feature is to expand the functionality of task service to include claimable tasks - tasks which only award rewards after they are claimed. The claiming of the task is done in a seperate endpoint with the task_id and user_id as parameters.

Multiple claimable solution options:
1. Insert claimable into tags - maybe the best solution, dont know what it might break, tags dont seem to be used
2. create new column claimable
3. use configuration json

New assigned task state flow
- ACTIVE
- FAILED
- ABANDONED
- COMPLETED
- CLAIMED if claimable

Expiration of tasks should work the same, if you competed the task and didnt claim you dont get anyhing, and if its not claimable then just send rewards as before.

Sending rewards:

Options:
- Send rewards from task service to where it has to go depending on reward configuration
- Send task completed event to related servcies and handle the task event there and distribute rewards accordingly
- if we go with this approach it would be appropriate to restructure atleast at first the new tasks to have rewards as a dictionary not as with keys being the name of the service, so we can access related rewards in that service

Tasks:

  1. Get familiar with task service structure, notably the task model and methods and expiration of tasks
  2. Investigate if its possible to include 'claimable' into tags and integrate it into the functions and queries
  3. Add new state of tasks (CLAIMED) and implement endpoints to get list of claimable tasks with paginations for user and endpoint to claim task
    1. EP to claim task
      1. should take a user_id and list of task_ids
      2. Should return proper and meaningfull internal exceptions, as they will be handled on php proxy layer, you can choose to handle middleware connections issues as well with retry if you want but for the sake of time its not required
  4. Reward, if claimable then reward thoruhg EP if not then keep the current logic

Add a amount field to either extras and configuration and add this "amount" to GET endpoint so its available for PHP, alongside the "game" parameter in extras

Actions #1

Updated by Kennedy Bacelar 9 months ago

  • % Done changed from 0 to 50

Peter Mačuga wrote:

The goal of this feature is to expand the functionality of task service to include claimable tasks - tasks which only award rewards after they are claimed. The claiming of the task is done in a seperate endpoint with the task_id and user_id as parameters.

Multiple claimable solution options:

  1. Insert claimable into tags - maybe the best solution, dont know what it might break, tags dont seem to be used
  2. create new column claimable
  3. use configuration json

New assigned task state flow

  • ACTIVE
    • FAILED
    • ABANDONED
    • COMPLETED
      • CLAIMED if claimable

Expiration of tasks should work the same, if you competed the task and didnt claim you dont get anyhing, and if its not claimable then just send rewards as before.

Sending rewards:

Options:

  • Send rewards from task service to where it has to go depending on reward configuration
  • Send task completed event to related servcies and handle the task event there and distribute rewards accordingly
    • if we go with this approach it would be appropriate to restructure atleast at first the new tasks to have rewards as a dictionary not as with keys being the name of the service, so we can access related rewards in that service

Tasks:

  1. Get familiar with task service structure, notably the task model and methods and expiration of tasks
  2. Investigate if its possible to include 'claimable' into tags and integrate it into the functions and queries
  3. Add new state of tasks (CLAIMED) and implement endpoints to get list of claimable tasks with paginations for user and endpoint to claim task
    1. EP to claim task
      1. should take a user_id and list of task_ids
      2. Should return proper and meaningfull internal exceptions, as they will be handled on php proxy layer, you can choose to handle middleware connections issues as well with retry if you want but for the sake of time its not required
  4. Reward, if claimable then reward thoruhg EP if not then keep the current logic

Add a amount field to either extras and configuration and add this "amount" to GET endpoint so its available for PHP, alongside the "game" parameter in extras

Actions #2

Updated by Kennedy Bacelar 9 months ago

EP to retrieve claimable tests already implemented. Unit and integration tests implemented. Missing to implement the EP to claim passed tasks.

Actions #3

Updated by Kennedy Bacelar 9 months ago

EP to retrieve claimable tests already implemented. Unit and integration tests implemented. Missing to implement the EP to claim passed tasks.

Check the changes at branch https://github.com/QORPO-WORLD/qorpo-task-service/tree/feature/expand-task-service-claimable-tasks_v2

Actions #4

Updated by Peter Mačuga 9 months ago

  • Pull Request set to https://github.com/QORPO-WORLD/qorpo-task-service/tree/feature/expand-task-service-claimable-tasks_v2
Actions #5

Updated by Peter Mačuga 9 months ago

  • Pull Request changed from https://github.com/QORPO-WORLD/qorpo-task-service/tree/feature/expand-task-service-claimable-tasks_v2 to https://github.com/QORPO-WORLD/qorpo-task-service/pull/9
Actions #6

Updated by Peter Mačuga 9 months ago

To clarify the inclusion of claimable amount:

Add a field to extras column in Task table called claimable_amount (or something similar) to show how much currency user needs to claim the rewards from the task.
Add a extras column to assigned_task model.
Add a claimable_amount value from task table to assigned_task.extras column on assigned_task create to keep the historical information about how much each task needed to be claimed, in case of task.extras.claimable_amount changes.
Include the task.extras.game and task.extras.claimable_amount to the get_claimable_tasks for user EP.
Modify the get_claimable_tasks EP to have a claimable:bool parameter and make it so that you can filter if you want claimble or not. Make it optional, in which case it will return them all. (This maybe already exists, if so write me a message)

Actions #7

Updated by Kennedy Bacelar 9 months ago

Peter Mačuga wrote in #note-6:

To clarify the inclusion of claimable amount:

Add a field to extras column in Task table called claimable_amount (or something similar) to show how much currency user needs to claim the rewards from the task. (Added)
Add a extras column to assigned_task model. (Added)
Add a claimable_amount value from task table to assigned_task.extras column on assigned_task create to keep the historical information about how much each task needed to be claimed, in case of task.extras.claimable_amount changes. (Added)
Include the task.extras.game and task.extras.claimable_amount to the get_claimable_tasks for user EP. (Included)
Modify the get_claimable_tasks EP to have a claimable:bool parameter and make it so that you can filter if you want claimble or not. Make it optional, in which case it will return them all. (This maybe already exists, if so write me a message) ( This already exist in other endpoints )

Actions #8

Updated by Kennedy Bacelar 9 months ago

  • % Done changed from 50 to 90

Waiting review.

Actions #9

Updated by Peter Mačuga 9 months ago

  • Status changed from New to Testing
  • % Done changed from 90 to 100
Actions

Also available in: Atom PDF