From 33fcf6de9feaaa6f90dfe5082e08d280c930dae1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 28 Apr 2014 00:04:30 -0400 Subject: Re-jigger the sampling interface --- lib/sampling/riot_api.rb | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'lib/sampling/riot_api.rb') diff --git a/lib/sampling/riot_api.rb b/lib/sampling/riot_api.rb index 8c34fc4..7e14551 100644 --- a/lib/sampling/riot_api.rb +++ b/lib/sampling/riot_api.rb @@ -1,5 +1,5 @@ module Sampling - module RiotApi + class RiotApi protected def self.api_name "prod.api.pvp.net/api/lol" @@ -87,21 +87,12 @@ module Sampling # Return whether or not the API can get a given statistic for # a given user. public - def self.can_get?(user, stat) - if user.nil? + def self.can_get?(stat) + if stats_available.include?(stat) + return 2 + else return 0 end - summoner = user.get_remote_username(match.tournament_stage.tournament.game) - if summoner.nil? - return 0 - end - if summoner["id"].nil? - return 0 - end - unless stats_available.include?(stat) - return 0 - end - return 2 end ## @@ -149,13 +140,20 @@ module Sampling data["name"] end + #### + + public + def initialize(match) + @match = match + end + ## # Fetch all the statistics for a match. public - def self.sampling_start(match, stats) + def start @match.teams.each do |team| team.users.each do |user| - Delayed::Job.enqueue(MatchJob.new(user, match, stats.map{|stat|stat[:name]}, nil), :queue => api_name) + Delayed::Job.enqueue(MatchJob.new(user, @match, @match.stats_from(self.class), nil), :queue => api_name) end end end @@ -191,12 +189,13 @@ module Sampling end public - def self.render_user_interaction(match, user) + def render_user_interaction(user) return "" end public - def self.handle_user_interaction(match, user) + def handle_user_interaction(user) + # do nothing end end end -- cgit v1.2.3-2-g168b