So i have a function where user can see a leaderboard on whoever completed most of the events (the ranking should be the person who have completed the most at the top and then go down and lower the user the least amount of task completed), I have being playing around with the custom filter and was still struggling with it, is there any ways i can fix this?
You can accomplish this by adding a number parameter to the user collection and call it “Completed Events”.
Add an action when the user completes an event to take the “logged-in user > completed events + 1”
I went ahead and tried your method out, i was able to set up the things you said correctly, however it is unfortunately not working when a user click on the toggle their completed event will not update in the database, is there a solution to this?
It can work just fine. I’m not sure what you mean. The user has to click the toggle to complete the event, correct? This will add 1 to their current count. You need to add their current counts manually.
Dont overthink it
Watch my video carefully. The +1 and -1 actions on on and off.
I would simply do a collection of items with a relation property with users called “completed by”, and a numeric field called “n. of completed items” . So when you toggle on that box, it will add the user to the completed by field and update +1 the current usern number, otherwise will remove him and remove -1.
Then in your ranking list just sort by current item - n. of completed items - High to Low
Remember to set up that number to 0 once the user sign-up for the first time
I’m sorry if my English is bad. I’m just saying that your numeric field (rating) should be in user’s collection. So once an user click the toggle on or off, it will do +1 or -1, also your collection of “tasks” should have a property in relation with users called “completed by”, so when an user click the toggle it automatically check if the same user has already completed the task or not, and based on that will correctly do the +1 or -1 operation