diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/match.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 14 | ||||
-rw-r--r-- | app/views/matches/show.html.erb | 2 |
3 files changed, 12 insertions, 6 deletions
diff --git a/app/models/match.rb b/app/models/match.rb index 20a36a5..9045d67 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -1,6 +1,6 @@ class Match < ActiveRecord::Base belongs_to :tournament_stage - has_many :scores + has_many :statistics has_and_belongs_to_many :teams belongs_to :winner, class_name: "Team" diff --git a/app/models/user.rb b/app/models/user.rb index e5ae7ea..d87f988 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -23,17 +23,23 @@ class User < ActiveRecord::Base self.permissions ||= Server.first.default_user_permissions end - def scores - self.statistics.find_by_name(:score) + def set_remote_username(game, data) + remote = self.remote_usernames.where(:game => game).first + if remote.nil? + self.remote_usernames.create(game: game, value: data) + else + remote.value = data + remote.save + end end - def find_remote_username(game) + def get_remote_username(game) obj = self.remote_usernames.where(:game => game).first if obj.nil? if game.parent.nil? return nil else - return find_remote_username(game.parent) + return get_remote_username(game.parent) end else return obj.value diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index 2ec0ea6..7a82527 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -47,7 +47,7 @@ function score_peers() { <% if @match.status <= 1 %> <li><%= user.user_name %></li> <% else %> - <% score = Statistic.where(:name => "score", :user => user, :match => @match).first%> + <% score = user.statistics.where(:name => "score", :match => @match).first %> <li><%= user.user_name %> - SCORE: <%= score ? score.value : 0 %></li> <% end %> <% end %> |