summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/matches_controller.rb3
-rw-r--r--app/models/game.rb40
-rw-r--r--app/models/game_setting.rb11
-rw-r--r--app/models/match.rb32
-rw-r--r--app/models/tournament.rb85
-rw-r--r--app/models/tournament_setting.rb12
-rw-r--r--app/models/tournament_stage.rb10
-rw-r--r--app/models/user.rb94
-rw-r--r--app/views/matches/_form.html.erb8
-rw-r--r--app/views/matches/index.json.jbuilder2
-rw-r--r--app/views/matches/show.json.jbuilder2
-rw-r--r--db/migrate/20140429034423_create_simple_captcha_data.rb (renamed from db/migrate/20140428183808_create_simple_captcha_data.rb)0
-rw-r--r--db/migrate/20140429074419_create_mailboxer.mailboxer_engine.rb (renamed from db/migrate/20140428223805_create_mailboxer.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140429074420_add_notified_object.mailboxer_engine.rb (renamed from db/migrate/20140428223806_add_notified_object.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140429074421_add_notification_code.mailboxer_engine.rb (renamed from db/migrate/20140428223807_add_notification_code.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140429074422_add_attachments.mailboxer_engine.rb (renamed from db/migrate/20140428223808_add_attachments.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140429074423_rename_receipts_read.mailboxer_engine.rb (renamed from db/migrate/20140428223809_rename_receipts_read.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140429074424_add_global_notification_support.mailboxer_engine.rb (renamed from db/migrate/20140428223810_add_global_notification_support.mailboxer_engine.rb)0
-rw-r--r--db/migrate/20140429074426_create_delayed_jobs.rb (renamed from db/migrate/20140428223812_create_delayed_jobs.rb)0
-rw-r--r--db/migrate/20140429074430_create_servers.rb (renamed from db/migrate/20140428223815_create_servers.rb)0
-rw-r--r--db/migrate/20140429074434_create_matches.rb (renamed from db/migrate/20140428223819_create_matches.rb)2
-rw-r--r--db/migrate/20140429074437_create_teams.rb (renamed from db/migrate/20140428223823_create_teams.rb)0
-rw-r--r--db/migrate/20140429074441_create_alerts.rb (renamed from db/migrate/20140428223827_create_alerts.rb)0
-rw-r--r--db/migrate/20140429074445_create_pms.rb (renamed from db/migrate/20140428223830_create_pms.rb)0
-rw-r--r--db/migrate/20140429074449_create_tournaments.rb (renamed from db/migrate/20140428223834_create_tournaments.rb)0
-rw-r--r--db/migrate/20140429074453_create_games.rb (renamed from db/migrate/20140428223838_create_games.rb)0
-rw-r--r--db/migrate/20140429074456_create_users.rb (renamed from db/migrate/20140428223842_create_users.rb)0
-rw-r--r--db/migrate/20140429074500_create_sessions.rb (renamed from db/migrate/20140428223845_create_sessions.rb)0
-rw-r--r--db/migrate/20140429074504_create_brackets.rb (renamed from db/migrate/20140428223849_create_brackets.rb)0
-rw-r--r--db/migrate/20140429074508_create_game_settings.rb (renamed from db/migrate/20140428223853_create_game_settings.rb)0
-rw-r--r--db/migrate/20140429074511_create_tournament_settings.rb (renamed from db/migrate/20140428223856_create_tournament_settings.rb)0
-rw-r--r--db/migrate/20140429074515_create_tournament_stages.rb (renamed from db/migrate/20140428223900_create_tournament_stages.rb)0
-rw-r--r--db/migrate/20140429074519_create_statistics.rb (renamed from db/migrate/20140428223903_create_statistics.rb)0
-rw-r--r--db/migrate/20140429074522_create_remote_usernames.rb (renamed from db/migrate/20140428223907_create_remote_usernames.rb)0
-rw-r--r--db/migrate/20140429074526_create_bracket_matches.rb (renamed from db/migrate/20140428223911_create_bracket_matches.rb)0
-rw-r--r--db/migrate/20140429074530_create_api_requests.rb (renamed from db/migrate/20140428223914_create_api_requests.rb)0
-rw-r--r--db/migrate/20140429074533_create_tournament_players_join_table.rb (renamed from db/migrate/20140428223918_create_tournament_players_join_table.rb)0
-rw-r--r--db/migrate/20140429074537_create_tournament_hosts_join_table.rb (renamed from db/migrate/20140428223922_create_tournament_hosts_join_table.rb)0
-rw-r--r--db/migrate/20140429074540_create_team_user_join_table.rb (renamed from db/migrate/20140428223925_create_team_user_join_table.rb)0
-rw-r--r--db/migrate/20140429074544_create_match_team_join_table.rb (renamed from db/migrate/20140428223929_create_match_team_join_table.rb)0
-rw-r--r--db/migrate/20140429074555_add_hidden_attrs_to_user.rb (renamed from db/migrate/20140428223939_add_hidden_attrs_to_user.rb)0
-rw-r--r--db/schema.rb4
-rw-r--r--db/seeds.rb263
-rwxr-xr-xgenerate.sh2
-rw-r--r--lib/scheduling/elimination.rb2
-rw-r--r--lib/scheduling/round_robin.rb2
-rw-r--r--lib/scoring/fibonacci_peer_with_blowout.rb10
-rw-r--r--test/controllers/matches_controller_test.rb4
-rw-r--r--test/fixtures/matches.yml4
49 files changed, 372 insertions, 220 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb
index d2dc918..e944983 100644
--- a/app/controllers/matches_controller.rb
+++ b/app/controllers/matches_controller.rb
@@ -88,7 +88,8 @@ class MatchesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def match_params
- params.require(:match).permit(:status, :tournament_stage_id, :winner_id, :remote_id, :submitted_peer_evaluations, :update_action)
+ params.require(:match).permit(:status, :tournament_stage_id, :winner_id)
+ params.require(:match).permit(:status, :tournament_stage_id, :winner_id)
end
# Turn of check_edit, since our #update is flexible
diff --git a/app/models/game.rb b/app/models/game.rb
index c5cb32a..d5622af 100644
--- a/app/models/game.rb
+++ b/app/models/game.rb
@@ -1,7 +1,45 @@
class Game < ActiveRecord::Base
belongs_to :parent, class_name: "Game"
+
has_many :children, class_name: "Game"
- has_many :game_settings
+ has_many :game_settings
+ validates_associated :game_settings
alias_attribute :settings, :game_settings
+
+ validates(:name,
+ presence: true,
+ length: {minimum: 5},
+ uniqueness: {case_sensitive: true})
+
+ validates(:min_players_per_team,
+ presence: true,
+ numericality: {
+ only_integer: true,
+ less_than_or_equal_to: :max_players_per_team,
+ })
+ validates(:max_players_per_team,
+ presence: true,
+ numericality: {
+ only_integer: true,
+ greater_than_or_equal_to: :min_players_per_team,
+ })
+
+ validates(:min_teams_per_match,
+ presence: true,
+ numericality: {
+ only_integer: true,
+ less_than_or_equal_to: :max_teams_per_match,
+ })
+ validates(:max_teams_per_match,
+ presence: true,
+ numericality: {
+ only_integer: true,
+ greater_than_or_equal_to: :min_teams_per_match,
+ })
+
+ validate :validate_scoring_method
+ def validate_scoring_method
+ (not self.scoring_method.try(:empty?)) and (Tournament.scoring_methods.include? scoring_method)
+ end
end
diff --git a/app/models/game_setting.rb b/app/models/game_setting.rb
index e701cae..40ab32f 100644
--- a/app/models/game_setting.rb
+++ b/app/models/game_setting.rb
@@ -3,6 +3,17 @@ class GameSetting < ActiveRecord::Base
alias_attribute :value, :default
+ validates(:vartype, presence: true, numericality: {only_integer: true})
+ validates(:type_opt, presence: true, if: :needs_type_opt?)
+
+ def needs_type_opt?
+ [
+ GameSetting.types[:pick_one_radio],
+ GameSetting.types[:pick_one_dropdown],
+ GameSetting.types[:pick_several],
+ ].include? self.vartype
+ end
+
def self.types
return {
:text_short => 0,
diff --git a/app/models/match.rb b/app/models/match.rb
index 85084f5..7b36777 100644
--- a/app/models/match.rb
+++ b/app/models/match.rb
@@ -5,6 +5,18 @@ class Match < ActiveRecord::Base
belongs_to :winner, class_name: "Team"
+ # status:integer
+ before_save { self.status ||= 0 }
+
+ # tournament_stage:references
+ validates_presence_of :tournament_stage
+
+ # winner:references
+ # not validated
+
+ ##
+ # Returns whether or not all the statistics have been collected
+ # such that the match may be considered finished.
def finished?
ok = true
tournament_stage.scoring.stats_needed.each do |stat|
@@ -13,26 +25,35 @@ class Match < ActiveRecord::Base
ok
end
- def win?(player)
- winner.players.include? player
- end
-
+ ##
+ # Returns all players involved in this match (from all teams).
def users
ret = []
self.teams.each{|t| ret.concat(t.users)}
return ret
end
+ ##
+ # Given a sampling class (a class that implements the interface
+ # described in `/lib/sampling/README.md`), this returns which
+ # statistics (in an Array of Strings) an instance of the class
+ # should collect.
def stats_from(sampling_class)
figure_sampling_methods.map{|stat,klass| (sampling_class==klass) ? stat : nil}.select{|s| not s.nil?}
end
+ ##
+ # Delagates PUT/PATCH HTTP params to the appropriate sampling
+ # methods.
def handle_sampling(user, params)
method_classes.each do |klass|
klass.new(self).handle_user_interaction(user, params)
end
end
+ ##
+ # Delagates out rendering forms to the appropriate sampling
+ # methods.
def render_sampling(user)
require 'set'
html = ''
@@ -46,6 +67,9 @@ class Match < ActiveRecord::Base
return html.html_safe
end
+ ##
+ # Calls `Sampling#start` on every sampling method that this match
+ # uses.
def start_sampling
method_classes.each do |klass|
klass.new(self).start
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index b867716..8a96dcc 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -1,15 +1,60 @@
class Tournament < ActiveRecord::Base
belongs_to :game
+
has_many :tournament_stages
+ # Don't validate presence of stages; sadly, it seems to break things
+ #validates_presence_of :tournament_stages
+ alias_attribute :stages, :tournament_stages
+
has_many :brackets
+
has_many :tournament_settings
+
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"
+ validates_presence_of :hosts
- alias_attribute :stages, :tournament_stages
+ validates_presence_of :game
before_save { self.status ||= 0 }
+ validates(:name,
+ presence: true,
+ length: {minimum: 5},
+ uniqueness: {case_sensitive: true})
+
+ validates(:min_players_per_team,
+ presence: true,
+ numericality: {
+ only_integer: true,
+ less_than_or_equal_to: :max_players_per_team,
+ })
+ validates(:max_players_per_team,
+ presence: true,
+ numericality: {
+ only_integer: true,
+ greater_than_or_equal_to: :min_players_per_team,
+ })
+
+ validates(:min_teams_per_match,
+ presence: true,
+ numericality: {
+ only_integer: true,
+ less_than_or_equal_to: :max_teams_per_match,
+ })
+ validates(:max_teams_per_match,
+ presence: true,
+ numericality: {
+ only_integer: true,
+ greater_than_or_equal_to: :min_teams_per_match,
+ })
+
+ validate :validate_scoring_method
+ def validate_scoring_method
+ (not self.scoring_method.try(:empty?)) and (scoring_methods.include? scoring_method)
+ end
+
# Settings #################################################################
def settings
@@ -69,16 +114,10 @@ class Tournament < ActiveRecord::Base
end
end
- # Misc. ####################################################################
-
- def open?
- return true
- end
-
# Joining/Leaving ##########################################################
def joinable_by?(user)
- return (open? and user.can?(:join_tournament) and !players.include?(user))
+ return (status==0 and user.can?(:join_tournament) and !players.include?(user))
end
def join(user)
@@ -100,32 +139,42 @@ class Tournament < ActiveRecord::Base
@scoring ||= "Scoring::#{self.scoring_method.camelcase}".constantize
end
- # YISSSSSS
+ # Options for configured methods/modules ###################################
+ # We're conflicted about whether these should be `self.` or not. ###########
- def scoring_methods
+ def self.scoring_methods
make_methods "scoring"
end
+ def scoring_methods
+ self.class.scoring_methods
+ end
def sampling_methods
- make_methods("sampling").select do |name|
+ self.class.make_methods("sampling").select do |name|
"Sampling::#{name.camelcase}".constantize.works_with?(self.game)
end
end
- def scheduling_methods
+ def self.scheduling_methods
make_methods "scheduling"
end
+ def scheduling_methods
+ self.class.scheduling_methods
+ end
- def seeding_methods
+ def self.seeding_methods
make_methods "seeding"
end
+ def seeding_methods
+ self.class.seeding_methods
+ end
private
- def make_methods(dir)
- @@methods ||= {}
- if @@methods[dir].nil? or Rails.env.development?
- @@methods[dir] = Dir.glob("#{Rails.root}/lib/#{dir}/*.rb").map{|filename| File.basename(filename, ".rb") }
+ def self.make_methods(dir)
+ @methods ||= {}
+ if @methods[dir].nil? or Rails.env.development?
+ @methods[dir] = Dir.glob("#{Rails.root}/lib/#{dir}/*.rb").map{|filename| File.basename(filename, ".rb") }
end
- return @@methods[dir]
+ return @methods[dir]
end
end
diff --git a/app/models/tournament_setting.rb b/app/models/tournament_setting.rb
index 9efaaea..20d9842 100644
--- a/app/models/tournament_setting.rb
+++ b/app/models/tournament_setting.rb
@@ -1,6 +1,18 @@
class TournamentSetting < ActiveRecord::Base
belongs_to :tournament
+ validates(:vartype, presence: true, numericality: {only_integer: true})
+ validates(:type_opt, presence: true, if: :needs_type_opt?)
+
+ def needs_type_opt?
+ [
+ GameSetting.types[:pick_one_radio],
+ GameSetting.types[:pick_one_dropdown],
+ GameSetting.types[:pick_several],
+ ].include? self.vartype
+ end
+
+
def self.types
GameSetting.types
end
diff --git a/app/models/tournament_stage.rb b/app/models/tournament_stage.rb
index 19b9c23..72aa14c 100644
--- a/app/models/tournament_stage.rb
+++ b/app/models/tournament_stage.rb
@@ -1,7 +1,17 @@
class TournamentStage < ActiveRecord::Base
belongs_to :tournament
+ validates_presence_of :tournament
+
has_many :matches
+ validates(:scheduling_method,
+ presence: true,
+ inclusion: {in: Tournament.new.scheduling_methods})
+
+ validates(:seeding_method,
+ presence: true,
+ inclusion: {in: Tournament.new.seeding_methods})
+
# A 1-indexed hash of matches
def matches_ordered
h = {}
diff --git a/app/models/user.rb b/app/models/user.rb
index b2c7862..a39037c 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,6 +1,7 @@
class User < ActiveRecord::Base
- before_save :default_values
-
+ ##################################################################
+ # Relationships #
+ ##################################################################
has_and_belongs_to_many :tournaments_played, class_name: "Tournament", foreign_key: "player_id", join_table: "players_tournaments"
has_and_belongs_to_many :tournaments_hosted, class_name: "Tournament", foreign_key: "host_id", join_table: "hosts_tournaments"
has_and_belongs_to_many :teams
@@ -8,20 +9,49 @@ class User < ActiveRecord::Base
has_many :statistics
has_many :remote_usernames
- apply_simple_captcha
+ ##################################################################
+ # Attributes #
+ ##################################################################
- acts_as_messageable
+ # name:string
+ validates(:name, presence: true, length: { maximum: 50 })
+ # email:string:uniq
+ before_save { self.email = email.downcase }
+ validates(:email,
+ presence: true,
+ format: {with: /\A\S+@\S+\.\S+\z/i},
+ uniqueness: { case_sensitive: false })
+
+ # user_name:string_uniq
+ validates(:user_name,
+ presence: true,
+ length:{maximum: 50},
+ format: {with: /\A[a-zA-Z0-9 _\-]+\z/},
+ uniqueness: {case_sensitive: false })
+
+ # password_digest:string
+ has_secure_password validations: false # maps :password and :password_confirmation to :password_digest
+ validates(:password,
+ length: { minimum: 6 },
+ confirmation: true,
+ unless: Proc.new { |u| u.password.try(:empty?) and not u.password_digest.try(:empty?) })
+
+ # permissions:integer
+ before_save { self.permissions ||= Server.first.default_user_permissions }
+
+ ##################################################################
+ # XXX: hard-coded-ish. It makes me feel dirty. #
+ ##################################################################
+ apply_simple_captcha
+ acts_as_messageable
def mailboxer_email(object)
return nil
end
- before_save { self.email = email.downcase }
- before_save { self.user_name = user_name }
-
- def default_values
- self.permissions ||= Server.first.default_user_permissions
- end
+ ##################################################################
+ # remote_usernames #
+ ##################################################################
def set_remote_username(game, data)
remote = self.remote_usernames.where(:game => game).first
@@ -46,6 +76,10 @@ class User < ActiveRecord::Base
end
end
+ ##################################################################
+ # Permissions #
+ ##################################################################
+
def self.permission_bits
return {
:create_tournament => (2**1),
@@ -104,7 +138,6 @@ class User < ActiveRecord::Base
end
end
-
# A representation of the permission bits as a mock-array.
def abilities
@abilities ||= Abilities.new(self)
@@ -122,7 +155,7 @@ class User < ActiveRecord::Base
# easy to modify them using a form.
class Abilities
def initialize(user)
- @user = user
+o @user = user
end
def [](ability)
return @user.can?(ability)
@@ -146,40 +179,9 @@ class User < ActiveRecord::Base
end
end
- # VAILD_EMAIL is the regex used to validate a user given email.
- VALID_EMAIL_REG = /\A\S+@\S+\.\S+\z/i
-
- # VALID_USER_NAME checks to make sure a user's user_name
- # is in the proper format.
- VALID_USER_NAME_REG = /\A[a-zA-Z0-9 _\-]+\z/
-
- # The following lines put a user account through a series of
- # validations in order to make sure all of their information
- # is in the proper format.
- #
- # validates :symbol_to_be_validated
- #
- # - presence: determines whether or not a symbol is filled or not
- # - length: ensures there is a length limit on the symbol
- # - format: checks the format of given information to ensure
- # validity
- validates(:name, presence: true, length: { maximum: 50 })
- validates(:email, presence: true, format: {with:
- VALID_EMAIL_REG},
- uniqueness: { case_sensitive: false })
- validates(:user_name, presence: true, length:{maximum: 50},
- format: {with: VALID_USER_NAME_REG },
- uniqueness: {case_sensitive: false })
-
- # Instead of adding password and password_confirmation
- # attributes, requiring the presence of a password,
- # requiring that pw and pw_com match, and add an authenticate
- # method to compare an encrypted password to the
- # password_digest to authenticate users, I can just add
- # has_secure_password which does all of this for me.
- has_secure_password
-
- validates :password, length: { minimum: 6 }
+ ##################################################################
+ # Null-object pattern #
+ ##################################################################
class NilUser
def nil?
diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb
index 9d402b3..a045e98 100644
--- a/app/views/matches/_form.html.erb
+++ b/app/views/matches/_form.html.erb
@@ -12,14 +12,6 @@
<%= f.label :winner_id %><br>
<%= f.text_field :winner_id %>
</div>
- <div class="field">
- <%= f.label :remote_id %><br>
- <%= f.text_area :remote_id %>
- </div>
- <div class="field">
- <%= f.label :submitted_peer_evaluations %><br>
- <%= f.number_field :submitted_peer_evaluations %>
- </div>
<div class="actions">
<%= f.submit %>
</div>
diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder
index bef149d..d5a97fe 100644
--- a/app/views/matches/index.json.jbuilder
+++ b/app/views/matches/index.json.jbuilder
@@ -1,4 +1,4 @@
json.array!(@matches) do |match|
- json.extract! match, :id, :status, :tournament_stage_id, :winner_id, :remote_id, :submitted_peer_evaluations
+ json.extract! match, :id, :status, :tournament_stage_id, :winner_id
json.url match_url(match, format: :json)
end
diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder
index 145f069..dd2cde3 100644
--- a/app/views/matches/show.json.jbuilder
+++ b/app/views/matches/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @match, :id, :status, :tournament_stage_id, :winner_id, :remote_id, :submitted_peer_evaluations, :created_at, :updated_at
+json.extract! @match, :id, :status, :tournament_stage_id, :winner_id, :created_at, :updated_at
diff --git a/db/migrate/20140428183808_create_simple_captcha_data.rb b/db/migrate/20140429034423_create_simple_captcha_data.rb
index 4573b20..4573b20 100644
--- a/db/migrate/20140428183808_create_simple_captcha_data.rb
+++ b/db/migrate/20140429034423_create_simple_captcha_data.rb
diff --git a/db/migrate/20140428223805_create_mailboxer.mailboxer_engine.rb b/db/migrate/20140429074419_create_mailboxer.mailboxer_engine.rb
index 690cec2..690cec2 100644
--- a/db/migrate/20140428223805_create_mailboxer.mailboxer_engine.rb
+++ b/db/migrate/20140429074419_create_mailboxer.mailboxer_engine.rb
diff --git a/db/migrate/20140428223806_add_notified_object.mailboxer_engine.rb b/db/migrate/20140429074420_add_notified_object.mailboxer_engine.rb
index 7f41ac6..7f41ac6 100644
--- a/db/migrate/20140428223806_add_notified_object.mailboxer_engine.rb
+++ b/db/migrate/20140429074420_add_notified_object.mailboxer_engine.rb
diff --git a/db/migrate/20140428223807_add_notification_code.mailboxer_engine.rb b/db/migrate/20140429074421_add_notification_code.mailboxer_engine.rb
index 04c12ef..04c12ef 100644
--- a/db/migrate/20140428223807_add_notification_code.mailboxer_engine.rb
+++ b/db/migrate/20140429074421_add_notification_code.mailboxer_engine.rb
diff --git a/db/migrate/20140428223808_add_attachments.mailboxer_engine.rb b/db/migrate/20140429074422_add_attachments.mailboxer_engine.rb
index b8d6588..b8d6588 100644
--- a/db/migrate/20140428223808_add_attachments.mailboxer_engine.rb
+++ b/db/migrate/20140429074422_add_attachments.mailboxer_engine.rb
diff --git a/db/migrate/20140428223809_rename_receipts_read.mailboxer_engine.rb b/db/migrate/20140429074423_rename_receipts_read.mailboxer_engine.rb
index 9ce904f..9ce904f 100644
--- a/db/migrate/20140428223809_rename_receipts_read.mailboxer_engine.rb
+++ b/db/migrate/20140429074423_rename_receipts_read.mailboxer_engine.rb
diff --git a/db/migrate/20140428223810_add_global_notification_support.mailboxer_engine.rb b/db/migrate/20140429074424_add_global_notification_support.mailboxer_engine.rb
index 60f67ab..60f67ab 100644
--- a/db/migrate/20140428223810_add_global_notification_support.mailboxer_engine.rb
+++ b/db/migrate/20140429074424_add_global_notification_support.mailboxer_engine.rb
diff --git a/db/migrate/20140428223812_create_delayed_jobs.rb b/db/migrate/20140429074426_create_delayed_jobs.rb
index ec0dd93..ec0dd93 100644
--- a/db/migrate/20140428223812_create_delayed_jobs.rb
+++ b/db/migrate/20140429074426_create_delayed_jobs.rb
diff --git a/db/migrate/20140428223815_create_servers.rb b/db/migrate/20140429074430_create_servers.rb
index fbe1b02..fbe1b02 100644
--- a/db/migrate/20140428223815_create_servers.rb
+++ b/db/migrate/20140429074430_create_servers.rb
diff --git a/db/migrate/20140428223819_create_matches.rb b/db/migrate/20140429074434_create_matches.rb
index bac92d1..d80db5f 100644
--- a/db/migrate/20140428223819_create_matches.rb
+++ b/db/migrate/20140429074434_create_matches.rb
@@ -4,8 +4,6 @@ class CreateMatches < ActiveRecord::Migration
t.integer :status
t.references :tournament_stage, index: true
t.references :winner, index: true
- t.text :remote_id
- t.integer :submitted_peer_evaluations
t.timestamps
end
diff --git a/db/migrate/20140428223823_create_teams.rb b/db/migrate/20140429074437_create_teams.rb
index dd8397d..dd8397d 100644
--- a/db/migrate/20140428223823_create_teams.rb
+++ b/db/migrate/20140429074437_create_teams.rb
diff --git a/db/migrate/20140428223827_create_alerts.rb b/db/migrate/20140429074441_create_alerts.rb
index 68a8e10..68a8e10 100644
--- a/db/migrate/20140428223827_create_alerts.rb
+++ b/db/migrate/20140429074441_create_alerts.rb
diff --git a/db/migrate/20140428223830_create_pms.rb b/db/migrate/20140429074445_create_pms.rb
index eb9f443..eb9f443 100644
--- a/db/migrate/20140428223830_create_pms.rb
+++ b/db/migrate/20140429074445_create_pms.rb
diff --git a/db/migrate/20140428223834_create_tournaments.rb b/db/migrate/20140429074449_create_tournaments.rb
index f3715bb..f3715bb 100644
--- a/db/migrate/20140428223834_create_tournaments.rb
+++ b/db/migrate/20140429074449_create_tournaments.rb
diff --git a/db/migrate/20140428223838_create_games.rb b/db/migrate/20140429074453_create_games.rb
index e841667..e841667 100644
--- a/db/migrate/20140428223838_create_games.rb
+++ b/db/migrate/20140429074453_create_games.rb
diff --git a/db/migrate/20140428223842_create_users.rb b/db/migrate/20140429074456_create_users.rb
index 8032870..8032870 100644
--- a/db/migrate/20140428223842_create_users.rb
+++ b/db/migrate/20140429074456_create_users.rb
diff --git a/db/migrate/20140428223845_create_sessions.rb b/db/migrate/20140429074500_create_sessions.rb
index f667f1e..f667f1e 100644
--- a/db/migrate/20140428223845_create_sessions.rb
+++ b/db/migrate/20140429074500_create_sessions.rb
diff --git a/db/migrate/20140428223849_create_brackets.rb b/db/migrate/20140429074504_create_brackets.rb
index 8813bf2..8813bf2 100644
--- a/db/migrate/20140428223849_create_brackets.rb
+++ b/db/migrate/20140429074504_create_brackets.rb
diff --git a/db/migrate/20140428223853_create_game_settings.rb b/db/migrate/20140429074508_create_game_settings.rb
index 06fb72e..06fb72e 100644
--- a/db/migrate/20140428223853_create_game_settings.rb
+++ b/db/migrate/20140429074508_create_game_settings.rb
diff --git a/db/migrate/20140428223856_create_tournament_settings.rb b/db/migrate/20140429074511_create_tournament_settings.rb
index e56697f..e56697f 100644
--- a/db/migrate/20140428223856_create_tournament_settings.rb
+++ b/db/migrate/20140429074511_create_tournament_settings.rb
diff --git a/db/migrate/20140428223900_create_tournament_stages.rb b/db/migrate/20140429074515_create_tournament_stages.rb
index 6e52bf0..6e52bf0 100644
--- a/db/migrate/20140428223900_create_tournament_stages.rb
+++ b/db/migrate/20140429074515_create_tournament_stages.rb
diff --git a/db/migrate/20140428223903_create_statistics.rb b/db/migrate/20140429074519_create_statistics.rb
index 09a435f..09a435f 100644
--- a/db/migrate/20140428223903_create_statistics.rb
+++ b/db/migrate/20140429074519_create_statistics.rb
diff --git a/db/migrate/20140428223907_create_remote_usernames.rb b/db/migrate/20140429074522_create_remote_usernames.rb
index e265985..e265985 100644
--- a/db/migrate/20140428223907_create_remote_usernames.rb
+++ b/db/migrate/20140429074522_create_remote_usernames.rb
diff --git a/db/migrate/20140428223911_create_bracket_matches.rb b/db/migrate/20140429074526_create_bracket_matches.rb
index 3323e31..3323e31 100644
--- a/db/migrate/20140428223911_create_bracket_matches.rb
+++ b/db/migrate/20140429074526_create_bracket_matches.rb
diff --git a/db/migrate/20140428223914_create_api_requests.rb b/db/migrate/20140429074530_create_api_requests.rb
index 544c330..544c330 100644
--- a/db/migrate/20140428223914_create_api_requests.rb
+++ b/db/migrate/20140429074530_create_api_requests.rb
diff --git a/db/migrate/20140428223918_create_tournament_players_join_table.rb b/db/migrate/20140429074533_create_tournament_players_join_table.rb
index be240e8..be240e8 100644
--- a/db/migrate/20140428223918_create_tournament_players_join_table.rb
+++ b/db/migrate/20140429074533_create_tournament_players_join_table.rb
diff --git a/db/migrate/20140428223922_create_tournament_hosts_join_table.rb b/db/migrate/20140429074537_create_tournament_hosts_join_table.rb
index 7521d89..7521d89 100644
--- a/db/migrate/20140428223922_create_tournament_hosts_join_table.rb
+++ b/db/migrate/20140429074537_create_tournament_hosts_join_table.rb
diff --git a/db/migrate/20140428223925_create_team_user_join_table.rb b/db/migrate/20140429074540_create_team_user_join_table.rb
index f3b57fc..f3b57fc 100644
--- a/db/migrate/20140428223925_create_team_user_join_table.rb
+++ b/db/migrate/20140429074540_create_team_user_join_table.rb
diff --git a/db/migrate/20140428223929_create_match_team_join_table.rb b/db/migrate/20140429074544_create_match_team_join_table.rb
index c2ed1b7..c2ed1b7 100644
--- a/db/migrate/20140428223929_create_match_team_join_table.rb
+++ b/db/migrate/20140429074544_create_match_team_join_table.rb
diff --git a/db/migrate/20140428223939_add_hidden_attrs_to_user.rb b/db/migrate/20140429074555_add_hidden_attrs_to_user.rb
index 9b5c505..9b5c505 100644
--- a/db/migrate/20140428223939_add_hidden_attrs_to_user.rb
+++ b/db/migrate/20140429074555_add_hidden_attrs_to_user.rb
diff --git a/db/schema.rb b/db/schema.rb
index c5032fa..1186a7f 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: 20140428223939) do
+ActiveRecord::Schema.define(version: 20140429074555) do
create_table "alerts", force: true do |t|
t.integer "author_id"
@@ -111,8 +111,6 @@ ActiveRecord::Schema.define(version: 20140428223939) do
t.integer "status"
t.integer "tournament_stage_id"
t.integer "winner_id"
- t.text "remote_id"
- t.integer "submitted_peer_evaluations"
t.datetime "created_at"
t.datetime "updated_at"
end
diff --git a/db/seeds.rb b/db/seeds.rb
index 910727e..adc740f 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -3,136 +3,148 @@
#
# Examples:
#
-# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
-# Mayor.create(name: 'Emanuel', city: cities.first)
+# cities = City.create!([{ name: 'Chicago' }, { name: 'Copenhagen' }])
+# Mayor.create!(name: 'Emanuel', city: cities.first)
#
p = User.permission_bits
-Server.create(default_user_permissions: p[:join_tournament] | p[:create_pm] | p[:edit_pm] | p[:create_bracket])
+Server.create!(default_user_permissions: p[:join_tournament] | p[:create_pm] | p[:edit_pm] | p[:create_bracket])
-league = Game.create(name: "League of Legends", min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 2, max_teams_per_match: 2)
-league.settings.create(display_order: 1, name: "map" , description: "Select a map to play on.", vartype: GameSetting::types[:pick_one_dropdown], type_opt: "summoners_rift,twisted_treeline,crystal_scar,haunted_abyss", default: "summoners_rift")
-league.settings.create(display_order: 2, name: "pick_type", description: "Select a pick type." , vartype: GameSetting::types[:pick_one_dropdown], type_opt: "blind_pick,draft" , default: "draft")
+league = Game.create!(name: "League of Legends", min_players_per_team: 5, max_players_per_team: 5, min_teams_per_match: 2, max_teams_per_match: 2)
+league.settings.create!(display_order: 1, name: "map" , description: "Select a map to play on.", vartype: GameSetting::types[:pick_one_dropdown], type_opt: "summoners_rift,twisted_treeline,crystal_scar,haunted_abyss", default: "summoners_rift")
+league.settings.create!(display_order: 2, name: "pick_type", description: "Select a pick type." , vartype: GameSetting::types[:pick_one_dropdown], type_opt: "blind_pick,draft" , default: "draft")
-chess = Game.create(name: "Chess", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2)
-chess.settings.create(display_order: 1, name: "time_control", description: "Enter a value for Time Control (ie. 5-5, 30, 6hr, or None)", vartype: GameSetting::types[:text_short], default: "")
+chess = Game.create!(name: "Chess", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2)
+chess.settings.create!(display_order: 1, name: "time_control", description: "Enter a value for Time Control (ie. 5-5, 30, 6hr, or None)", vartype: GameSetting::types[:text_short], default: "")
-hearthstone = Game.create(name: "Hearthstone", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2)
-hearthstone.settings.create(display_order: 1, name: "deck_name", description: "Enter a name for your deck, be descriptive.", vartype: GameSetting::types[:text_long], default: "")
+hearthstone = Game.create!(name: "Hearthstone", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, max_teams_per_match: 2)
+hearthstone.settings.create!(display_order: 1, name: "deck_name", description: "Enter a name for your deck, be descriptive.", vartype: GameSetting::types[:text_long], default: "")
-rockpaperscissors = Game.create(name: "Rock, Paper, Scissors", min_players_per_team: 1, max_players_per_team: 3, min_teams_per_match: 2, max_teams_per_match: 2)
-rockpaperscissors.settings.create(display_order: 4, name: "lizard_spock_allowed", description: "Will you allow Lizard and Spock?" , vartype: GameSetting::types[:true_false] , default: false)
-rockpaperscissors.settings.create(display_order: 5, name: "favorite_object" , description: "What is your favorite object in RPS?", vartype: GameSetting::types[:pick_one_radio], type_opt: "rock,paper,scissors", default: "rock")
-rockpaperscissors.settings.create(display_order: 6, name: "check_boxes" , description: "Example boxes" , vartype: GameSetting::types[:pick_several] , type_opt: "i_do_not_know,there_is_now_spoon,wow,because_electricity,wat?", default: "wow,wat?")
+rockpaperscissors = Game.create!(name: "Rock, Paper, Scissors", min_players_per_team: 1, max_players_per_team: 3, min_teams_per_match: 2, max_teams_per_match: 2)
+rockpaperscissors.settings.create!(display_order: 4, name: "lizard_spock_allowed", description: "Will you allow Lizard and Spock?" , vartype: GameSetting::types[:true_false] , default: false)
+rockpaperscissors.settings.create!(display_order: 5, name: "favorite_object" , description: "What is your favorite object in RPS?", vartype: GameSetting::types[:pick_one_radio], type_opt: "rock,paper,scissors", default: "rock")
+rockpaperscissors.settings.create!(display_order: 6, name: "check_boxes" , description: "Example boxes" , vartype: GameSetting::types[:pick_several] , type_opt: "i_do_not_know,there_is_now_spoon,wow,because_electricity,wat?", default: "wow,wat?")
if Rails.env.development?
# User 1, the ADMIN
- User.create(name: "Administrator", user_name: "admin", email: "root@localhost.lan", password: "password", password_confirmation: "password", permissions: 0xFFFFFFFF)
+ admin = User.create!(name: "Administrator", user_name: "admin", email: "root@localhost.lan", password: "password", permissions: 0xFFFFFFFF)
# John Doe's for testing
- User.create(name: "John 0", password: "password", email: "john0@gmail.com", user_name: "johndoe0", password_confirmation: "password")
- User.create(name: "John 1", password: "password", email: "john1@gmail.com", user_name: "johndoe1", password_confirmation: "password")
- User.create(name: "John 2", password: "password", email: "john2@gmail.com", user_name: "johndoe2", password_confirmation: "password")
- User.create(name: "John 3", password: "password", email: "john3@gmail.com", user_name: "johndoe3", password_confirmation: "password")
- User.create(name: "John 4", password: "password", email: "john4@gmail.com", user_name: "johndoe4", password_confirmation: "password")
- User.create(name: "John 5", password: "password", email: "john5@gmail.com", user_name: "johndoe5", password_confirmation: "password")
- User.create(name: "John 6", password: "password", email: "john6@gmail.com", user_name: "johndoe6", password_confirmation: "password")
- User.create(name: "John 7", password: "password", email: "john7@gmail.com", user_name: "johndoe7", password_confirmation: "password")
- User.create(name: "John 8", password: "password", email: "john8@gmail.com", user_name: "johndoe8", password_confirmation: "password")
- User.create(name: "John 9", password: "password", email: "john9@gmail.com", user_name: "johndoe9", password_confirmation: "password")
+ User.create!(name: "John 0", password: "password", email: "john0@gmail.com", user_name: "johndoe0")
+ User.create!(name: "John 1", password: "password", email: "john1@gmail.com", user_name: "johndoe1")
+ User.create!(name: "John 2", password: "password", email: "john2@gmail.com", user_name: "johndoe2")
+ User.create!(name: "John 3", password: "password", email: "john3@gmail.com", user_name: "johndoe3")
+ User.create!(name: "John 4", password: "password", email: "john4@gmail.com", user_name: "johndoe4")
+ User.create!(name: "John 5", password: "password", email: "john5@gmail.com", user_name: "johndoe5")
+ User.create!(name: "John 6", password: "password", email: "john6@gmail.com", user_name: "johndoe6")
+ User.create!(name: "John 7", password: "password", email: "john7@gmail.com", user_name: "johndoe7")
+ User.create!(name: "John 8", password: "password", email: "john8@gmail.com", user_name: "johndoe8")
+ User.create!(name: "John 9", password: "password", email: "john9@gmail.com", user_name: "johndoe9")
# Users for mocked Riot API calls
players_for_league = []
- players_for_league.push(User.create(name: "Sytrie" , password: "password", email: "Sytrie@gmail.com" , user_name: "Sytrie" , password_confirmation: "password"))
- players_for_league.push(User.create(name: "Derpanator115" , password: "password", email: "Derpanator115@gmail.com" , user_name: "Derpanator115" , password_confirmation: "password"))
- players_for_league.push(User.create(name: "Wlknexe56" , password: "password", email: "Wlknexe56@gmail.com" , user_name: "Wlknexe56" , password_confirmation: "password"))
- players_for_league.push(User.create(name: "DVisionzz" , password: "password", email: "DVisionzz@gmail.com" , user_name: "DVisionzz" , password_confirmation: "password"))
- players_for_league.push(User.create(name: "HYP3RTONIC" , password: "password", email: "HYP3RTONIC@gmail.com" , user_name: "HYP3RTONIC" , password_confirmation: "password"))
- players_for_league.push(User.create(name: "M9Fumjaa" , password: "password", email: "M9Fumjaa@gmail.com" , user_name: "M9Fumjaa" , password_confirmation: "password"))
- players_for_league.push(User.create(name: "spikevsnaruto" , password: "password", email: "spikevsnaruto@gmail.com" , user_name: "spikevsnaruto" , password_confirmation: "password"))
- players_for_league.push(User.create(name: "GoogleMaSkills" , password: "password", email: "GoogleMaSkills@gmail.com" , user_name: "GoogleMaSkills" , password_confirmation: "password"))
- players_for_league.push(User.create(name: "james chamberlan", password: "password", email: "jameschamberlan@gmail.com", user_name: "james chamberlan", password_confirmation: "password"))
- players_for_league.push(User.create(name: "Kaceytron" , password: "password", email: "Kaceytron@gmail.com" , user_name: "Kaceytron" , password_confirmation: "password"))
+ players_for_league.push(User.create!(name: "Sytrie" , password: "password", email: "Sytrie@gmail.com" , user_name: "Sytrie" ))
+ players_for_league.push(User.create!(name: "Derpanator115" , password: "password", email: "Derpanator115@gmail.com" , user_name: "Derpanator115" ))
+ players_for_league.push(User.create!(name: "Wlknexe56" , password: "password", email: "Wlknexe56@gmail.com" , user_name: "Wlknexe56" ))
+ players_for_league.push(User.create!(name: "DVisionzz" , password: "password", email: "DVisionzz@gmail.com" , user_name: "DVisionzz" ))
+ players_for_league.push(User.create!(name: "HYP3RTONIC" , password: "password", email: "HYP3RTONIC@gmail.com" , user_name: "HYP3RTONIC" ))
+ players_for_league.push(User.create!(name: "M9Fumjaa" , password: "password", email: "M9Fumjaa@gmail.com" , user_name: "M9Fumjaa" ))
+ players_for_league.push(User.create!(name: "spikevsnaruto" , password: "password", email: "spikevsnaruto@gmail.com" , user_name: "spikevsnaruto" ))
+ players_for_league.push(User.create!(name: "GoogleMaSkills" , password: "password", email: "GoogleMaSkills@gmail.com" , user_name: "GoogleMaSkills" ))
+ players_for_league.push(User.create!(name: "james chamberlan", password: "password", email: "jameschamberlan@gmail.com", user_name: "james chamberlan"))
+ players_for_league.push(User.create!(name: "Kaceytron" , password: "password", email: "Kaceytron@gmail.com" , user_name: "Kaceytron" ))
# Semi-real users
- guntas = User.create(name: "Guntas Grewal" , password: "password", email: "guntasgrewal@gmail.com" , user_name: "guntasgrewal", password_confirmation: "password")
- luke = User.create(name: "Luke Shumaker" , password: "password", email: "lukeshu@emacs4lyfe.com" , user_name: "lukeshu" , password_confirmation: "password")
- tomer = User.create(name: "Tomer Kimia" , password: "password", email: "tomer@2majors4lyfe.com" , user_name: "tkimia" , password_confirmation: "password")
- josh = User.create(name: "Josh Huser" , password: "password", email: "jhuser@iownabusiness.net" , user_name: "WinterWorks" , password_confirmation: "password")
- dunsmore = User.create(name: "Professor Dunsmore", password: "password", email: "bxd@purdue.edu" , user_name: "Dumbledore" , password_confirmation: "password")
- marco = User.create(name: "Marco Polo" , password: "password", email: "marco@ta4lyfe.com" , user_name: "iCoordinate" , password_confirmation: "password")
- jordan = User.create(name: "Geoffrey Webb" , password: "password", email: "imnotjoffreybarathian@gameofthrones.com", user_name: "GTBPhoenix" , password_confirmation: "password")
- obama = User.create(name: "Obama" , password: "password", email: "obama@whitehouse.gov" , user_name: "Obama" , password_confirmation: "password")
-
- g = Array.new
-
- davis = User.create(name: "Davis Webb" , password: "password", email: "davislwebb@gmail.com" , user_name: "TeslasMind" , password_confirmation: "password")
- foy = User.create(name: "Nathaniel Foy" , password: "password", email: "nfoy@purdue.edu" , user_name: "NalfeinX" , password_confirmation: "password")
- andrew = User.create(name: "Andrew Murrell" , password: "password", email: "murrel@murrel.gov" , user_name: "ImFromNasa" , password_confirmation: "password")
- joey = User.create(name: "Joseph Adams" , password: "password", email: "alpha142@fluttershyop.com" , user_name: "alpha142" , password_confirmation: "password")
- panda = User.create(name: "Panda" , password: "password", email: "panda@gmail.com" , user_name: "InspectorPanderp" , password_confirmation: "password")
- mesa = User.create(name: "Mesataki" , password: "password", email: "mesataki@gmail.com" , user_name: "Mesakati" , password_confirmation: "password")
- guntas_league = User.create(name: "TolkiensButt" , password: "password", email: "TolkiensButt@gmail.com" , user_name: "TolkiensButt" , password_confirmation: "password")
- lyra = User.create(name: "Lyra Heartstings" , password: "password", email: "LyraHeartstings@gmail.com" , user_name: "Lyra Heartstings" , password_confirmation: "password")
- josh_league = User.create(name: "Josh_league" , password: "password", email: "josh_league@gmail.com" , user_name: "Joshoowah" , password_confirmation: "password")
- jeff = User.create(name: "Jeff Linguinee" , password: "password", email: "jefflingueeneeeee@gmail.com" , user_name: "SenorJeffafa" , password_confirmation: "password")
- sarah = User.create(name: "Sarah Lawson" , password: "password", email: "sarah@gmail.com" , user_name: "LittlexSurah" , password_confirmation: "password")
-
+ guntas = User.create(name: "Guntas Grewal" , password: "password", email: "guntasgrewal@gmail.com" , user_name: "guntasgrewal")
+ luke = User.create(name: "Luke Shumaker" , password: "password", email: "lukeshu@emacs4lyfe.com" , user_name: "lukeshu" )
+ tomer = User.create(name: "Tomer Kimia" , password: "password", email: "tomer@2majors4lyfe.com" , user_name: "tkimia" )
+ josh = User.create(name: "Josh Huser" , password: "password", email: "jhuser@iownabusiness.net" , user_name: "WinterWorks" )
+ dunsmore = User.create(name: "Professor Dunsmore", password: "password", email: "bxd@purdue.edu" , user_name: "Dumbledore" )
+ marco = User.create(name: "Marco Polo" , password: "password", email: "marco@ta4lyfe.com" , user_name: "iCoordinate" )
+ jordan = User.create(name: "Geoffrey Webb" , password: "password", email: "imnotjoffreybarathian@gameofthrones.com", user_name: "GTBPhoenix" )
+ obama = User.create(name: "Obama" , password: "password", email: "obama@whitehouse.gov" , user_name: "Obama" )
+
+ davis = User.create(name: "Davis Webb" , password: "password", email: "davislwebb@gmail.com" , user_name: "TeslasMind" )
+ foy = User.create(name: "Nathaniel Foy" , password: "password", email: "nfoy@purdue.edu" , user_name: "NalfeinX" )
+ andrew = User.create(name: "Andrew Murrell" , password: "password", email: "murrel@murrel.gov" , user_name: "ImFromNasa" )
+ joey = User.create(name: "Joseph Adams" , password: "password", email: "alpha142@fluttershyop.com" , user_name: "alpha142" )
+ panda = User.create(name: "Panda" , password: "password", email: "panda@gmail.com" , user_name: "InspectorPanderp" )
+ mesa = User.create(name: "Mesataki" , password: "password", email: "mesataki@gmail.com" , user_name: "Mesakati" )
+ guntas_league = User.create(name: "TolkiensButt" , password: "password", email: "TolkiensButt@gmail.com" , user_name: "TolkiensButt" )
+ lyra = User.create(name: "Lyra Heartstings" , password: "password", email: "LyraHeartstings@gmail.com" , user_name: "Lyra Heartstings" )
+ josh_league = User.create(name: "Josh_league" , password: "password", email: "josh_league@gmail.com" , user_name: "Joshoowah" )
+ jeff = User.create(name: "Jeff Linguinee" , password: "password", email: "jefflingueeneeeee@gmail.com" , user_name: "SenorJeffafa" )
+ sarah = User.create(name: "Sarah Lawson" , password: "password", email: "sarah@gmail.com" , user_name: "LittlexSurah" )
# League of Legends tournament
- league_tourn = Tournament.create(game: league, name: "League of Legends Seed",
- min_players_per_team: 5, max_players_per_team: 5,
- min_teams_per_match: 2, max_teams_per_match: 2,
- scoring_method: "winner_takes_all")
-
- league_tourn.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding")
-
- league_tourn.hosts.push(User.find(1))
+ league_tourn = Tournament.create!(
+ game: league,
+ name: "League of Legends Seed",
+ min_players_per_team: 5,
+ max_players_per_team: 5,
+ min_teams_per_match: 2,
+ max_teams_per_match: 2,
+ scoring_method: "winner_takes_all",
+ hosts: [admin])
+ league_tourn.stages.create!(scheduling_method: "round_robin" , seeding_method: "random_seeding")
players_for_league.each do |player|
league_tourn.join(player)
end
# Chess
- chess_tourn = Tournament.create(game: chess, name: "Chess Seed",
- min_players_per_team: 1, max_players_per_team: 1,
- min_teams_per_match: 2, max_teams_per_match: 2,
- scoring_method: "winner_takes_all")
-
- chess_tourn.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding")
-
- chess_tourn.hosts.push(davis)
+ chess_tourn = Tournament.create!(
+ game: chess,
+ name: "Chess Seed",
+ min_players_per_team: 1,
+ max_players_per_team: 1,
+ min_teams_per_match: 2,
+ max_teams_per_match: 2,
+ scoring_method: "winner_takes_all",
+ hosts: [davis])
+ chess_tourn.stages.create!(scheduling_method: "round_robin" , seeding_method: "random_seeding")
chess_tourn.join(davis)
chess_tourn.join(foy)
# Rock Paper Scissors
- rps = Tournament.create(game: rockpaperscissors, name: "Rock, Paper, Scissors Seed",
- min_players_per_team: 1, max_players_per_team: 3,
- min_teams_per_match: 2, max_teams_per_match: 2,
- scoring_method: "winner_takes_all")
- rps.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding")
- rps.hosts.push(davis)
+ rps = Tournament.create!(
+ game: rockpaperscissors,
+ name: "Rock, Paper, Scissors Seed",
+ min_players_per_team: 1,
+ max_players_per_team: 3,
+ min_teams_per_match: 2,
+ max_teams_per_match: 2,
+ scoring_method: "winner_takes_all",
+ hosts: [davis])
+ rps.stages.create!(scheduling_method: "round_robin" , seeding_method: "random_seeding")
rps.join(davis)
rps.join(foy)
rps.join(guntas)
# Another League tournament
- tourn5 = Tournament.create(game: league, name: "5 Teams, 2 Teams Per Match",
- min_players_per_team: 1, max_players_per_team: 1,
- min_teams_per_match: 2, max_teams_per_match: 2,
- scoring_method: "winner_takes_all")
- tourn5.hosts.push(User.find(1))
+ tourn5 = Tournament.create!(
+ game: league,
+ name: "5 Teams, 2 Teams Per Match",
+ min_players_per_team: 1,
+ max_players_per_team: 1,
+ min_teams_per_match: 2,
+ max_teams_per_match: 2,
+ scoring_method: "winner_takes_all",
+ hosts: [admin])
+ tourn5.stages.create!(scheduling_method: "elimination" , seeding_method: "random_seeding")
players_for_league.each do |player|
tourn5.join(player)
end
- tourn5.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding")
# Yet another League tournament
- tourn6 = Tournament.create(game_id: 1, name: "3 teams per match",
- min_players_per_team: 1, max_players_per_team: 1,
- min_teams_per_match: 3, max_teams_per_match: 3,
- scoring_method: "winner_takes_all")
-
- tourn6.hosts.push(User.find(1))
- tourn6.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding")
+ tourn6 = Tournament.create!(
+ game_id: 1,
+ name: "3 teams per match",
+ min_players_per_team: 1,
+ max_players_per_team: 1,
+ min_teams_per_match: 3,
+ max_teams_per_match: 3,
+ scoring_method: "winner_takes_all",
+ hosts: [admin])
+ tourn6.stages.create!(scheduling_method: "round_robin" , seeding_method: "random_seeding")
players_for_league.each do |player|
tourn6.join(player)
end
@@ -146,41 +158,44 @@ if Rails.env.development?
tourn6.join(joey)
#Hearthstone tournament
- hearth = Tournament.create(game: hearthstone, name: "Hearthstone Seed", min_teams_per_match: 1, min_players_per_team: 1,
- max_teams_per_match: 2, max_players_per_team: 1, scoring_method: "winner_takes_all")
- hearth.hosts.push(User.find(1))
-
+ hearth = Tournament.create!(
+ game: hearthstone,
+ name: "Hearthstone Seed",
+ min_teams_per_match: 1,
+ min_players_per_team: 1,
+ max_teams_per_match: 2,
+ max_players_per_team: 1,
+ scoring_method: "winner_takes_all",
+ hosts: [admin])
+ hearth.stages.create!(scheduling_method: "round_robin" , seeding_method: "random_seeding")
hearth.join(davis)
hearth.join(foy)
- hearth.stages.create(scheduling_method: "round_robin" , seeding_method: "random_seeding")
-
#THE REAL GAME WE ARE PLAYING AT 10
- davis.remote_usernames.create(game: league, value: {"name" => "TeslasMind", "id" => 30533514} )
- foy.remote_usernames.create(game: league, value: {"name" => "NalfeinX", "id" => 29538130} )
- andrew.remote_usernames.create(game: league, value: {"name" => "ImFromNasa", "id" => 29782091} )
- joey.remote_usernames.create(game: league, value: {"name" => "Alpha142", "id" => 29732514} )
- sarah.remote_usernames.create(game: league, value: {"name" => "LittlexSurah", "id" => 30613787} )
- mesa.remote_usernames.create(game: league, value: {"name" => "Mesakati", "id" => 51552042 } )
- panda.remote_usernames.create(game: league, value: {"name" => "NalfeinX", "id" => 47953989} )
- jordan.remote_usernames.create(game: league, value: {"name" => "GTBPhoenix", "id" => 29812020} )
- josh_league.remote_usernames.create(game: league, value: {"name" => "Joshoowah", "id" => 26083333} )
- jeff.remote_usernames.create(game: league, value: {"name" => "SenorJeffafa", "id" => 32612067} )
- lyra.remote_usernames.create(game: league, value: {"name" => "Lyra Heartstings", "id" => 32240762} )
-
- g.push(davis, joey, panda, mesa, lyra, jordan, jeff, sarah, foy, andrew)
-
- custom = Tournament.create(game: league, name: "Real League Game",
- min_players_per_team: 5, max_players_per_team: 5,
- min_teams_per_match: 2, max_teams_per_match: 2,
- scoring_method: "winner_takes_all")
-
- custom.hosts.push(User.find(1))
-
- custom.stages.create(scheduling_method: "round_robin" , seeding_method: "early_bird_seeding")
-
-
- custom.hosts.push(User.find(1))
+ davis.remote_usernames.create( game: league, value: {"name" => "TeslasMind" , "id" => 30533514} )
+ foy.remote_usernames.create( game: league, value: {"name" => "NalfeinX" , "id" => 29538130} )
+ andrew.remote_usernames.create( game: league, value: {"name" => "ImFromNasa" , "id" => 29782091} )
+ joey.remote_usernames.create( game: league, value: {"name" => "Alpha142" , "id" => 29732514} )
+ sarah.remote_usernames.create( game: league, value: {"name" => "LittlexSurah" , "id" => 30613787} )
+ mesa.remote_usernames.create( game: league, value: {"name" => "Mesakati" , "id" => 51552042} )
+ panda.remote_usernames.create( game: league, value: {"name" => "NalfeinX" , "id" => 47953989} )
+ jordan.remote_usernames.create( game: league, value: {"name" => "GTBPhoenix" , "id" => 29812020} )
+ josh_league.remote_usernames.create(game: league, value: {"name" => "Joshoowah" , "id" => 26083333} )
+ jeff.remote_usernames.create( game: league, value: {"name" => "SenorJeffafa" , "id" => 32612067} )
+ lyra.remote_usernames.create( game: league, value: {"name" => "Lyra Heartstings", "id" => 32240762} )
+
+ g = [davis, joey, panda, mesa, lyra, jordan, jeff, sarah, foy, andrew]
+
+ custom = Tournament.create!(
+ game: league,
+ name: "Real League Game",
+ min_players_per_team: 5,
+ max_players_per_team: 5,
+ min_teams_per_match: 2,
+ max_teams_per_match: 2,
+ scoring_method: "winner_takes_all",
+ hosts: [admin])
+ custom.stages.create!(scheduling_method: "round_robin" , seeding_method: "early_bird_seeding")
g.each do |player|
custom.join(player)
end
diff --git a/generate.sh b/generate.sh
index ffcde4b..3a9d738 100755
--- a/generate.sh
+++ b/generate.sh
@@ -40,7 +40,7 @@ bundle exec rails generate delayed_job:active_record
# The whole shebang, models, views, and controllers
bundle exec rails generate scaffold server default_user_permissions:integer
-bundle exec rails generate scaffold match status:integer tournament_stage:references winner:references remote_id:text submitted_peer_evaluations:integer
+bundle exec rails generate scaffold match status:integer tournament_stage:references winner:references
bundle exec rails generate scaffold team
bundle exec rails generate scaffold alert author:references message:text
bundle exec rails generate scaffold pm author:references recipient:references message:text subject:text conversation:references
diff --git a/lib/scheduling/elimination.rb b/lib/scheduling/elimination.rb
index 73aefb4..44ce81e 100644
--- a/lib/scheduling/elimination.rb
+++ b/lib/scheduling/elimination.rb
@@ -11,7 +11,7 @@ module Scheduling
num_teams = (tournament.players.count/tournament.min_players_per_team).floor
num_matches = (Float(num_teams - tournament.min_teams_per_match)/(tournament.min_teams_per_match - 1)).ceil + 1
for i in 1..num_matches
- tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0)
+ tournament_stage.matches.create
end
match_num = num_matches-1
diff --git a/lib/scheduling/round_robin.rb b/lib/scheduling/round_robin.rb
index c0d68d3..7ee617d 100644
--- a/lib/scheduling/round_robin.rb
+++ b/lib/scheduling/round_robin.rb
@@ -20,7 +20,7 @@ module Scheduling
# => Create new matches
@matches_per_round.times do
- tournament_stage.matches.create(status: 0, submitted_peer_evaluations: 0)
+ tournament_stage.matches.create
end
# => seed the first time
diff --git a/lib/scoring/fibonacci_peer_with_blowout.rb b/lib/scoring/fibonacci_peer_with_blowout.rb
index 21ffab1..f592540 100644
--- a/lib/scoring/fibonacci_peer_with_blowout.rb
+++ b/lib/scoring/fibonacci_peer_with_blowout.rb
@@ -1,13 +1,19 @@
module Scoring
module FibonacciPeerWithBlowout
def self.stats_needed
- return [:votes]
+ return [:votes, :win, :blowout]
end
def self.score(match)
scores = {}
match.players.each do |player|
- scores[player] = self.score_user(match.statistics.where(user: player, name: :votes).first, match.win?(player), match.blowout)
+ stats = Statistics.where(user: player, match: match)
+
+ votes = stats.where(name: :votes ).first
+ win = stats.where(name: :win ).first
+ blowout = stats.where(name: :blowout).first
+
+ scores[player] = self.score_user(votes, win, blowout)
end
scores
end
diff --git a/test/controllers/matches_controller_test.rb b/test/controllers/matches_controller_test.rb
index d4ac1ed..69cbff5 100644
--- a/test/controllers/matches_controller_test.rb
+++ b/test/controllers/matches_controller_test.rb
@@ -18,7 +18,7 @@ class MatchesControllerTest < ActionController::TestCase
test "should create match" do
assert_difference('Match.count') do
- post :create, match: { remote_id: @match.remote_id, status: @match.status, submitted_peer_evaluations: @match.submitted_peer_evaluations, tournament_stage_id: @match.tournament_stage_id, winner_id: @match.winner_id }
+ post :create, match: { status: @match.status, tournament_stage_id: @match.tournament_stage_id, winner_id: @match.winner_id }
end
assert_redirected_to match_path(assigns(:match))
@@ -35,7 +35,7 @@ class MatchesControllerTest < ActionController::TestCase
end
test "should update match" do
- patch :update, id: @match, match: { remote_id: @match.remote_id, status: @match.status, submitted_peer_evaluations: @match.submitted_peer_evaluations, tournament_stage_id: @match.tournament_stage_id, winner_id: @match.winner_id }
+ patch :update, id: @match, match: { status: @match.status, tournament_stage_id: @match.tournament_stage_id, winner_id: @match.winner_id }
assert_redirected_to match_path(assigns(:match))
end
diff --git a/test/fixtures/matches.yml b/test/fixtures/matches.yml
index 4213238..2a995c7 100644
--- a/test/fixtures/matches.yml
+++ b/test/fixtures/matches.yml
@@ -4,12 +4,8 @@ one:
status: 1
tournament_stage_id:
winner_id:
- remote_id: MyText
- submitted_peer_evaluations: 1
two:
status: 1
tournament_stage_id:
winner_id:
- remote_id: MyText
- submitted_peer_evaluations: 1