starknet-id / starknet.quest

The on-chain quest tool of Starknet
https://starknet.quest
31 stars 80 forks source link

Fix duplicate task IDs #838

Open Marchand-Nicolas opened 5 hours ago

Marchand-Nicolas commented 5 hours ago

Description

Fix: we often create new tasks in a batch. This is currently a problem because as the backend receives all these requests, it assigns the tasks IDs simultaneously, which causes multiples tasks to have the same ID (where every ID should be unique, and should, when adding a new task, be the last task ID + 1).

PROPOSED TODO

The issue is located here: app\admin\quests\dashboard\[questId]\page.tsx

const handleAddTasks = useCallback(async (addedTasks: StepMap[]) => {
    const taskPromises = addedTasks.map(async (step) => {
      if (step.type === "Quiz") {
        ...

      if (step.type === "TwitterFw") {
        ...
      } else if (step.type === "TwitterRw") {
      ...
Iwueseiter commented 5 hours ago

can I work on this @Marchand-Nicolas? I'm a frontend and smart contract developer. To fix this bug, I will replace the addedTasks.map with a for...of loop to ensure that each request is awaited before moving to the next one. This approach ensures that each task is processed sequentially, preventing simultaneous ID assignments. The for...of loop combined with await will wait for each request to resolve before continuing to the next one. ETA: 24hrs.

onlydustapp[bot] commented 5 hours ago

Hi @Iwueseiter! Maintainers during the ODHack # 8.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.

onlydustapp[bot] commented 5 hours ago

Hi @Iwueseiter! Maintainers during the ODHack # 8.0 will be tracking applications via OnlyDust. Therefore, in order for you to have a chance at being assigned to this issue, please apply directly here, or else your application may not be considered.