Created
March 24, 2015 19:41
-
-
Save Theminijohn/0b514a94348fe2424391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'perseus' | |
class TeamRankedStatJob < ActiveJob::Base | |
queue_as :default | |
def perform(team) | |
## Get ready | |
client = Perseus::Client.new(Settings.rito.api_key, region: team.server) | |
## Get Info | |
entries = client.league.entries_by_team(team.full_id).values.flatten | |
## Create | |
entries.each do |e| | |
create_ranked_statistic(e, team_id = team.id) | |
end | |
end | |
def create_ranked_statistic(e, team) | |
RankedStatistic.create( | |
tier: e.tier, | |
wins: e.entries.first.wins, | |
queue: e.queue, | |
losses: e.entries.first.losses, | |
team_id: team.id, | |
division: e.entries.first.division, | |
is_veteran: e.entries.first.is_veteran, | |
is_inactive: e.entries.first.is_inactive, | |
is_hot_streak: e.entries.first.is_hot_streak, | |
league_points: e.entries.first.league_points, | |
is_fresh_blood: e.entries.first.is_fresh_blood, | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment