diff options
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | Gemfile.lock | 4 | ||||
-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 | ||||
-rw-r--r-- | config/application.example.yml | 3 | ||||
-rw-r--r-- | config/initializers/secret_token.rb | 6 |
8 files changed, 33 insertions, 8 deletions
@@ -15,7 +15,13 @@ /log/*.log /tmp -# The above is from Rails. The following is from Luke. +# The above is from Rails. + +# The next lines are from `rails generate figaro:install` +# Ignore application configuration +/config/application.yml + +# The rest is from Luke. /vendor/bundle nohup.out # As noted above, you probably want to add the following to your global git config. @@ -52,6 +52,8 @@ gem 'delayed_job_active_record' # Mailboxer supports a messaging and alerting system. gem 'mailboxer' +gem 'figaro' + group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 145a7fc..2de3fea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,6 +50,9 @@ GEM delayed_job (>= 3.0, < 4.1) erubis (2.7.0) execjs (2.0.2) + figaro (0.7.0) + bundler (~> 1.0) + rails (>= 3, < 5) foreigner (1.6.1) activerecord (>= 3.0.0) hike (1.2.3) @@ -143,6 +146,7 @@ DEPENDENCIES coffee-rails (~> 4.0.0) daemons delayed_job_active_record + figaro httparty jbuilder (~> 1.2) jquery-rails 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 %> diff --git a/config/application.example.yml b/config/application.example.yml new file mode 100644 index 0000000..a98b40e --- /dev/null +++ b/config/application.example.yml @@ -0,0 +1,3 @@ +SECRET_TOKEN: 'cc884af613d0dd093f1d6c9153abac1200c5a0db923613245b80c5c3f5e9c9f9ba51712b702f2d494a22ddea8ab40601b38a41eb39eec97b50a7a2e37748b1bc' +RIOT_API_KEY: 'ad539f86-22fd-474d-9279-79a7a296ac38' +RIOT_API_REGION: 'na' diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 604d43d..fbab4b9 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -9,4 +9,8 @@ # Make sure your secret_key_base is kept private # if you're sharing your code publicly. -Leaguer::Application.config.secret_key_base = 'cc884af613d0dd093f1d6c9153abac1200c5a0db923613245b80c5c3f5e9c9f9ba51712b702f2d494a22ddea8ab40601b38a41eb39eec97b50a7a2e37748b1bc' +Leaguer::Application.config.secret_key_base = if Rails.env.development? or Rails.env.test? + ('x' * 30) # meets minimum requirement of 30 chars long +else + ENV['SECRET_TOKEN'] +end |