PeterBorah / vigor

An unofficial ruby wrapper for the League of Legends API
MIT License
4 stars 4 forks source link

The '.recent_games' method for the Summoner class not sorted. #23

Closed chrisroman closed 10 years ago

chrisroman commented 10 years ago

It just returns the games in some random order (I'm not too sure how it's being given back). However, this code would return the games in order from the most recent to the least recent which would be more convenient.

def recent_games
    games = Vigor.recent_games(@id)
    games.sort { |x, y| y.created_at <=> x.created_at } 
end

Edit: Phew finally got the spaceship operator to show up

PeterBorah commented 10 years ago

+1

At the moment, we just use the output of Httparty. I'm not sure if that means Riot is returning an unordered list, or that it's getting mangled on our end, but either way you are right that it should be ordered.

imogenkinsman commented 10 years ago

Yeah, the API returns an unordered list - one of several weird issues with it (mastery pages aren't ordered either, and there's no way I know of to sort that). I think it'd make sense for us to just sort the response, since most people using the gem would want it sorted for displaying recent games.