summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortkimia <tkimia@purdue.edu>2014-04-07 12:58:37 -0400
committertkimia <tkimia@purdue.edu>2014-04-07 12:58:37 -0400
commitc10c4a27277a0335cd51f85708d12e8c81f7bc9d (patch)
tree90d9e5c426ea9373e129a6041ef22b4f1d733683
parentcc3190779e064932ae6c4e180454e379b9c4f933 (diff)
parent57f8334838ebf138b73d12d2750ea792fcc1af68 (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
-rw-r--r--app/controllers/matches_controller.rb20
-rw-r--r--app/models/match.rb30
2 files changed, 30 insertions, 20 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index b6fde0a..95f99a6 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -121,26 +121,6 @@ class MatchesController < ApplicationController
end #end if
end #end def
- def is_match_over
- response = HTTParty.get("https://prod.api.pvp.net/api/lol/na/v1.3/summoner/by-name/#{@first}?api_key=ad539f86-22fd-474d-9279-79a7a296ac38")
- riot_id = response["#{@first}"]['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"]
-
- while true do
- sleep(240) #wait four minutes
-
- recent = 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 = recent["games"][0]["gameId"]
-
- if current_id != first_id
- @match.status = 2
- end
- end #while
- end
- handle_asynchronously :is_match_over
-
# GET /tournaments/1/matches/1
# GET /tournaments/1/matches/1.json
def show
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