summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguntasgrewal <guntasgrewal@gmail.com>2014-04-24 17:58:22 -0400
committerguntasgrewal <guntasgrewal@gmail.com>2014-04-24 17:58:22 -0400
commit76ee2a59964be6707cab25053697a2d848bbcd52 (patch)
treed9e815057b04cfb3af2b0c98ca3c2d1c808c4f3b
parent7fe1894becda038c3e85ba179dc27ce3b54690dc (diff)
parent976325f60e7706e480f3d45848897200734c8485 (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
-rw-r--r--app/controllers/tournaments_controller.rb4
-rw-r--r--app/models/api_request.rb2
-rw-r--r--app/models/api_requests.rb2
-rw-r--r--app/models/tournament.rb12
-rw-r--r--app/views/matches/index.html.erb7
-rw-r--r--db/migrate/20140424162546_create_simple_captcha_data.rb (renamed from db/migrate/20140423214420_create_simple_captcha_data.rb)0
-rw-r--r--db/migrate/20140424202542_create_mailboxer.mailboxer_engine.rb (renamed from db/migrate/20140424014418_create_mailboxer.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424202543_add_notified_object.mailboxer_engine.rb (renamed from db/migrate/20140424014419_add_notified_object.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424202544_add_notification_code.mailboxer_engine.rb (renamed from db/migrate/20140424014420_add_notification_code.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424202545_add_attachments.mailboxer_engine.rb (renamed from db/migrate/20140424014421_add_attachments.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424202546_rename_receipts_read.mailboxer_engine.rb (renamed from db/migrate/20140424014422_rename_receipts_read.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424202547_add_global_notification_support.mailboxer_engine.rb (renamed from db/migrate/20140424014423_add_global_notification_support.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140424202549_create_delayed_jobs.rb (renamed from db/migrate/20140424014424_create_delayed_jobs.rb)0
-rw-r--r--db/migrate/20140424202553_create_servers.rb (renamed from db/migrate/20140424014425_create_servers.rb)0
-rw-r--r--db/migrate/20140424202557_create_matches.rb (renamed from db/migrate/20140424014426_create_matches.rb)0
-rw-r--r--db/migrate/20140424202600_create_teams.rb (renamed from db/migrate/20140424014427_create_teams.rb)0
-rw-r--r--db/migrate/20140424202604_create_alerts.rb (renamed from db/migrate/20140424014428_create_alerts.rb)0
-rw-r--r--db/migrate/20140424202608_create_pms.rb (renamed from db/migrate/20140424014429_create_pms.rb)0
-rw-r--r--db/migrate/20140424202611_create_tournaments.rb (renamed from db/migrate/20140424014431_create_tournaments.rb)0
-rw-r--r--db/migrate/20140424202615_create_games.rb (renamed from db/migrate/20140424014433_create_games.rb)0
-rw-r--r--db/migrate/20140424202619_create_users.rb (renamed from db/migrate/20140424014434_create_users.rb)0
-rw-r--r--db/migrate/20140424202623_create_sessions.rb (renamed from db/migrate/20140424014436_create_sessions.rb)0
-rw-r--r--db/migrate/20140424202626_create_brackets.rb (renamed from db/migrate/20140424014437_create_brackets.rb)0
-rw-r--r--db/migrate/20140424202630_create_game_settings.rb (renamed from db/migrate/20140424014439_create_game_settings.rb)0
-rw-r--r--db/migrate/20140424202634_create_tournament_settings.rb (renamed from db/migrate/20140424014440_create_tournament_settings.rb)0
-rw-r--r--db/migrate/20140424202638_create_tournament_stages.rb (renamed from db/migrate/20140424014442_create_tournament_stages.rb)0
-rw-r--r--db/migrate/20140424202641_create_statistics.rb (renamed from db/migrate/20140424014443_create_statistics.rb)0
-rw-r--r--db/migrate/20140424202645_create_remote_usernames.rb (renamed from db/migrate/20140424014445_create_remote_usernames.rb)0
-rw-r--r--db/migrate/20140424202649_create_bracket_matches.rb (renamed from db/migrate/20140424014446_create_bracket_matches.rb)0
-rw-r--r--db/migrate/20140424202652_create_api_requests.rb (renamed from db/migrate/20140424014448_create_api_requests.rb)0
-rw-r--r--db/migrate/20140424202656_create_tournament_players_join_table.rb (renamed from db/migrate/20140424014449_create_tournament_players_join_table.rb)0
-rw-r--r--db/migrate/20140424202659_create_tournament_hosts_join_table.rb (renamed from db/migrate/20140424014451_create_tournament_hosts_join_table.rb)0
-rw-r--r--db/migrate/20140424202703_create_team_user_join_table.rb (renamed from db/migrate/20140424014452_create_team_user_join_table.rb)0
-rw-r--r--db/migrate/20140424202706_create_match_team_join_table.rb (renamed from db/migrate/20140424014454_create_match_team_join_table.rb)0
-rw-r--r--db/migrate/20140424202717_add_hidden_attrs_to_user.rb (renamed from db/migrate/20140424014459_add_hidden_attrs_to_user.rb)0
-rw-r--r--db/schema.rb2
-rwxr-xr-xgenerate.sh2
-rw-r--r--lib/scheduling/elimination.rb2
-rw-r--r--test/models/api_request_test.rb (renamed from test/models/api_requests_test.rb)2
39 files changed, 12 insertions, 23 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index ebc54c1..1354ad6 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -116,8 +116,8 @@ class TournamentsController < ApplicationController
success = true
ActiveRecord::Base.transaction do
success &= @tournament.save &&
- success &= @tournament.tournament_stages.create(scheduling: "elimination")
- success &= @tournament.tournament_stages.first.create_matches
+ success &= @tournament.stages.create(scheduling: "elimination")
+ success &= @tournament.stages.first.create_matches
end
if success
format.html { redirect_to @tournament, notice: 'You have started this tournament.' }
diff --git a/app/models/api_request.rb b/app/models/api_request.rb
new file mode 100644
index 0000000..ffb7267
--- /dev/null
+++ b/app/models/api_request.rb
@@ -0,0 +1,2 @@
+class ApiRequest < ActiveRecord::Base
+end
diff --git a/app/models/api_requests.rb b/app/models/api_requests.rb
deleted file mode 100644
index 19c76e2..0000000
--- a/app/models/api_requests.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class ApiRequests < ActiveRecord::Base
-end
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index e21ccb1..861be6c 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -1,20 +1,10 @@
class Tournament < ActiveRecord::Base
belongs_to :game
- has_many :tournament_stages
+ has_many :stages, class_name: "TournamentStage"
has_many :settings_raw, class_name: "TournamentSetting"
has_and_belongs_to_many :players, class_name: "User", association_foreign_key: "player_id", join_table: "players_tournaments"
has_and_belongs_to_many :hosts, class_name: "User", association_foreign_key: "host_id", join_table: "hosts_tournaments"
- def stages_ordered
- h = {}
- i = 1
- self.tournament_stages.order(:id).each do |s|
- h[i] = s
- i += 1
- end
- return h
- end
-
def settings
@settings ||= Settings.new(self)
end
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb
index 8a50fee..784d7db 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -12,8 +12,7 @@
</tr>
</thead>
<tbody>
- <% @tournament.stages_ordered.keys.sort.each do |stage_key| %>
- <% stage = @tournament.stages_ordered[stage_key] %>
+ <% @tournament.stages.order(:id).each do |stage| %>
<% stage.matches_ordered.keys.sort.reverse.each do |match_key| %><tr>
<% match = stage.matches_ordered[match_key] %>
<td><%= "Match #{match.id}" %></td>
@@ -36,6 +35,6 @@
<br>
-<% @tournament.stages_ordered.keys.sort.each do |stage_key| %>
- <div class="graph"><%= raw @tournament.stages_ordered[stage_key].to_svg(current_user) %></div>
+<% @tournament.stages.order(:id).each do |stage| %>
+ <div class="graph"><%= raw stage.to_svg(current_user) %></div>
<% end %>
diff --git a/db/migrate/20140423214420_create_simple_captcha_data.rb b/db/migrate/20140424162546_create_simple_captcha_data.rb
index 4573b20..4573b20 100644
--- a/db/migrate/20140423214420_create_simple_captcha_data.rb
+++ b/db/migrate/20140424162546_create_simple_captcha_data.rb
diff --git a/db/migrate/20140424014418_create_mailboxer.mailboxer_engine.rb b/db/migrate/20140424202542_create_mailboxer.mailboxer_engine.rb
index 690cec2..690cec2 100644
--- a/db/migrate/20140424014418_create_mailboxer.mailboxer_engine.rb
+++ b/db/migrate/20140424202542_create_mailboxer.mailboxer_engine.rb
diff --git a/db/migrate/20140424014419_add_notified_object.mailboxer_engine.rb b/db/migrate/20140424202543_add_notified_object.mailboxer_engine.rb
index 7f41ac6..7f41ac6 100644
--- a/db/migrate/20140424014419_add_notified_object.mailboxer_engine.rb
+++ b/db/migrate/20140424202543_add_notified_object.mailboxer_engine.rb
diff --git a/db/migrate/20140424014420_add_notification_code.mailboxer_engine.rb b/db/migrate/20140424202544_add_notification_code.mailboxer_engine.rb
index 04c12ef..04c12ef 100644
--- a/db/migrate/20140424014420_add_notification_code.mailboxer_engine.rb
+++ b/db/migrate/20140424202544_add_notification_code.mailboxer_engine.rb
diff --git a/db/migrate/20140424014421_add_attachments.mailboxer_engine.rb b/db/migrate/20140424202545_add_attachments.mailboxer_engine.rb
index b8d6588..b8d6588 100644
--- a/db/migrate/20140424014421_add_attachments.mailboxer_engine.rb
+++ b/db/migrate/20140424202545_add_attachments.mailboxer_engine.rb
diff --git a/db/migrate/20140424014422_rename_receipts_read.mailboxer_engine.rb b/db/migrate/20140424202546_rename_receipts_read.mailboxer_engine.rb
index 9ce904f..9ce904f 100644
--- a/db/migrate/20140424014422_rename_receipts_read.mailboxer_engine.rb
+++ b/db/migrate/20140424202546_rename_receipts_read.mailboxer_engine.rb
diff --git a/db/migrate/20140424014423_add_global_notification_support.mailboxer_engine.rb b/db/migrate/20140424202547_add_global_notification_support.mailboxer_engine.rb
index 60f67ab..60f67ab 100644
--- a/db/migrate/20140424014423_add_global_notification_support.mailboxer_engine.rb
+++ b/db/migrate/20140424202547_add_global_notification_support.mailboxer_engine.rb
diff --git a/db/migrate/20140424014424_create_delayed_jobs.rb b/db/migrate/20140424202549_create_delayed_jobs.rb
index ec0dd93..ec0dd93 100644
--- a/db/migrate/20140424014424_create_delayed_jobs.rb
+++ b/db/migrate/20140424202549_create_delayed_jobs.rb
diff --git a/db/migrate/20140424014425_create_servers.rb b/db/migrate/20140424202553_create_servers.rb
index fbe1b02..fbe1b02 100644
--- a/db/migrate/20140424014425_create_servers.rb
+++ b/db/migrate/20140424202553_create_servers.rb
diff --git a/db/migrate/20140424014426_create_matches.rb b/db/migrate/20140424202557_create_matches.rb
index bac92d1..bac92d1 100644
--- a/db/migrate/20140424014426_create_matches.rb
+++ b/db/migrate/20140424202557_create_matches.rb
diff --git a/db/migrate/20140424014427_create_teams.rb b/db/migrate/20140424202600_create_teams.rb
index dd8397d..dd8397d 100644
--- a/db/migrate/20140424014427_create_teams.rb
+++ b/db/migrate/20140424202600_create_teams.rb
diff --git a/db/migrate/20140424014428_create_alerts.rb b/db/migrate/20140424202604_create_alerts.rb
index 68a8e10..68a8e10 100644
--- a/db/migrate/20140424014428_create_alerts.rb
+++ b/db/migrate/20140424202604_create_alerts.rb
diff --git a/db/migrate/20140424014429_create_pms.rb b/db/migrate/20140424202608_create_pms.rb
index 93bb5c6..93bb5c6 100644
--- a/db/migrate/20140424014429_create_pms.rb
+++ b/db/migrate/20140424202608_create_pms.rb
diff --git a/db/migrate/20140424014431_create_tournaments.rb b/db/migrate/20140424202611_create_tournaments.rb
index 716871f..716871f 100644
--- a/db/migrate/20140424014431_create_tournaments.rb
+++ b/db/migrate/20140424202611_create_tournaments.rb
diff --git a/db/migrate/20140424014433_create_games.rb b/db/migrate/20140424202615_create_games.rb
index 23edf0b..23edf0b 100644
--- a/db/migrate/20140424014433_create_games.rb
+++ b/db/migrate/20140424202615_create_games.rb
diff --git a/db/migrate/20140424014434_create_users.rb b/db/migrate/20140424202619_create_users.rb
index 8032870..8032870 100644
--- a/db/migrate/20140424014434_create_users.rb
+++ b/db/migrate/20140424202619_create_users.rb
diff --git a/db/migrate/20140424014436_create_sessions.rb b/db/migrate/20140424202623_create_sessions.rb
index f667f1e..f667f1e 100644
--- a/db/migrate/20140424014436_create_sessions.rb
+++ b/db/migrate/20140424202623_create_sessions.rb
diff --git a/db/migrate/20140424014437_create_brackets.rb b/db/migrate/20140424202626_create_brackets.rb
index 8813bf2..8813bf2 100644
--- a/db/migrate/20140424014437_create_brackets.rb
+++ b/db/migrate/20140424202626_create_brackets.rb
diff --git a/db/migrate/20140424014439_create_game_settings.rb b/db/migrate/20140424202630_create_game_settings.rb
index 06fb72e..06fb72e 100644
--- a/db/migrate/20140424014439_create_game_settings.rb
+++ b/db/migrate/20140424202630_create_game_settings.rb
diff --git a/db/migrate/20140424014440_create_tournament_settings.rb b/db/migrate/20140424202634_create_tournament_settings.rb
index e56697f..e56697f 100644
--- a/db/migrate/20140424014440_create_tournament_settings.rb
+++ b/db/migrate/20140424202634_create_tournament_settings.rb
diff --git a/db/migrate/20140424014442_create_tournament_stages.rb b/db/migrate/20140424202638_create_tournament_stages.rb
index e3668cb..e3668cb 100644
--- a/db/migrate/20140424014442_create_tournament_stages.rb
+++ b/db/migrate/20140424202638_create_tournament_stages.rb
diff --git a/db/migrate/20140424014443_create_statistics.rb b/db/migrate/20140424202641_create_statistics.rb
index cc2e97d..cc2e97d 100644
--- a/db/migrate/20140424014443_create_statistics.rb
+++ b/db/migrate/20140424202641_create_statistics.rb
diff --git a/db/migrate/20140424014445_create_remote_usernames.rb b/db/migrate/20140424202645_create_remote_usernames.rb
index e265985..e265985 100644
--- a/db/migrate/20140424014445_create_remote_usernames.rb
+++ b/db/migrate/20140424202645_create_remote_usernames.rb
diff --git a/db/migrate/20140424014446_create_bracket_matches.rb b/db/migrate/20140424202649_create_bracket_matches.rb
index 3323e31..3323e31 100644
--- a/db/migrate/20140424014446_create_bracket_matches.rb
+++ b/db/migrate/20140424202649_create_bracket_matches.rb
diff --git a/db/migrate/20140424014448_create_api_requests.rb b/db/migrate/20140424202652_create_api_requests.rb
index 544c330..544c330 100644
--- a/db/migrate/20140424014448_create_api_requests.rb
+++ b/db/migrate/20140424202652_create_api_requests.rb
diff --git a/db/migrate/20140424014449_create_tournament_players_join_table.rb b/db/migrate/20140424202656_create_tournament_players_join_table.rb
index be240e8..be240e8 100644
--- a/db/migrate/20140424014449_create_tournament_players_join_table.rb
+++ b/db/migrate/20140424202656_create_tournament_players_join_table.rb
diff --git a/db/migrate/20140424014451_create_tournament_hosts_join_table.rb b/db/migrate/20140424202659_create_tournament_hosts_join_table.rb
index 7521d89..7521d89 100644
--- a/db/migrate/20140424014451_create_tournament_hosts_join_table.rb
+++ b/db/migrate/20140424202659_create_tournament_hosts_join_table.rb
diff --git a/db/migrate/20140424014452_create_team_user_join_table.rb b/db/migrate/20140424202703_create_team_user_join_table.rb
index f3b57fc..f3b57fc 100644
--- a/db/migrate/20140424014452_create_team_user_join_table.rb
+++ b/db/migrate/20140424202703_create_team_user_join_table.rb
diff --git a/db/migrate/20140424014454_create_match_team_join_table.rb b/db/migrate/20140424202706_create_match_team_join_table.rb
index c2ed1b7..c2ed1b7 100644
--- a/db/migrate/20140424014454_create_match_team_join_table.rb
+++ b/db/migrate/20140424202706_create_match_team_join_table.rb
diff --git a/db/migrate/20140424014459_add_hidden_attrs_to_user.rb b/db/migrate/20140424202717_add_hidden_attrs_to_user.rb
index 9b5c505..9b5c505 100644
--- a/db/migrate/20140424014459_add_hidden_attrs_to_user.rb
+++ b/db/migrate/20140424202717_add_hidden_attrs_to_user.rb
diff --git a/db/schema.rb b/db/schema.rb
index 0e9202a..0833263 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20140424014459) do
+ActiveRecord::Schema.define(version: 20140424202717) do
create_table "alerts", force: true do |t|
t.integer "author_id"
diff --git a/generate.sh b/generate.sh
index 8e29384..be2e1a1 100755
--- a/generate.sh
+++ b/generate.sh
@@ -61,7 +61,7 @@ bundle exec rails generate model remote_username game:references user:references
bundle exec rails generate model bracket_match bracket:references match:references predicted_winner:references
-bundle exec rails generate model api_requests api_name:string
+bundle exec rails generate model api_request api_name:string
# Join tables
bundle exec rails generate migration CreateTournamentPlayersJoinTable players tournaments
diff --git a/lib/scheduling/elimination.rb b/lib/scheduling/elimination.rb
index ca48f14..e66a29a 100644
--- a/lib/scheduling/elimination.rb
+++ b/lib/scheduling/elimination.rb
@@ -32,7 +32,7 @@ module Scheduling
# if the match is full, move to the next match, otherwise move to the next team
if (team_num == self.tournament.min_teams_per_match)
match_num -= 1
- team_num = 0
+ team_num = 1
else
team_num += 1
end
diff --git a/test/models/api_requests_test.rb b/test/models/api_request_test.rb
index 18763a7..ea37ce4 100644
--- a/test/models/api_requests_test.rb
+++ b/test/models/api_request_test.rb
@@ -1,6 +1,6 @@
require 'test_helper'
-class ApiRequestsTest < ActiveSupport::TestCase
+class ApiRequestTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end