Leaderboard logic

0
Hi, i have created a leaderboard which grabs the top 10 usernames with the highest points, as well as the local user and their points. I want to create a microflow to display which position they are in the leaderboard, so the top 10 will obviously display 1-10 and the current user could be anything from 1-500 (etc); what resources would developers recommend, or could anyone provide any advice regarding this? I have enclosed screenshots from what the app will look like (the question mark is where the position should be)
asked
2 answers
0

There may be better ways of doing it, but here are two methods.

  1. Add an attribute to the user called ‘Position’
    In a microflow, retrieve and sort the list of users and their score descending. Have a integer varible that starts at 1.  Iterate in a loop over the list and apply that integer variable to the user then add one. So it should apply 1 to 1st plave, 2 to 2nd and so on. 
    You can have a text field that displays the [%CurrentUser%]/Position somewhere on the page. 

 

  1. Alternatively in a microflow retrieve any users that have a higher number than the current user, count them, add one and apply the result to the current user. Noe entirely accurate buy easy to do.
answered
-1

I would recommend doing Garion’s first example, but in order to also display the current user, I would add on one extra thing:
In the list view where you display the top 10, if the current user isn’t a part of the top 10 list, I would make visible a second list view that appeared under the top 10 list and displayed the user’s information (You can single out the user by adding a constraint to the second list view that goes like ‘User/Name = [%CurrentUser%]/Name’). I’ve played with stacked list views like this in the past and it should look seamless, so the user won’t know you’re displaying two separate lists.

answered