@adamhholmes this would have to be a contender for an interesting Bubble challenge
@daniel.svedberg I understand that you want to find the current userâs leaderboard position, without displaying all of the others. The simple solution is to, yes, find ALL leaderboard positions, and conditionally hide them if itâs not the Current User, but that is WU heavy and requires returning all position data to the client. Maybe you want to display â#3â in the Userâs dashboard, for example.
The problem is, Bubble doesnât give us a great way to find a Thingâs position in a list. What youâd want to do (and Bubble wonât let you) is Sort a list, then retrieve the index of the row where User = Current User. Bubble doesnât let us get the index - and as far as I can tell, most of the workarounds require returning all of the other data (e.g unique IDs) and using some Regex or Split by to work out the position in the list.
If thatâs fine for you, then go for it, but Bubble makes it harder than it needs to be!
This should work⌠(but havenât actually tried it)
Search for users [where points > Current User's points]: grouped by points: count: +1
That would first find all users with more points than the current user (i.e. who are higher in the leaderboard).
Then it would establish how many actual positions above the current user there are (assuming multiple users with the same points would share the same position).
Then just add 1 to get the current userâs position.
Works like a charm.
Just have to define your own rule for equality. To know if you do the group by thing or not. And have John in the 5th or the 7th place (with this example).
Yeah, I reckon itâs 0.3 WU search/group by, possibly + 0.2 WU for count (though who knows whether Bubble charges for that as surely thatâs already in the browser). Max 0.5 WU if the docs are right. Pretty damn good, and a simple solution with no hacky workarounds.
However, for some things, I donât understand why you wouldnât use third-party software.
For example, Referral Hero is like $200 a month and does a ton of stuff that would take a whole lot of work units to do. Leaderboards and everything else.
Why not use whatâs out there and incorporate it into your Bubble app?
Itâs like scheduling. Why not use Calendly or something like that and save yourself a ton of work units?
Maybe Iâm wrong. Just what Iâve noticed so far.
If anyone has any thoughts Iâd love to hear them.
For me personally, I try to avoid any 3rd party platforms originally due to extra fees, but now that WUs are involved that is not necessarily the first reason, but is still a consideration. For example a 3rd party database, may cost $99/month, but the WU tier that I need to upgrade may only be $30/month or equal to the $99/month 3rd party database.
So, if the costs are equal, it then comes down to complexity of the build in Bubble and also the reliance on more than one provider, which could mean, problems with Bubble make app not function and problems with 3rd party platform make the app not function. In addition to that, it is the need to learn a 3rd party platform as well that gives me pause in implementing more 3rd party tools into the Bubble app. And lastly, I donât like having to check in so many different places for things, and so to have to check 3rd party accounts to see things in addition to seeing them in Bubble is something I like to avoid, especially during debugging.
I can understand there are probably examples of 3rd party systems that can be incorporated that are free, not complicated etc. but still, I prefer to be reliant on less providers as it feels a bit âsaferâ.
I imagine as well, that if the time were to come when a commercial application of mine was taking off, and the need for a 3rd party tool to do something Bubble either is too costly for or not as efficient, then I would bite the bullet and do what needs to be done. I imagine for most on Bubble, they have yet to reach that point, so they may continue to implement the KISS principle in getting their MVPs out the door.
This is great, I would just add that if your âpointsâ shouldnât be public to other users and you just want the position on the leaderboard, youâd be best off running this in a backend workflow that ignores privacy rules. That way the search is done server-side and youâre not exposing any points to other users. It probably also makes the most sense to update this once per day rather than every time the page loads.
Updating a rank field on each user once will cost at least 1 WU per user per day, when 98% of users wonât even be logging in that day.
Donât do that.
If you really want to cache it, then do it when the user logs in, for the first time today, and save their position in a field and reference that everywhere else. But, as with many WU optimisations, probably not worth it given the poorer user experience it results in.
99.99% of leaderboards and ladders Iâve seen do not calculate themselves on demand. Even in the majority of video games the ELO will update instantly but the âTop 10â typically doesnât update on a per-match basis. That would frankly be bizarre. A leaderboard that calculates once per day or once per week is much more common, YMMV.
Yeah, calculating this once per day (for every single User in the database) will not only cost way more in WU, but also (potentially) make the data so inaccurate as to be completely irrelevant.
Why are we calculating this for every single user, even if theyâre inactive or havenât contributed in the last day? And it would be inaccurate by one day at the most.
I donât have enough context to say if thatâs a problem, but in many cases it wonât be.
I understand what you mean about 3rd party software.
Even someone like AirBnb though uses 3rd party software. They use Grow Surf for their referrals. You just include the script and the whole thing runs on its own. Emails, fraud prevention, etc.
I could use Ruby on Rails like Morning Brew, but then again I asked myself why, when I could take 15 minutes, include some script, and have something that ran on its own.
I spent hours over a few days learning how to build a referral program for my appâŚwhen I was done i decided by the time I added all the features a 3rd party program had it would take more work to just maintain the program than what it was probably worth. Plus, the added cost in WUs. Referral programs can grow big really fast if theyâre done right.
My goal is to just have an app that can pretty much run on its own. Yes, I know apps always need maintenance, but Iâm trying to minimize that
The only 3rd party software I was also considering that requires using their admin panel is tawk.to, and thatâs if I decide to add a chat feature. Itâs free, but Iâm still considering it.
Maybe someday when I get more experienced with Bubble some of the added features wonât be so complicated for me to figure out.
Well, how else could you do it, if not for every user? In order to calculate a Users position you have to establish every other userâs score/position regardless of whether theyâve been active in the past day or not. (if someone else has been active on a given day and I havenât, they may have overtaken me in the leaderboard, so youâll have to update my position as well as everyone elseâs).
Exactly - so if users are earning points on an hourly basis, it will be wildly inaccurate to the point of being useless.