-
-
Save kenrick/2d2623ad2b29cff4b090 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 | |
attr_reader :team | |
queue_as :default | |
def perform(team) #rename team here | |
@team = 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) | |
end | |
end | |
def create_ranked_statistic(e) | |
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
OP as always <3