From c87dbe49d521683900c20a9425a96467fa631489 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Sun, 27 Apr 2014 20:39:13 -0400 Subject: Seeding Algorithms now create teams. --- lib/seeding/early_bird_seeding.rb | 2 +- lib/seeding/fair_ranked_seeding.rb | 3 +++ lib/seeding/random_seeding.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/seeding/early_bird_seeding.rb b/lib/seeding/early_bird_seeding.rb index f3fc6f9..cb24415 100644 --- a/lib/seeding/early_bird_seeding.rb +++ b/lib/seeding/early_bird_seeding.rb @@ -7,7 +7,7 @@ module Seeding teams = 0 tournament.players.each_slice(tournament.min_players_per_team) do |slice| if teams < tournament.min_teams_per_match - match.teams[teams].players += slice + match.teams.push Team.create(players: slice) teams += 1 else match_num += 1 diff --git a/lib/seeding/fair_ranked_seeding.rb b/lib/seeding/fair_ranked_seeding.rb index 22c245e..6531c43 100644 --- a/lib/seeding/fair_ranked_seeding.rb +++ b/lib/seeding/fair_ranked_seeding.rb @@ -5,6 +5,9 @@ module Seeding match = matches.first match_num = 0 players_used = 0 + (tournament.players.count/tournament.min_players_per_team).floor.times do + match.teams.push Team.create() + end best_first(tournament).each_slice(tournament.min_teams_per_match) do |slice| (0..tournament.min_teams_per_match-1).each do |index| match.teams[index].players += slice[index] diff --git a/lib/seeding/random_seeding.rb b/lib/seeding/random_seeding.rb index bc332ef..65979bc 100644 --- a/lib/seeding/random_seeding.rb +++ b/lib/seeding/random_seeding.rb @@ -7,7 +7,7 @@ module Seeding teams = 0 tournament.players.shuffle.each_slice(tournament.min_players_per_team) do |slice| if teams < tournament.min_teams_per_match - match.teams[teams].players += slice + match.teams.push Team.create(players: slice) teams += 1 else match_num += 1 -- cgit v1.2.3 From 17169088974477c2702377a5ea3e14afff62e009 Mon Sep 17 00:00:00 2001 From: nfoy Date: Sun, 27 Apr 2014 23:05:26 -0400 Subject: Fixed conversations. --- app/views/pms/index.html.erb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb index a1feb42..056b371 100644 --- a/app/views/pms/index.html.erb +++ b/app/views/pms/index.html.erb @@ -11,7 +11,7 @@ - <% if conversations.reject { |c| c.is_unread?(current_user) && (c.receipts_for current_user).last.message.sender != current_user }.empty? %> + <%# if conversations.reject { |c| c.is_unread?(current_user) && (c.receipts_for current_user).last.message.sender != current_user }.empty? %> With @@ -38,9 +38,9 @@ <% end %> <% end %> - <% else %> -

No unread conversations

- <% end %> + <%# else %> + + <%# end %> @@ -53,7 +53,7 @@ - <% if conversations.reject { |c| c.is_read?(current_user) || (c.receipts_for current_user).last.message.sender == current_user }.empty? %> + <%# if conversations.reject { |c| c.is_read?(current_user) || (c.receipts_for current_user).last.message.sender == current_user }.empty? %> With @@ -80,8 +80,8 @@ <% end %> <% end %> - <% else %> -

No unread conversations

- <% end %> + <% #else %> + + <% #end %> \ No newline at end of file -- cgit v1.2.3 From b35fa4b6f79d13d46eab4c9ba9e631eeb20ba73b Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Sun, 27 Apr 2014 23:15:31 -0400 Subject: replaced getStatistic with focused where --- app/models/match.rb | 9 ++++++++- app/views/tournaments/standings.html.erb | 4 ++-- lib/seeding/fair_ranked_seeding.rb | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/match.rb b/app/models/match.rb index 9045d67..e817b71 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -6,7 +6,14 @@ class Match < ActiveRecord::Base belongs_to :winner, class_name: "Team" def setup() - + end + + def finished? + ok = true + tournament_stage.scoring_method.stats_needed.each do |stat| + ok &= statistics.where(match: self, name: stat).nil? + end + ok end def is_match_over(match, firstPlayer) diff --git a/app/views/tournaments/standings.html.erb b/app/views/tournaments/standings.html.erb index b8739de..a04e132 100644 --- a/app/views/tournaments/standings.html.erb +++ b/app/views/tournaments/standings.html.erb @@ -1,7 +1,7 @@ -<% playerscores = @tournament.players.collect {|player| player => @tournament.statistics.getStatistic(player.matches.last, player, :score) } %> +<% playerscores = @tournament.players.collect {|player| player => @tournament.statistics.where(match: player.matches.last, user: player, name: :score) } %> <% teams = tournament_stage.matches.collect { |match| match.teams.collect { |team| team.id => team.players.collect -{ |player| player.user_name => @tournament.statistics.getStatistic(player.matches.last, player, :score } } } %> +{ |player| player.user_name => @tournament.statistics.where(match: player.matches.last, user: player, name: :score } } } %> diff --git a/lib/seeding/fair_ranked_seeding.rb b/lib/seeding/fair_ranked_seeding.rb index 6bc62ca..870ebdd 100644 --- a/lib/seeding/fair_ranked_seeding.rb +++ b/lib/seeding/fair_ranked_seeding.rb @@ -33,7 +33,7 @@ module Seeding end def self.previous_score(player, tournament) - score = tournament.statistics.getStatistic(player.matches.last, player, :score) + score = tournament.statistics.where(match: player.matches.last, user: player, name: :score) if score.nil? return 0 end -- cgit v1.2.3 From 6cbf08bb7659dc3265b45d05a66170f1c69ce696 Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Sun, 27 Apr 2014 23:26:00 -0400 Subject: Alerts now have AJAX. Seeds were changed for tournaments to have sampling methods. --- .../javascripts/application/layout.js.coffee | 21 +++ app/assets/stylesheets/custom.css.scss | 4 + app/views/layouts/application.html.erb | 5 +- app/views/tournaments/_form.html.erb | 150 ++++++++++++--------- db/seeds.rb | 8 +- lib/sampling/README.md | 2 +- 6 files changed, 116 insertions(+), 74 deletions(-) create mode 100644 app/assets/javascripts/application/layout.js.coffee diff --git a/app/assets/javascripts/application/layout.js.coffee b/app/assets/javascripts/application/layout.js.coffee new file mode 100644 index 0000000..da0bc67 --- /dev/null +++ b/app/assets/javascripts/application/layout.js.coffee @@ -0,0 +1,21 @@ +json_url = "/alerts.json" + +page_visited = false +starting_size = 0 +update = (alerts) -> + if !page_visited + starting_size = alerts.length + page_visited = true + + if alerts.length > starting_size + $("#alerts-ajax").css("display", "inline"); + return + + setTimeout (-> + $.ajax(url: json_url).done update + return + ), 2000 + +# Now kick off the whole process +window.onload = -> + $.ajax(url: json_url).done update \ No newline at end of file diff --git a/app/assets/stylesheets/custom.css.scss b/app/assets/stylesheets/custom.css.scss index 9e9e63a..b274a0d 100644 --- a/app/assets/stylesheets/custom.css.scss +++ b/app/assets/stylesheets/custom.css.scss @@ -24,6 +24,10 @@ header > nav { } } +#alerts-ajax { + display: none; +} + .btn-custom-orange { color: white; background-color: rgb(255, 69, 0); diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 9eea734..f3535e9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -35,9 +35,8 @@ <%= link_to "Create Alert", new_alert_path, :class => "create-alert" %> <% end %> <%= link_to "Sign out", session_path("current"), method: "delete", :class => "signout" %> - <%= link_to "", alerts_path, :class => "alerts"%> - - + <%# if there is an unread alert then I wanna be able to show the notification icon by saying :style => display:inline. This will be Done by Guntas once he figures out how to get unread alerts. Psuedo if alerts.unread > 0 then display else don't.%> + <%= link_to "", alerts_path, :class => "alerts", :id => "alerts-ajax"%> <% else %> <%= link_to "Log in", new_session_path, :class => "signin" %> <%= link_to "Sign up", new_user_path, :class => "signup" %> diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index 90e0257..d89e0bc 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -1,36 +1,42 @@ <%= render "common/error_messages", :target => @tournament %> -
Attributes -<%= form_for(@tournament, url: new_tournament_path, method: "get") do |f| %> - <%= render "common/error_messages", :target => @tournament %> -

- <%= f.label :game_id, "Select a game type" %> - <%= f.select(:game_id, Game.all.map{|game| [game.name, game.id]}) %> - <%= f.submit("Select") %> -

-<% end %> +
+ + Attributes + + + <%= form_for(@tournament, url: new_tournament_path, method: "get") do |f| %> + <%= render "common/error_messages", :target => @tournament %> +

+ <%= f.label :game_id, "Select a game type" %> + <%= f.select(:game_id, Game.all.map{|game| [game.name, game.id]}) %> + <%= f.submit("Select") %> +

+ <% end %> -<% if @tournament.game.nil? %> -
+ <% if @tournament.game.nil? %> +
<% else %> <%= form_for(@tournament, url: tournaments_path, method: "post") do |f| %> -

<%= f.label :name %> <%= f.text_field :name %>

-

- - - - - - - - - -
MinimumMaximum
Players per team: <%= f.text_field(:min_players_per_team, type: :number, min: 1) %><%= f.text_field(:max_players_per_team, type: :number, min: 1) %>
+ + + + + + + + + + + + + +
MinimumMaximum
Players per team: <%= f.text_field(:min_players_per_team, type: :number, min: 1) %><%= f.text_field(:max_players_per_team, type: :number, min: 1) %>

@@ -56,59 +62,71 @@ <%= f.select(:sampling_method, @tournament.sampling_methods.map{|method| [method.humanize, method]}) %>

- + -
Settings +
+ Settings + <%= f.fields_for :settings do |setting_fields| %> <% @tournament.tournament_settings.each do |setting| %>

<%= setting_fields.label setting.name %>
<% case setting.vartype %> - <% when 0 %> - <%= setting_fields.text_field( setting.name ) %> - <% when 1 %> - <%= setting_fields.text_area( setting.name ) %> - <% when 2 %> -

    - <% setting.type_opt.split(',').each do |option|%> -
  • - <% end %> -
- <% when 3 %> -
    - <% setting.type_opt.split(',').each do |option|%> -
  • - <% end %> -
- <% when 4 %> - <%= setting_fields.radio_button( setting.name, "true" ) %> True - <%= setting_fields.radio_button( setting.name, "false" ) %> False - <% when 5 %> - <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %> + <% when 0 %> + <%= setting_fields.text_field( setting.name ) %> + <% when 1 %> + <%= setting_fields.text_area( setting.name ) %> + <% when 2 %> +
    + <% setting.type_opt.split(',').each do |option|%> +
  • + <% end %> +
+ <% when 3 %> +
    + <% setting.type_opt.split(',').each do |option|%> +
  • + <% end %> +
+ <% when 4 %> + <%= setting_fields.radio_button( setting.name, "true" ) %> True + <%= setting_fields.radio_button( setting.name, "false" ) %> False + <% when 5 %> + <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %> <% end %> -

<% end %> - <% end %> -
- - <%= f.fields_for :stages do |stages_fields| %>
Stages - - - <%# stage_fields.submit("Set Stages") %> - <% for i in 1..(params[:num_stages].to_i) do %> -

- <%= stages_fields.fields_for i.to_s do |stage_fields| %>

Stage <%= i %> - <%= stage_fields.label :scheduling_method %> - <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize, method]}) %> - <%= stage_fields.label :seeding_method %> - <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize, method]}) %> -
<% end %> -

+

<% end %> -
<% end %> +
+ + <%= f.fields_for :stages do |stages_fields| %> +
+ + Stages + + + + + <%# stage_fields.submit("Set Stages") %> + <% for i in 1..(params[:num_stages].to_i) do %> +

+ <%= stages_fields.fields_for i.to_s do |stage_fields| %> +

+ Stage <%= i %> + + <%= stage_fields.label :scheduling_method %> + <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize, method]}) %> + <%= stage_fields.label :seeding_method %> + <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize, method]}) %> +
+ <% end %> +

+ <% end %> +
+ <% end %> <%= f.submit %> - <%# render 'stages' %> - <% end %> <% end %> +<% end %> diff --git a/db/seeds.rb b/db/seeds.rb index c37dcf7..a66cc4b 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -85,7 +85,7 @@ if Rails.env.development? #chess chess_tourn = Tournament.create(game_id: 2, status: 0, name: "Chess Seed", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 2, - max_teams_per_match: 2, sampling_method: nil) + max_teams_per_match: 2, sampling_method: "manual") chess_tourn.hosts.push(davis) chess_tourn.join(davis) @@ -93,7 +93,7 @@ if Rails.env.development? #Rock Paper Scissors rps = Tournament.create(game_id: 4, status: 0, 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, sampling_method: nil) + max_teams_per_match: 2, sampling_method: "manual") rps.hosts.push(davis) rps.join(davis) @@ -101,7 +101,7 @@ if Rails.env.development? rps.join(guntas) tourn5 = Tournament.create(game_id: 1, status: 0, 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, sampling_method: nil) + max_teams_per_match: 2, sampling_method: "manual") for i in 0..9 if i == 0 @@ -112,7 +112,7 @@ if Rails.env.development? tourn5.join(players_for_league[9]) tourn6 = Tournament.create(game_id: 1, status: 0, 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, sampling_method: nil) + max_teams_per_match: 3, sampling_method: "manual") for i in 0..9 if i == 0 diff --git a/lib/sampling/README.md b/lib/sampling/README.md index bde84cd..3d564da 100644 --- a/lib/sampling/README.md +++ b/lib/sampling/README.md @@ -11,7 +11,7 @@ interface: - `can_get?(User, String setting_name) => Fixnum` - Returns whether or nat this sampling method can get a specifed + Returns whether or not this sampling method can get a specifed statistic; 0 means 'false', positive integers mean 'true', where higher numbers are higher priority. -- cgit v1.2.3 From d38f6fa6262803f3c6380a43f32de4889fcacaec Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Sun, 27 Apr 2014 23:41:09 -0400 Subject: Fixed an end with a _form and we fixed some other erros --- app/views/tournaments/_form.html.erb | 5 ++--- lib/sampling/peer_review.rb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index 90e0257..986bc70 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -13,7 +13,6 @@ <% else %> <%= form_for(@tournament, url: tournaments_path, method: "post") do |f| %> -

<%= f.label :name %> <%= f.text_field :name %> @@ -48,7 +47,7 @@

<%= f.label :scoring_method %> - <%= f.select(:scoring_method, @tournament.scoring_methods.map{|method| [method.humanize, method]}) %> + <%= f.select(:scoring_method, @tournament.scoring_methods.map{|method| [method.humanize.titleize, method]}) %>

@@ -84,7 +83,7 @@ <%= setting_fields.radio_button( setting.name, "true" ) %> True <%= setting_fields.radio_button( setting.name, "false" ) %> False <% when 5 %> - <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %> + <%= setting_fields.select( setting.name, setting.type_opt.split(',').collect {|opt| opt.humanize.titleize} ) %> <% end %>

<% end %> <% end %> diff --git a/lib/sampling/peer_review.rb b/lib/sampling/peer_review.rb index cbbd2f9..5ae4e81 100644 --- a/lib/sampling/peer_review.rb +++ b/lib/sampling/peer_review.rb @@ -76,6 +76,6 @@ module Sampling end return ret - endx + end end end -- cgit v1.2.3 From 919ba959bbc782315b0a8b171aa96e2118a43067 Mon Sep 17 00:00:00 2001 From: tkimia Date: Mon, 28 Apr 2014 00:00:47 -0400 Subject: fixed the db seeds. They can now be started --- app/models/match.rb | 1 + app/views/common/_show_tournament.html.erb | 6 ++++-- db/seeds.rb | 11 ++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/match.rb b/app/models/match.rb index d4c0ce5..ff81d68 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -12,6 +12,7 @@ class Match < ActiveRecord::Base ok = true tournament_stage.scoring_method.stats_needed.each do |stat| ok &= statistics.where(match: self, name: stat).nil? + end ok end diff --git a/app/views/common/_show_tournament.html.erb b/app/views/common/_show_tournament.html.erb index 151e5d2..12a7fea 100644 --- a/app/views/common/_show_tournament.html.erb +++ b/app/views/common/_show_tournament.html.erb @@ -33,8 +33,10 @@ <% else %>

You've signed up for this tournament!

<% end %> - <%= form_tag(tournament_brackets_path(target), method: "post") do %> - <%= submit_tag("Make Bracket") %> + <% if target.status == 1 %> + <%= form_tag(tournament_brackets_path(target), method: "post") do %> + <%= submit_tag("Make Bracket") %> + <% end %> <% end %> <% end %> diff --git a/db/seeds.rb b/db/seeds.rb index a66cc4b..ea0338d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -95,6 +95,7 @@ if Rails.env.development? rps = Tournament.create(game_id: 4, status: 0, 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, sampling_method: "manual") + rps.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding") rps.hosts.push(davis) rps.join(davis) rps.join(foy) @@ -109,6 +110,7 @@ if Rails.env.development? end tourn5.join(players_for_league[i]) end + tourn5.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding") tourn5.join(players_for_league[9]) tourn6 = Tournament.create(game_id: 1, status: 0, name: "3 teams per match", min_players_per_team: 1, max_players_per_team: 1, min_teams_per_match: 3, @@ -120,6 +122,7 @@ if Rails.env.development? end tourn6.join(players_for_league[i]) end + tourn6.stages.create(scheduling_method: "elimination" , seeding_method: "random_seeding") tourn6.join(players_for_league[9]) tourn6.join(davis) tourn6.join(foy) @@ -138,7 +141,13 @@ if Rails.env.development? hash4 = {:username => "NalfeinX", :id => id} hash5 = {:username => "GTBPhoenix", :id => id} hash6 = {:username => , :id => id} - hash7 = {:username => username, :id => id} + hash7 = {:username => username, :id => id}ages.first.create_matchesages.first.create_matches +end +if success +format.html { redirect_to @tournament, +end +if success +format.html { redirect_to @tournament, hash8 = {:username => username, :id => id} hash9 = {:username => username, :id => id} hash10 = {:username => username, :id => id} -- cgit v1.2.3