dgw / sopel-rep

Lets users "luv" and "h8" other users on IRC. Functional clone of a mIRC script someone used in a channel I was in.
Other
0 stars 1 forks source link

Ranking functions #1

Open dgw opened 9 years ago

dgw commented 9 years ago

Need a way to output the top n (and also bottom n?) users by rep score. Ideally, without having to switch away from using bot.db for storage…

dgw commented 7 years ago

I don't think it's practical to implement this without switching to a custom database table. It's possible to generate a ranking with something like

SELECT n.canonical, v.value 
FROM nick_values v 
JOIN nicknames n ON n.nick_id=v.nick_id 
WHERE key='rep_score' 
GROUP BY n.nick_id 
ORDER BY value DESC 
LIMIT 5;

but that returns whichever canonical nick the database feels like returning (and usually not the "primary", or first one added to the group). Works great for installs that don't utilize nick grouping at all, but as soon as even one nick group exists (that contains more than one nickname) it will more than likely start returning the "wrong" nickname for display.

So, this will remain on the back burner, as it has for nearly two years. (I don't want to use custom tables because of the maintenance overhead required to support merging them in the merge utils module, but ugh.)