From 677f914b0d1c9cefcbd9aacbd48e83ab98916f8f Mon Sep 17 00:00:00 2001 From: nfoy Date: Mon, 7 Apr 2014 12:53:36 -0400 Subject: Moved and updated the not-working asynchronous API auto-update feature. --- app/models/match.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'app/models') diff --git a/app/models/match.rb b/app/models/match.rb index 48d6b83..ac74fe1 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -8,4 +8,34 @@ class Match < ActiveRecord::Base def setup() end + + def is_match_over(match, firstPlayer) + #response = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{firstPlayer}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + #riot_id = response["#{firstPlayer}"]['id'] + #recent game information + #game_info = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/game/by-summoner/#{riot_id}/recent?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + #first_id = game_info["games"][0]["gameId"] + + count = 0 + while true do + #sleep(5) #wait four minutes + + puts("Every 4 minutes.") + puts("Every 4 minutes.") + count += 1 + #game_info = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/game/by-summoner/#{riot_id}/recent?api_key=ad539f86-22fd-474d-9279-79a7a296ac38") + #current_id = game_info["games"][0]["gameId"] + + #if current_id != first_id + if count > 2 + puts(count) + #sleep(10) + match.status = 2 + match.save + return true + end + end #while + end + #handle_asynchronously :is_match_over + end -- cgit v1.2.3-2-g168b