I have a user's item that needs to be validated 10 times (variable value) by other users. And when the item is validated 10 times, the item's owner gets a number of points.
But my problem is, if 400 users validate at the same time the item, I will not be able to validate it only once.
e.g:
nbValidation >= 10 && validated === false
-> patch { validated: true }
and give to the user 10 pointsnbValidation >= 10 && validated === false
-> patch { validated: true }
and give to the user 10 points againSo the user has 20 points instead of 10 points.
I'm using feathersJs
Have you any idea to avoid this problem?
Thanks
In your validation service, the incoming requests should be queued and pick one user at a time to do your logic. Once you successfully validate the variable, give points to the user and maintain a record of who already validated the current variable like a cache and add this user. Now, you can remove the user from the queue and pick the next one.
This way you can keep the users in the same format as they come in and the local cache can help you identify who already validated the same variable.