paulgibbs / achievements

Achievements gamifies your WordPress site with challenges, badges, and points.
http://achievementsapp.com
63 stars 9 forks source link

Create a function to get the rank, user id and points of all the users #109

Closed BronsonQuick closed 11 years ago

BronsonQuick commented 11 years ago

Hey Paul,

Seeing you're interesting in fleshing out the API first I'll add this function for your consideration.

I added https://github.com/BronsonQuick/achievements/commit/dad89f8b8752aa7fd1318771f8633210c4e6bf01#L0R370 to make sure that null values were pushed to the bottom of the stack.

Sorry for the delay. Life and clients have been getting in the way of my coding lately!

Cheers!

paulgibbs commented 11 years ago

Thanks. I want to do more to this, but figured it's safe enough to merge in right now, even if I don't get time to finish it before shipping the next version (which i'd like to do later this month)

BronsonQuick commented 11 years ago

Sweet :+1:

I was thinking this morning in the shower that if you didn't want to keep the rank in there we could probably pull out all the results and do a usort or maybe an asort in php.

I come probably have a look at templates for this after this project of ours ships? Maybe we should Skype sometime later in the week so I can flesh out what you have in mind for displaying on the leaderboard?

mikebronner commented 11 years ago

Hi guys,

Just wanted to touch base on this again. What are the benefits of this solution vs the solution I provided? I don't want to harp on my solution as being the correct one, just want to see where this one is different and improved, to better understand it. :)

I know there were discussions about offloading some of the lookup work from the SQL query. What are the large-scale test results on that with, say 20k users? Have you found an decrease in time? I doubt that Wordpress will cache that many users, it might only cache the first few. I did do quite a bit of work to get it into an extensible shortcode format -- is that something of interest still?

I haven't had much time to work on it more, but I'll put more work into it if it is of some use. :)

Thanks! ~Mike

On Jul 1, 2013, at 6:01 PM, Bronson Quick notifications@github.com wrote:

Sweet

I was thinking this morning in the shower that if you didn't want to keep the rank in there we could probably pull out all the results and do a usort or maybe an asort in php.

I come probably have a look at templates for this after this project of ours ships? Maybe we should Skype sometime later in the week so I can flesh out what you have in mind for displaying on the leaderboard?

— Reply to this email directly or view it on GitHub.

BronsonQuick commented 11 years ago

Hey Mike,

My understand from Paul's comment here: https://github.com/paulgibbs/achievements/pull/94#issuecomment-18465157 was that we're better off doing one query to get the least amount of data that we need then run other secondary queries to reduce the load on the databases. For example I've got code very similar to yours (thank you :smiley: to output the leaderboard but I'm using data from this query to user core functions to get the additional data I need.

Checkout: https://gist.github.com/BronsonQuick/6340b6c591674276c049 (It's not pretty cause we're under the pump for a deadline!

Cheers

instinct commented 11 years ago

Well done guys! I'm hanging out for this functionality and waiting for it to get to a point where I can commission some Plugins :P