From 33fcf6de9feaaa6f90dfe5082e08d280c930dae1 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 28 Apr 2014 00:04:30 -0400 Subject: Re-jigger the sampling interface --- app/models/match.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app') diff --git a/app/models/match.rb b/app/models/match.rb index c2df6e0..1edac8f 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -9,6 +9,16 @@ class Match < ActiveRecord::Base winner.players.include? player end + def users + ret = [] + self.teams.each{|t| ret.concat(t.users)} + return ret + end + + def stats_from(sampling_class) + # TODO + end + def handle_sampling(params) # TODO end -- cgit v1.2.3 From 952387be24043e76dfd9b7a461ee31d1246fa58e Mon Sep 17 00:00:00 2001 From: nfoy Date: Mon, 28 Apr 2014 00:07:57 -0400 Subject: Messages and alerts play together more nicely now. --- app/views/pms/index.html.erb | 69 +++++++++++++++++++++++++++++++++++++------- app/views/pms/show.html.erb | 1 + 2 files changed, 60 insertions(+), 10 deletions(-) (limited to 'app') diff --git a/app/views/pms/index.html.erb b/app/views/pms/index.html.erb index 056b371..fec6db2 100644 --- a/app/views/pms/index.html.erb +++ b/app/views/pms/index.html.erb @@ -23,6 +23,9 @@ <% if conversation.is_unread?(current_user) && receipts.last.message.sender != current_user %> <% message = receipts.last.message %> + <% if conversation.subject == "Pay Attention!" %> + <% conversation.mark_as_read(current_user) %> + <% end %> <% people = conversation.participants %> <% people.each do |person| %> @@ -65,17 +68,63 @@ <% if conversation.is_read?(current_user) || receipts.last.message.sender == current_user %> <% message = receipts.last.message %> - - <% people = conversation.participants %> - <% people.each do |person| %> - <% unless person == current_user %> - <%= truncate(person.user_name, length: 20) %> + <% if conversation.subject != "Pay Attention!" %> + + <% people = conversation.participants %> + <% people.each do |person| %> + <% unless person == current_user %> + <%= truncate(person.user_name, length: 20) %> + <% end %> <% end %> - <% end %> - - <%= truncate(conversation.subject, length: 30) %> - <%= truncate(message.body, length: 42) %> - <%= link_to 'View', @pms.find_by(conversation: conversation) %> + + <%= truncate(conversation.subject, length: 30) %> + <%= truncate(message.body, length: 42) %> + <%= link_to 'View', @pms.find_by(conversation: conversation) %> + <% end %> + + <% end %> + <% end %> + + <% #else %> + + <% #end %> + + + +
+

Alerts

+<% conversations = current_user.mailbox.conversations %> + + + + + + + <%# if conversations.reject { |c| c.is_read?(current_user) || (c.receipts_for current_user).last.message.sender == current_user }.empty? %> + + + + + + + <% conversations.each do |conversation| %> + <% receipts = conversation.receipts_for current_user %> + <% if conversation.is_read?(current_user) || receipts.last.message.sender == current_user %> + <% message = receipts.last.message %> + + <% if conversation.subject == "Pay Attention!" %> + + + + + <% end %> <% end %> <% end %> diff --git a/app/views/pms/show.html.erb b/app/views/pms/show.html.erb index ca8d9bf..2c93102 100644 --- a/app/views/pms/show.html.erb +++ b/app/views/pms/show.html.erb @@ -31,6 +31,7 @@

________________________________________________

+ <% @pm.message = "" %> <%= form_for(@pm) do |f| %>

<%= f.text_area :message %> -- cgit v1.2.3 From ee238dbbca6ee979aa886a4f4cebad41e6f79cce Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Mon, 28 Apr 2014 00:17:33 -0400 Subject: 30 minutes to add a single line --- app/views/tournaments/_form.html.erb | 1 + 1 file changed, 1 insertion(+) (limited to 'app') diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb index 2a871ea..a5eba7a 100644 --- a/app/views/tournaments/_form.html.erb +++ b/app/views/tournaments/_form.html.erb @@ -17,6 +17,7 @@ <% else %> <%= form_for(@tournament, url: tournaments_path, method: "post") do |f| %> + <%= f.hidden_field(:game_id) %>

<%= f.label :name %> <%= f.text_field :name %> -- cgit v1.2.3 From d43213dfcf1f1d73d76ae2d2aa59cee3597c06da Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 28 Apr 2014 00:25:18 -0400 Subject: implement most of the TODOs in Match --- app/models/match.rb | 63 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/models/match.rb b/app/models/match.rb index fa15980..460e7c4 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -27,18 +27,73 @@ class Match < ActiveRecord::Base end def stats_from(sampling_class) - # TODO + figure_sampling_methods.map{|stat,klass| (sampling_class==klass) ? stat : nil}.select{|s| not s.nil?} end - def handle_sampling(params) - # TODO + def handle_sampling(user, params) + method_classes.each do |klass| + klass.new(self).handle_user_interaction(user, params) + end end def render_sampling(user) - # TODO + require 'set' + html = '' + + method_classes.each do |klass| + html += '

' + html += klass.new(self).render_user_interaction(user) + html += '
' + end + + return html.html_safe end def finished? # TODO end + + private + def figure_sampling_methods + if @sampling_methods.nil? + data = {} + needed = self.tournament_stage.scoring.stats_needed + methods_names = self.tournament_stage.tournament.sampling_methods + methods_names.each do |method_name| + method_class = "Sampling::#{sampling_name.camelcase}".constantize + if method_class.works_with(self.tournament_stage.tournament.game) + needed.each do |stat| + data[stat] ||= {} + data[stat][method] = method.can_get?(user, stat) + end + end + end + + needed.each do |stat| + max_val = nil + max_pri = 0 + data[stat].each do |method,priority| + if priority > max_pri + max_val = method + max_pri = priority + end + end + data[stat] = max_val + end + @sampling_methods = data + end + return @sampling_methods + end + + def method_classes + if @method_classes.nil? + data = Set.new + figure_sampling_methods.each do |stat,method| + data.push(method) + end + @method_classes = data + end + return @method_classes + end + end -- cgit v1.2.3 From 0a5242c3a460d0b99be0adc4593774a58b68154a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 28 Apr 2014 00:29:11 -0400 Subject: fix bad merge --- app/models/match.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'app') diff --git a/app/models/match.rb b/app/models/match.rb index 460e7c4..3cbe0da 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -49,10 +49,6 @@ class Match < ActiveRecord::Base return html.html_safe end - def finished? - # TODO - end - private def figure_sampling_methods if @sampling_methods.nil? -- cgit v1.2.3 From fbd258986b41b96a9f901d6be03bcfa9111fe13d Mon Sep 17 00:00:00 2001 From: guntasgrewal Date: Mon, 28 Apr 2014 00:35:47 -0400 Subject: addes ajax for converstaion it doesnt work right now. --- app/assets/javascripts/pms/show.js.coffee | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'app') diff --git a/app/assets/javascripts/pms/show.js.coffee b/app/assets/javascripts/pms/show.js.coffee index e69de29..559513c 100644 --- a/app/assets/javascripts/pms/show.js.coffee +++ b/app/assets/javascripts/pms/show.js.coffee @@ -0,0 +1,25 @@ +json_url = window.location.href.replace(/\.[^/]*$/,'')+".json" + +page_visited_pms = false +starting_size_pms = 0 +update = (pms) -> + if !page_visited_pms + starting_size_pms = pms.conversation.count_messages + page_visited_pms = true + + if pms.convesation.count_messages > starting_size_pms + window.location.reload true + return + + console.log("hey we got here!") + console.log(starting_size_pms) + console.log(pms.convesation.count_messages) + + 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 -- cgit v1.2.3 From aedb959b027e10290a344495b28047437c28e1aa Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Mon, 28 Apr 2014 00:37:13 -0400 Subject: Fixing Errors in lib and hooks into lib --- app/models/tournament_stage.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/tournament_stage.rb b/app/models/tournament_stage.rb index 9352137..caf5a8a 100644 --- a/app/models/tournament_stage.rb +++ b/app/models/tournament_stage.rb @@ -40,6 +40,6 @@ class TournamentStage < ActiveRecord::Base end def seeding - @seeding ||= "Seeding::#{self.seeding_method.camelcase}".constantize.new(self) + @seeding ||= "Seeding::#{self.seeding_method.camelcase}".constantize end end -- cgit v1.2.3
WithSubjectBody
+ <% people = conversation.participants %> + <% people.each do |person| %> + <% unless person == current_user %> + <%= truncate(person.user_name, length: 20) %> + <% end %> + <% end %> + <%= truncate(conversation.subject, length: 30) %><%= truncate(message.body, length: 42) %><%= link_to 'View', @pms.find_by(conversation: conversation) %>