mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Compare commits
42 Commits
circleci-p
...
c0ad06cea7
| Author | SHA1 | Date | |
|---|---|---|---|
| c0ad06cea7 | |||
| ad259f00b5 | |||
| 7ee8abe81a | |||
| cc38c842e0 | |||
| f7ea68da17 | |||
| cb5f0e28ae | |||
| 873e5b9465 | |||
| df6a029ef1 | |||
| 03d884e672 | |||
| e1cba865b0 | |||
| e36de59971 | |||
| 329c01db79 | |||
| 4cdc9e7df1 | |||
| 1f43fdf8fa | |||
| f6aff5a753 | |||
| 3dabc16a82 | |||
| 9d51ef7b51 | |||
| 63b0541aa4 | |||
| 1e30344be8 | |||
| 683b2967af | |||
| 432903e7a9 | |||
| 537eccf04d | |||
| 89a695388a | |||
| 0aea26967a | |||
| 5677f4e944 | |||
| f5ddc6652d | |||
| 987c89b7d5 | |||
| b2ba1901df | |||
| 6c86f25add | |||
| ce063f5faa | |||
| 396e4be5b3 | |||
| 46919a2b1b | |||
| 55d122771c | |||
| e43f3253d4 | |||
| f720de0db6 | |||
| 44c9f947d7 | |||
| ee8d861bee | |||
| bdd80fc1d2 | |||
| db15e79c0f | |||
| 1f5aa304ff | |||
| 4522113396 | |||
| 7327902fe8 |
@@ -1,10 +1,39 @@
|
||||
version: 2
|
||||
workflows: # Define a Workflow running the build job, then the deploy job
|
||||
version: 2
|
||||
build-deploy:
|
||||
jobs:
|
||||
- build
|
||||
- deploy:
|
||||
requires:
|
||||
- build
|
||||
filters:
|
||||
branches:
|
||||
only: master # Only deploys when the commit is on the Master branch
|
||||
jobs:
|
||||
build:
|
||||
machine: true
|
||||
steps:
|
||||
- checkout
|
||||
# start proprietary DB using private Docker image
|
||||
# with credentials stored in the UI
|
||||
- run: |
|
||||
bash bin/run-tests-with-docker.sh
|
||||
bash bin/run-tests-with-docker.sh
|
||||
|
||||
# https://github.com/circleci/circleci-docs/blob/master/jekyll/_cci1/continuous-deployment-with-heroku.md
|
||||
deploy:
|
||||
machine: true
|
||||
steps:
|
||||
- checkout
|
||||
- run: |
|
||||
cat >~/.netrc <<EOF
|
||||
machine api.heroku.com
|
||||
login $HEROKU_EMAIL
|
||||
password $HEROKU_TOKEN
|
||||
machine git.heroku.com
|
||||
login $HEROKU_EMAIL
|
||||
password $HEROKU_TOKEN
|
||||
EOF
|
||||
chmod 600 ~/.netrc # Heroku cli complains about permissions without this
|
||||
heroku git:remote -a wrestlingapp
|
||||
git push heroku master
|
||||
sleep 20s
|
||||
heroku run rake db:migrate --app wrestlingapp
|
||||
21
.travis.yml
21
.travis.yml
@@ -1,21 +0,0 @@
|
||||
sudo: required
|
||||
language: minimal
|
||||
services:
|
||||
- docker
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- docker-ce
|
||||
env:
|
||||
- DOCKER_COMPOSE_VERSION=1.22.0
|
||||
script:
|
||||
- bash bin/run-tests-with-docker.sh
|
||||
deploy:
|
||||
provider: heroku
|
||||
api_key:
|
||||
secure: WQnMF1v9J8n3z+Icx1Sp2tcu5bsIDwuCRgmGSEyFEl0aI3KsFxCpNWKEhHougkBxYRi7XXW1TZGGwRYb5VNf5UVG4xqlgJE7vm4ri3PjU2x/bLJb6tJq+WNrXoJNzfeyRqwXpfOYJT6n3/ak7lsZrVY2zSIuNTdQQ1oVWk33x9KNyr1RS/XmygJDnsG8n7dnz4xUi57F2w3hORVF3Lm3a63F9hoBcZjZUeMHzLPPhG4yySkpBe1oWtFk58ZSyqCSpcpbiQSSCxHiMrlSJ6GDZjUFDe+GIkx/P8by+MP0qcS2dw1w5yPZvsAATe826xP+LmcZX7g2LHJbIDu+ZwisQDbWfhpShvIkgtnhG95fAF7pv+md6VsLf3cTggtOYKHXDGBTO2nHDDuol/W7ZZHiVT5Da52MFdkJ/4TTgzqWmnlDmmJT6nAZKgGp/dcnslUHscwM1nnhJZZqbxbg8tIZ3Q9+hLjh9vikO76ujkIaseJ+fGcpzTl5SvwW7NfINzJPkVZsPQb6tYNs01iKVfLJ8xNKvUswKe3G3nvrbfJahgySZ0+4xDEjQbbaa63RjyOw06DAcN3SgMj0o1w66NGdd1GzloggN0mdUfXkn+mjP3okYh7zgPY1n+ZJ88BQYJoScS790g30pqxR1Tj0uR3+TEd3Qmp7McfXKlMJiMXX2mI=
|
||||
app: wrestlingapp
|
||||
on:
|
||||
repo: jcwimer/wrestlingApp
|
||||
branch: master
|
||||
run: rake db:migrate RAILS_ENV=production
|
||||
9
Gemfile
9
Gemfile
@@ -1,8 +1,8 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
ruby '2.6.5'
|
||||
ruby '3.0.0'
|
||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||
gem 'rails', '6.0.3.2'
|
||||
gem 'rails', '6.1.4.1'
|
||||
# Use sqlite3 as the database for Active Record
|
||||
#gem 'sqlite3', '~> 1.3', '< 1.4', :group => :development
|
||||
gem 'sqlite3', :group => :development
|
||||
@@ -38,7 +38,6 @@ gem 'spring', :group => :development
|
||||
# Use debugger
|
||||
# gem 'debugger', group: [:development, :test]
|
||||
|
||||
|
||||
#Installed by me
|
||||
group :production do
|
||||
gem 'rails_12factor'
|
||||
@@ -48,6 +47,7 @@ group :production do
|
||||
gem 'dalli'
|
||||
end
|
||||
|
||||
gem 'influxdb-rails'
|
||||
gem 'devise'
|
||||
gem 'cancancan'
|
||||
gem 'round_robin_tournament'
|
||||
@@ -63,7 +63,6 @@ group :development do
|
||||
gem 'rubocop'
|
||||
gem 'bullet'
|
||||
gem 'brakeman'
|
||||
gem 'hakiri'
|
||||
gem 'travis'
|
||||
gem 'bundler-audit'
|
||||
end
|
||||
|
||||
|
||||
327
Gemfile.lock
327
Gemfile.lock
@@ -1,71 +1,76 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (6.0.3.2)
|
||||
actionpack (= 6.0.3.2)
|
||||
actioncable (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailbox (6.0.3.2)
|
||||
actionpack (= 6.0.3.2)
|
||||
activejob (= 6.0.3.2)
|
||||
activerecord (= 6.0.3.2)
|
||||
activestorage (= 6.0.3.2)
|
||||
activesupport (= 6.0.3.2)
|
||||
actionmailbox (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activejob (= 6.1.4.1)
|
||||
activerecord (= 6.1.4.1)
|
||||
activestorage (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
mail (>= 2.7.1)
|
||||
actionmailer (6.0.3.2)
|
||||
actionpack (= 6.0.3.2)
|
||||
actionview (= 6.0.3.2)
|
||||
activejob (= 6.0.3.2)
|
||||
actionmailer (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
actionview (= 6.1.4.1)
|
||||
activejob (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (6.0.3.2)
|
||||
actionview (= 6.0.3.2)
|
||||
activesupport (= 6.0.3.2)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
actionpack (6.1.4.1)
|
||||
actionview (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
rack (~> 2.0, >= 2.0.9)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||
actiontext (6.0.3.2)
|
||||
actionpack (= 6.0.3.2)
|
||||
activerecord (= 6.0.3.2)
|
||||
activestorage (= 6.0.3.2)
|
||||
activesupport (= 6.0.3.2)
|
||||
actiontext (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activerecord (= 6.1.4.1)
|
||||
activestorage (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
nokogiri (>= 1.8.5)
|
||||
actionview (6.0.3.2)
|
||||
activesupport (= 6.0.3.2)
|
||||
actionview (6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||
activejob (6.0.3.2)
|
||||
activesupport (= 6.0.3.2)
|
||||
activejob (6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (6.0.3.2)
|
||||
activesupport (= 6.0.3.2)
|
||||
activerecord (6.0.3.2)
|
||||
activemodel (= 6.0.3.2)
|
||||
activesupport (= 6.0.3.2)
|
||||
activestorage (6.0.3.2)
|
||||
actionpack (= 6.0.3.2)
|
||||
activejob (= 6.0.3.2)
|
||||
activerecord (= 6.0.3.2)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (6.0.3.2)
|
||||
activemodel (6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
activerecord (6.1.4.1)
|
||||
activemodel (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
activestorage (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activejob (= 6.1.4.1)
|
||||
activerecord (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
marcel (~> 1.0.0)
|
||||
mini_mime (>= 1.1.0)
|
||||
activesupport (6.1.4.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
zeitwerk (~> 2.2, >= 2.2.2)
|
||||
addressable (2.4.0)
|
||||
ast (2.4.1)
|
||||
backports (3.18.2)
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
tzinfo (~> 2.0)
|
||||
zeitwerk (~> 2.3)
|
||||
ast (2.4.2)
|
||||
bcrypt (3.1.16)
|
||||
brakeman (4.9.1)
|
||||
brakeman (5.1.1)
|
||||
builder (3.2.4)
|
||||
bullet (6.1.0)
|
||||
bullet (6.1.5)
|
||||
activesupport (>= 3.0.0)
|
||||
uniform_notifier (~> 1.11)
|
||||
cancancan (3.1.0)
|
||||
bundler-audit (0.8.0)
|
||||
bundler (>= 1.2.0, < 3)
|
||||
thor (~> 1.0)
|
||||
cancancan (3.3.0)
|
||||
coffee-rails (5.0.0)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 5.2.0)
|
||||
@@ -73,178 +78,130 @@ GEM
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.12.2)
|
||||
commander (4.4.6)
|
||||
highline (~> 1.7.2)
|
||||
concurrent-ruby (1.1.7)
|
||||
concurrent-ruby (1.1.9)
|
||||
crass (1.0.6)
|
||||
daemons (1.3.1)
|
||||
dalli (2.7.10)
|
||||
delayed_job (4.1.8)
|
||||
activesupport (>= 3.0, < 6.1)
|
||||
delayed_job_active_record (4.1.4)
|
||||
activerecord (>= 3.0, < 6.1)
|
||||
daemons (1.4.1)
|
||||
dalli (2.7.11)
|
||||
delayed_job (4.1.9)
|
||||
activesupport (>= 3.0, < 6.2)
|
||||
delayed_job_active_record (4.1.6)
|
||||
activerecord (>= 3.0, < 6.2)
|
||||
delayed_job (>= 3.0, < 5)
|
||||
delayed_job_web (1.4.3)
|
||||
delayed_job_web (1.4.4)
|
||||
activerecord (> 3.0.0)
|
||||
delayed_job (> 2.0.3)
|
||||
rack-protection (>= 1.5.5)
|
||||
sinatra (>= 1.4.4)
|
||||
devise (4.7.2)
|
||||
devise (4.8.0)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
railties (>= 4.1.0)
|
||||
responders
|
||||
warden (~> 1.2.3)
|
||||
domain_name (0.5.20190701)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
erubi (1.9.0)
|
||||
ethon (0.12.0)
|
||||
ffi (>= 1.3.0)
|
||||
execjs (2.7.0)
|
||||
faraday (0.17.3)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday_middleware (0.14.0)
|
||||
faraday (>= 0.7.4, < 1.0)
|
||||
ffi (1.13.1)
|
||||
gh (0.15.1)
|
||||
addressable (~> 2.4.0)
|
||||
backports
|
||||
faraday (~> 0.8)
|
||||
multi_json (~> 1.0)
|
||||
net-http-persistent (~> 2.9)
|
||||
net-http-pipeline
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
hakiri (0.7.2)
|
||||
activesupport
|
||||
bundler
|
||||
commander
|
||||
i18n
|
||||
json
|
||||
rake
|
||||
rest-client
|
||||
terminal-table
|
||||
highline (1.7.10)
|
||||
http-accept (1.7.0)
|
||||
http-cookie (1.0.3)
|
||||
domain_name (~> 0.5)
|
||||
i18n (1.8.5)
|
||||
erubi (1.10.0)
|
||||
execjs (2.8.1)
|
||||
globalid (0.5.2)
|
||||
activesupport (>= 5.0)
|
||||
i18n (1.8.10)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jbuilder (2.10.1)
|
||||
influxdb (0.8.1)
|
||||
influxdb-rails (1.0.2)
|
||||
influxdb (~> 0.6, >= 0.6.4)
|
||||
railties (>= 5.0)
|
||||
jbuilder (2.11.2)
|
||||
activesupport (>= 5.0.0)
|
||||
jquery-rails (4.4.0)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
json (2.3.1)
|
||||
launchy (2.4.3)
|
||||
addressable (~> 2.3)
|
||||
libv8 (3.16.14.19)
|
||||
loofah (2.7.0)
|
||||
libv8 (3.16.14.19-x86_64-linux)
|
||||
loofah (2.12.0)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
marcel (1.0.1)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2020.0512)
|
||||
mimemagic (0.3.5)
|
||||
mini_mime (1.0.2)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.14.2)
|
||||
multi_json (1.15.0)
|
||||
multipart-post (2.1.1)
|
||||
mini_mime (1.1.1)
|
||||
minitest (5.14.4)
|
||||
mustermann (1.1.1)
|
||||
ruby2_keywords (~> 0.0.1)
|
||||
mysql2 (0.5.3)
|
||||
net-http-persistent (2.9.4)
|
||||
net-http-pipeline (1.0.1)
|
||||
netrc (0.11.0)
|
||||
newrelic_rpm (6.12.0.367)
|
||||
nio4r (2.5.3)
|
||||
nokogiri (1.10.10)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
newrelic_rpm (7.2.0)
|
||||
nio4r (2.5.8)
|
||||
nokogiri (1.12.4-x86_64-linux)
|
||||
racc (~> 1.4)
|
||||
orm_adapter (0.5.0)
|
||||
parallel (1.19.2)
|
||||
parser (2.7.1.4)
|
||||
parallel (1.20.1)
|
||||
parser (3.0.2.0)
|
||||
ast (~> 2.4.1)
|
||||
passenger (6.0.6)
|
||||
passenger (6.0.10)
|
||||
rack
|
||||
rake (>= 0.8.1)
|
||||
puma (4.3.6)
|
||||
puma (5.4.0)
|
||||
nio4r (~> 2.0)
|
||||
pusher-client (0.6.2)
|
||||
json
|
||||
websocket (~> 1.0)
|
||||
racc (1.5.2)
|
||||
rack (2.2.3)
|
||||
rack-protection (2.1.0)
|
||||
rack
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (6.0.3.2)
|
||||
actioncable (= 6.0.3.2)
|
||||
actionmailbox (= 6.0.3.2)
|
||||
actionmailer (= 6.0.3.2)
|
||||
actionpack (= 6.0.3.2)
|
||||
actiontext (= 6.0.3.2)
|
||||
actionview (= 6.0.3.2)
|
||||
activejob (= 6.0.3.2)
|
||||
activemodel (= 6.0.3.2)
|
||||
activerecord (= 6.0.3.2)
|
||||
activestorage (= 6.0.3.2)
|
||||
activesupport (= 6.0.3.2)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 6.0.3.2)
|
||||
rails (6.1.4.1)
|
||||
actioncable (= 6.1.4.1)
|
||||
actionmailbox (= 6.1.4.1)
|
||||
actionmailer (= 6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
actiontext (= 6.1.4.1)
|
||||
actionview (= 6.1.4.1)
|
||||
activejob (= 6.1.4.1)
|
||||
activemodel (= 6.1.4.1)
|
||||
activerecord (= 6.1.4.1)
|
||||
activestorage (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
bundler (>= 1.15.0)
|
||||
railties (= 6.1.4.1)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.3.0)
|
||||
rails-html-sanitizer (1.4.2)
|
||||
loofah (~> 2.3)
|
||||
rails_12factor (0.0.3)
|
||||
rails_serve_static_assets
|
||||
rails_stdout_logging
|
||||
rails_serve_static_assets (0.0.5)
|
||||
rails_stdout_logging (0.0.5)
|
||||
railties (6.0.3.2)
|
||||
actionpack (= 6.0.3.2)
|
||||
activesupport (= 6.0.3.2)
|
||||
railties (6.1.4.1)
|
||||
actionpack (= 6.1.4.1)
|
||||
activesupport (= 6.1.4.1)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.20.3, < 2.0)
|
||||
rake (>= 0.13)
|
||||
thor (~> 1.0)
|
||||
rainbow (3.0.0)
|
||||
rake (13.0.1)
|
||||
rake (13.0.6)
|
||||
rb-readline (0.5.5)
|
||||
rdoc (6.2.1)
|
||||
rdoc (6.3.2)
|
||||
ref (2.0.0)
|
||||
regexp_parser (1.7.1)
|
||||
regexp_parser (2.1.1)
|
||||
responders (3.0.1)
|
||||
actionpack (>= 5.0)
|
||||
railties (>= 5.0)
|
||||
rest-client (2.1.0)
|
||||
http-accept (>= 1.7.0, < 2.0)
|
||||
http-cookie (>= 1.0.2, < 2.0)
|
||||
mime-types (>= 1.16, < 4.0)
|
||||
netrc (~> 0.8)
|
||||
rexml (3.2.4)
|
||||
round_robin_tournament (0.0.1)
|
||||
rubocop (0.91.0)
|
||||
rexml (3.2.5)
|
||||
round_robin_tournament (0.1.1)
|
||||
rubocop (1.20.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.7.1.1)
|
||||
parser (>= 3.0.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.7)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml
|
||||
rubocop-ast (>= 0.4.0, < 1.0)
|
||||
rubocop-ast (>= 1.9.1, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 2.0)
|
||||
rubocop-ast (0.4.0)
|
||||
parser (>= 2.7.1.4)
|
||||
ruby-progressbar (1.10.1)
|
||||
ruby2_keywords (0.0.2)
|
||||
sdoc (1.1.0)
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.11.0)
|
||||
parser (>= 3.0.1.1)
|
||||
ruby-progressbar (1.11.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
sdoc (2.2.0)
|
||||
rdoc (>= 5.0)
|
||||
sinatra (2.1.0)
|
||||
mustermann (~> 1.0)
|
||||
@@ -260,53 +217,36 @@ GEM
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.4.2)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
therubyracer (0.12.3)
|
||||
libv8 (~> 3.16.14.15)
|
||||
ref
|
||||
thor (1.0.1)
|
||||
thread_safe (0.3.6)
|
||||
thor (1.1.0)
|
||||
tilt (2.0.10)
|
||||
travis (1.8.13)
|
||||
backports
|
||||
faraday (~> 0.9)
|
||||
faraday_middleware (~> 0.9, >= 0.9.1)
|
||||
gh (~> 0.13)
|
||||
highline (~> 1.6)
|
||||
launchy (~> 2.1)
|
||||
pusher-client (~> 0.4)
|
||||
typhoeus (~> 0.6, >= 0.6.8)
|
||||
turbolinks (5.2.1)
|
||||
turbolinks-source (~> 5.2)
|
||||
turbolinks-source (5.2.0)
|
||||
typhoeus (0.8.0)
|
||||
ethon (>= 0.8.0)
|
||||
tzinfo (1.2.7)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo-data (1.2020.1)
|
||||
tzinfo (2.0.4)
|
||||
concurrent-ruby (~> 1.0)
|
||||
tzinfo-data (1.2021.1)
|
||||
tzinfo (>= 1.0.0)
|
||||
uglifier (4.2.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.7)
|
||||
unicode-display_width (1.7.0)
|
||||
uniform_notifier (1.13.0)
|
||||
unicode-display_width (2.0.0)
|
||||
uniform_notifier (1.14.2)
|
||||
warden (1.2.9)
|
||||
rack (>= 2.0.9)
|
||||
websocket (1.2.8)
|
||||
websocket-driver (0.7.3)
|
||||
websocket-driver (0.7.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
zeitwerk (2.4.0)
|
||||
zeitwerk (2.4.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
brakeman
|
||||
bullet
|
||||
bundler-audit
|
||||
cancancan
|
||||
coffee-rails
|
||||
daemons
|
||||
@@ -314,14 +254,14 @@ DEPENDENCIES
|
||||
delayed_job_active_record
|
||||
delayed_job_web
|
||||
devise
|
||||
hakiri
|
||||
influxdb-rails
|
||||
jbuilder
|
||||
jquery-rails
|
||||
mysql2
|
||||
newrelic_rpm
|
||||
passenger
|
||||
puma
|
||||
rails (= 6.0.3.2)
|
||||
rails (= 6.1.4.1)
|
||||
rails_12factor
|
||||
rb-readline
|
||||
round_robin_tournament
|
||||
@@ -330,13 +270,12 @@ DEPENDENCIES
|
||||
spring
|
||||
sqlite3
|
||||
therubyracer
|
||||
travis
|
||||
turbolinks
|
||||
tzinfo-data
|
||||
uglifier
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.6.5p114
|
||||
ruby 3.0.0p0
|
||||
|
||||
BUNDLED WITH
|
||||
2.0.2
|
||||
2.2.26
|
||||
|
||||
15
README.md
15
README.md
@@ -2,10 +2,10 @@
|
||||
This application is being created to run a wrestling tournament.
|
||||
|
||||
### Current master status
|
||||
[](https://travis-ci.org/jcwimer/wrestlingApp)
|
||||
[](https://circleci.com/gh/jcwimer/wrestlingApp/tree/master)
|
||||
|
||||
### Current development status
|
||||
[](https://travis-ci.org/jcwimer/wrestlingApp)
|
||||
[](https://circleci.com/gh/jcwimer/wrestlingApp/tree/development)
|
||||
|
||||
# Info
|
||||
**License:** MIT License
|
||||
@@ -13,8 +13,8 @@ This application is being created to run a wrestling tournament.
|
||||
**Public Production Url:** [https://wrestlingdev.com](http://wrestlingdev.com)
|
||||
|
||||
**App Info**
|
||||
* Ruby 2.6.5
|
||||
* Rails 6.0.1
|
||||
* Ruby 3.0.0
|
||||
* Rails 6.1.2
|
||||
* DB mysql or mariadb
|
||||
* Memcached
|
||||
* Delayed Jobs
|
||||
@@ -30,7 +30,7 @@ From here, you can run the normal rails commands.
|
||||
* `rails generate blah blah blah`
|
||||
* ` rails s -b 0.0.0.0` port 3000 is exposed. You can open [http://localhost:3000](http://localhost:3000) after running that command
|
||||
* etc.
|
||||
* `rake finish_seed_tournament` will complete all matches from the seed data. This command takes about 5 minutes to execute
|
||||
* `rake finish_seed_tournaments` will complete all matches from the seed data. This command takes about 5 minutes to execute
|
||||
|
||||
To deploy a a full local version of the app `bash deploy/deploy-test.sh` (this requires docker-compose to be installed). This deploys a full version of the app. App, delayed job, memcached, and mariadb. Now, you can open [http://localhost](http://localhost). Delayed jobs are turned off in dev and everything that is a delayed job in prod just runs in browser.
|
||||
|
||||
@@ -54,3 +54,8 @@ The production version of this is currently deployed in Kubernetes. See [Deployi
|
||||
* `MEMCACHIER_SERVERS=memcachier_hostname:memcachier_port` needed for caching
|
||||
* `MEMCACHIER_USERNAME=memcachier_username` needed for caching
|
||||
* `WRESTLINGDEV_NEW_RELIC_LICENSE_KEY=new_relic_license_key` this is only needed to use new relic
|
||||
* `WRESTLINGDEV_INFLUXDB_DATABASE=influx_db_name` to send metrics to influxdb this is required
|
||||
* `WRESTLINGDEV_INFLUXDB_HOST=influx_db_ip_or_hostname` to send metrics to influxdb this is required
|
||||
* `WRESTLINGDEV_INFLUXDB_PORT=influx_db_port` to send metrics to influxdb this is required
|
||||
* `WRESTLINGDEV_INFLUXDB_USERNAME=influx_db_username` to send metrics to influxdb this is optional
|
||||
* `WRESTLINGDEV_INFLUXDB_PASSWORD=influx_db_password` to send metrics to influxdb this is optional
|
||||
@@ -134,7 +134,7 @@ class TournamentsController < ApplicationController
|
||||
end
|
||||
|
||||
def matches
|
||||
@matches = @tournament.matches.sort_by{|m| m.bout_number}
|
||||
@matches = @tournament.matches.includes(:wrestlers,:schools).sort_by{|m| m.bout_number}
|
||||
if @match
|
||||
@w1 = @match.wrestler1
|
||||
@w2 = @match.wrestler2
|
||||
@@ -165,7 +165,7 @@ class TournamentsController < ApplicationController
|
||||
end
|
||||
|
||||
def create_custom_weights
|
||||
@custom = params[:customValue].to_s
|
||||
@custom = params[:customValue].split(",")
|
||||
@tournament.create_pre_defined_weights(@custom)
|
||||
redirect_to "/tournaments/#{@tournament.id}"
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@ class Match < ActiveRecord::Base
|
||||
belongs_to :weight, touch: true
|
||||
belongs_to :mat, touch: true
|
||||
has_many :wrestlers, :through => :weight
|
||||
has_many :schools, :through => :wrestlers
|
||||
after_update :after_finished_actions, :if => :saved_change_to_finished? or :saved_change_to_winner_id? or :saved_change_to_win_type? or :saved_change_to_score?
|
||||
|
||||
def after_finished_actions
|
||||
@@ -96,7 +97,7 @@ class Match < ActiveRecord::Base
|
||||
elsif self.win_type == "DQ"
|
||||
return "(DQ)"
|
||||
elsif self.win_type == "Forfeit"
|
||||
return "(For)"
|
||||
return "(FF)"
|
||||
else
|
||||
win_type_abbreviation = "#{self.win_type.chars.to_a[0..2].join('')}"
|
||||
return "(#{win_type_abbreviation} #{self.score})"
|
||||
|
||||
@@ -14,10 +14,15 @@ class School < ActiveRecord::Base
|
||||
|
||||
def abbreviation
|
||||
name_array = self.name.split(' ')
|
||||
if name_array.size > 1
|
||||
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a[0..1].join('').upcase}"
|
||||
if name_array.size > 2
|
||||
# If three words, use first letter of first word, first letter of second, and first two of third
|
||||
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a.first}#{name_array[2].chars.to_a[0..1].join('').upcase}"
|
||||
elsif name_array.size > 1
|
||||
# If two words use first letter of first word and first three of the second
|
||||
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a[0..2].join('').upcase}"
|
||||
else
|
||||
return "#{name_array[0].chars.to_a[0..2].join('').upcase}"
|
||||
# If one word use first four letters
|
||||
return "#{name_array[0].chars.to_a[0..3].join('').upcase}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,31 +45,24 @@ class School < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def calculate_score_raw
|
||||
newScore = total_points_scored_by_wrestlers - total_points_deducted
|
||||
newScore = total_points_scored_by_wrestlers - total_points_deducted
|
||||
self.score = newScore
|
||||
self.save
|
||||
end
|
||||
|
||||
def total_points_scored_by_wrestlers
|
||||
points = 0
|
||||
points = 0.0
|
||||
self.wrestlers.each do |w|
|
||||
if w.extra != true
|
||||
points = points + w.total_team_points
|
||||
end
|
||||
points = points + w.total_team_points
|
||||
end
|
||||
points
|
||||
end
|
||||
|
||||
def total_points_deducted
|
||||
points = 0
|
||||
points = 0.0
|
||||
deductedPoints.each do |d|
|
||||
points = points + d.points
|
||||
end
|
||||
self.wrestlers.each do |w|
|
||||
w.deductedPoints.each do |d|
|
||||
points = points + d.points
|
||||
end
|
||||
end
|
||||
points
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,17 +29,21 @@ class Tournament < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def tournament_types
|
||||
["Pool to bracket","Modified 16 Man Double Elimination","Double Elimination 1-6"]
|
||||
["Pool to bracket","Modified 16 Man Double Elimination 1-6","Modified 16 Man Double Elimination 1-8","Regular Double Elimination 1-6","Regular Double Elimination 1-8"]
|
||||
end
|
||||
|
||||
def create_pre_defined_weights(value)
|
||||
|
||||
def number_of_placers
|
||||
if self.tournament_type.include? "1-8"
|
||||
return 8
|
||||
elsif self.tournament_type.include? "1-6"
|
||||
return 6
|
||||
end
|
||||
end
|
||||
|
||||
def create_pre_defined_weights(weight_classes)
|
||||
weights.destroy_all
|
||||
if value == 'hs'
|
||||
Weight::HS_WEIGHT_CLASSES.each do |w|
|
||||
weights.create(max: w)
|
||||
end
|
||||
else
|
||||
raise "Unspecified behavior"
|
||||
weight_classes.each do |w|
|
||||
weights.create(max: w)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -116,7 +120,7 @@ class Tournament < ActiveRecord::Base
|
||||
|
||||
def modified_sixteen_man_number_of_wrestlers
|
||||
error_string = ""
|
||||
if self.tournament_type == "Modified 16 Man Double Elimination"
|
||||
if self.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 16}
|
||||
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 12}
|
||||
weights_with_too_many_wrestlers.each do |weight|
|
||||
@@ -145,17 +149,17 @@ class Tournament < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def match_generation_error
|
||||
errorString = "There is a tournament error."
|
||||
error_string = "There is a tournament error."
|
||||
modified_sixteen_man_error = modified_sixteen_man_number_of_wrestlers
|
||||
double_elim_error = double_elim_number_of_wrestlers
|
||||
if pool_to_bracket_weights_with_too_many_wrestlers != nil
|
||||
errorString = errorString + " The following weights have too many wrestlers "
|
||||
error_string = error_string + " The following weights have too many wrestlers "
|
||||
pool_to_bracket_weights_with_too_many_wrestlers.each do |w|
|
||||
errorString = errorString + "#{w.max} "
|
||||
error_string = error_string + "#{w.max} "
|
||||
end
|
||||
return errorString
|
||||
return error_string
|
||||
elsif modified_sixteen_man_error.length > 0
|
||||
return errorString + modified_sixteen_man_error
|
||||
return error_string + modified_sixteen_man_error
|
||||
elsif double_elim_error.length > 0
|
||||
return error_string + double_elim_error
|
||||
else
|
||||
|
||||
@@ -7,7 +7,11 @@ class Weight < ActiveRecord::Base
|
||||
|
||||
validates :max, presence: true
|
||||
|
||||
HS_WEIGHT_CLASSES = [106,113,120,126,132,138,145,152,160,170,182,195,220,285]
|
||||
# passed via layouts/_tournament-navbar.html.erb
|
||||
# tournaments controller does a .split(',') on this string and creates an array via commas
|
||||
# tournament model runs the code via method create_pre_defined_weights
|
||||
HS_WEIGHT_CLASSES = "106,113,120,126,132,138,144,150,157,165,175,190,215,285."
|
||||
HS_GIRLS_WEIGHT_CLASSES = "100,105,110,115,120,125,130,135,140,145,155,170,190,235"
|
||||
|
||||
before_destroy do
|
||||
self.tournament.destroy_all_matches
|
||||
|
||||
@@ -15,8 +15,8 @@ class AdvanceWrestler
|
||||
|
||||
def advance_raw
|
||||
pool_to_bracket_advancement if @tournament.tournament_type == "Pool to bracket"
|
||||
DoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type == "Modified 16 Man Double Elimination" or
|
||||
@tournament.tournament_type == "Double Elimination 1-6"
|
||||
DoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or
|
||||
@tournament.tournament_type.include? "Regular Double Elimination"
|
||||
end
|
||||
|
||||
def pool_to_bracket_advancement
|
||||
|
||||
@@ -28,17 +28,18 @@ class DoubleEliminationAdvance
|
||||
update_new_match(new_match, get_wrestler_number)
|
||||
elsif @last_match.bracket_position == "Conso Semis"
|
||||
# if its a regular double elim
|
||||
if Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","Conso Semis",@next_match_position_number.ceil,@wrestler.weight_id).first.loser1_name != nil
|
||||
if @wrestler.tournament.tournament_type.include? "Regular Double Elimination"
|
||||
new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","3/4",@next_match_position_number.ceil,@wrestler.weight_id).first
|
||||
update_new_match(new_match, get_wrestler_number)
|
||||
# if it's a special bracket where consolations wrestler for 5th
|
||||
else
|
||||
elsif @wrestler.tournament.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||
new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","5/6",@next_match_position_number.ceil,@wrestler.weight_id).first
|
||||
update_new_match(new_match, get_wrestler_number)
|
||||
end
|
||||
elsif @last_match.bracket_position == "Conso Quarter"
|
||||
next_round_matches = Match.where("weight_id = ? and bracket_position = ?", @wrestler.weight_id, "Conso Semis").sort_by{|m| m.round}
|
||||
this_round_matches = Match.where("weight_id = ? and round = ? and bracket_position = ?", @wrestler.weight_id, @last_match.round, "Conso Quarter")
|
||||
# bracket position is different depending on if a semi loser is dropping or if there are 4 conso quarter matches
|
||||
if next_round_matches.size == this_round_matches.size
|
||||
# if a semi loser is dropping down
|
||||
new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","Conso Semis",@last_match.bracket_position_number,@wrestler.weight_id).first
|
||||
|
||||
@@ -33,12 +33,12 @@ class GenerateTournamentMatches
|
||||
def generate_raw
|
||||
standardStartingActions
|
||||
PoolToBracketMatchGeneration.new(@tournament).generatePoolToBracketMatches if @tournament.tournament_type == "Pool to bracket"
|
||||
ModifiedSixteenManMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type == "Modified 16 Man Double Elimination"
|
||||
DoubleEliminationMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type == "Double Elimination 1-6"
|
||||
ModifiedSixteenManMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||
DoubleEliminationMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type.include? "Regular Double Elimination"
|
||||
postMatchCreationActions
|
||||
PoolToBracketMatchGeneration.new(@tournament).assignLoserNames if @tournament.tournament_type == "Pool to bracket"
|
||||
ModifiedSixteenManGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type == "Modified 16 Man Double Elimination"
|
||||
DoubleEliminationGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type == "Double Elimination 1-6"
|
||||
ModifiedSixteenManGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||
DoubleEliminationGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type.include? "Regular Double Elimination"
|
||||
end
|
||||
|
||||
def standardStartingActions
|
||||
|
||||
@@ -10,6 +10,7 @@ class ModifiedSixteenManGenerateLoserNames
|
||||
conso_round_2(matches_by_weight)
|
||||
conso_round_3(matches_by_weight)
|
||||
third_fourth(matches_by_weight)
|
||||
seventh_eighth(matches_by_weight)
|
||||
save_matches(matches_by_weight)
|
||||
matches_by_weight = @tournament.matches.where(weight_id: w.id).reload
|
||||
advance_bye_matches_championship(matches_by_weight)
|
||||
@@ -55,11 +56,17 @@ class ModifiedSixteenManGenerateLoserNames
|
||||
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Semis"}.second.bout_number}"
|
||||
end
|
||||
end
|
||||
|
||||
def seventh_eighth(matches)
|
||||
matches.select{|m| m.bracket_position == "7/8"}.sort_by{|m| m.bracket_position_number}.each do |match|
|
||||
match.loser1_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Semis"}.first.bout_number}"
|
||||
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Semis"}.second.bout_number}"
|
||||
end
|
||||
end
|
||||
|
||||
def advance_bye_matches_championship(matches)
|
||||
matches.select{|m| m.round == 1 and m.bracket_position == "Bracket"}.sort_by{|m| m.bracket_position_number}.each do |match|
|
||||
if match.w1 == nil or match.w2 == nil
|
||||
puts match.bout_number
|
||||
match.finished = 1
|
||||
match.win_type = "BYE"
|
||||
if match.w1 != nil
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class ModifiedSixteenManMatchGeneration
|
||||
def initialize( tournament )
|
||||
@tournament = tournament
|
||||
@number_of_placers = @tournament.number_of_placers
|
||||
end
|
||||
|
||||
def generate_matches
|
||||
@@ -57,6 +58,9 @@ class ModifiedSixteenManMatchGeneration
|
||||
create_matchup(nil,nil,"1/2",1,5,weight)
|
||||
create_matchup(nil,nil,"3/4",1,5,weight)
|
||||
create_matchup(nil,nil,"5/6",1,5,weight)
|
||||
if @number_of_placers >= 8
|
||||
create_matchup(nil,nil,"7/8",1,5,weight)
|
||||
end
|
||||
end
|
||||
|
||||
def wrestler_with_seed(seed,weight)
|
||||
|
||||
@@ -10,6 +10,7 @@ class SixteenManDoubleEliminationGenerateLoserNames
|
||||
conso_round_3(matches_by_weight)
|
||||
conso_round_5(matches_by_weight)
|
||||
fifth_sixth(matches_by_weight)
|
||||
seventh_eighth(matches_by_weight)
|
||||
save_matches(matches_by_weight)
|
||||
matches_by_weight = @weight.matches.reload
|
||||
advance_bye_matches_championship(matches_by_weight)
|
||||
@@ -64,6 +65,13 @@ class SixteenManDoubleEliminationGenerateLoserNames
|
||||
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Semis"}.second.bout_number}"
|
||||
end
|
||||
end
|
||||
|
||||
def seventh_eighth(matches)
|
||||
matches.select{|m| m.bracket_position == "7/8"}.sort_by{|m| m.bracket_position_number}.each do |match|
|
||||
match.loser1_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Quarter"}.first.bout_number}"
|
||||
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Quarter"}.second.bout_number}"
|
||||
end
|
||||
end
|
||||
|
||||
def advance_bye_matches_championship(matches)
|
||||
matches.select{|m| m.round == 1 and m.bracket_position == "Bracket"}.sort_by{|m| m.bracket_position_number}.each do |match|
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class SixteenManDoubleEliminationMatchGeneration
|
||||
def initialize( weight )
|
||||
@weight = weight
|
||||
@number_of_placers = @weight.tournament.number_of_placers
|
||||
end
|
||||
|
||||
def generate_matches_for_weight
|
||||
@@ -57,6 +58,9 @@ class SixteenManDoubleEliminationMatchGeneration
|
||||
create_matchup(nil,nil,"1/2",1,6,weight)
|
||||
create_matchup(nil,nil,"3/4",1,6,weight)
|
||||
create_matchup(nil,nil,"5/6",1,6,weight)
|
||||
if @number_of_placers >= 8
|
||||
create_matchup(nil,nil,"7/8",1,6,weight)
|
||||
end
|
||||
end
|
||||
|
||||
def wrestler_with_seed(seed,weight)
|
||||
|
||||
@@ -26,8 +26,8 @@ class CalculateWrestlerTeamScore
|
||||
|
||||
def placement_points
|
||||
return PoolBracketPlacementPoints.new(@wrestler).calcPoints if @tournament.tournament_type == "Pool to bracket"
|
||||
return ModifiedSixteenManPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type == "Modified 16 Man Double Elimination"
|
||||
return DoubleEliminationPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type == "Double Elimination 1-6"
|
||||
return ModifiedSixteenManPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||
return DoubleEliminationPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type.include? "Regular Double Elimination"
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
class DoubleEliminationPlacementPoints
|
||||
def initialize(wrestler)
|
||||
@wrestler = wrestler
|
||||
if wrestler.tournament.tournament_type == "Double Elimination 1-6"
|
||||
@number_of_placers = 6
|
||||
end
|
||||
@number_of_placers = @wrestler.tournament.number_of_placers
|
||||
end
|
||||
|
||||
def calc_points
|
||||
@@ -22,7 +20,7 @@ class DoubleEliminationPlacementPoints
|
||||
elsif won_bracket_position_size("7/8") > 0
|
||||
return PlacementPoints.new(@number_of_placers).seventhPlace
|
||||
elsif bracket_position_size("Conso Quarter") > 0 and @number_of_placers >= 8
|
||||
return PlacementPoints.new(@number_of_placers).eigthPlace
|
||||
return PlacementPoints.new(@number_of_placers).eighthPlace
|
||||
else
|
||||
return 0
|
||||
end
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class ModifiedSixteenManPlacementPoints
|
||||
def initialize(wrestler)
|
||||
@wrestler = wrestler
|
||||
@number_of_placers = 6
|
||||
@wrestler = wrestler
|
||||
@number_of_placers = @wrestler.tournament.number_of_placers
|
||||
end
|
||||
|
||||
def calc_points
|
||||
@@ -17,6 +18,10 @@ class ModifiedSixteenManPlacementPoints
|
||||
return PlacementPoints.new(@number_of_placers).fifthPlace
|
||||
elsif bracket_position_size("5/6") > 0
|
||||
return PlacementPoints.new(@number_of_placers).sixthPlace
|
||||
elsif won_bracket_position_size("7/8") > 0
|
||||
return PlacementPoints.new(@number_of_placers).seventhPlace
|
||||
elsif bracket_position_size("Conso Semis") > 0 and @number_of_placers >= 8
|
||||
return PlacementPoints.new(@number_of_placers).eighthPlace
|
||||
else
|
||||
return 0
|
||||
end
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
<li><strong>Time Savers</strong></li>
|
||||
<li><%= link_to "Create High School Weights (106-285)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=hs",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
|
||||
<li><%= link_to "Create Boys High School Weights (106-285)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::HS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
|
||||
<li><%= link_to "Create Girls High School Weights (101-235)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::HS_GIRLS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
|
||||
<li><strong>Tournament Actions</strong></li>
|
||||
<li><%= link_to "Calculate Team Scores" , "/tournaments/#{@tournament.id}/calculate_team_scores", method: :post %></li>
|
||||
<li><%= link_to "Generate Brackets" , "/tournaments/#{@tournament.id}/generate_matches", data: { confirm: 'Are you sure? This will delete all current matches.' } %></li>
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
<li>Tournament Types
|
||||
<ul>
|
||||
<li>Pool to bracket (adhears to 5 match per day rule)</li>
|
||||
<li>Double elimination 16 man and 8 man</li>
|
||||
<li>Regular Double Elimination 16 man and 8 man. Options for placing 1st-6th or 1st-8th.</li>
|
||||
<li>Modified 16 Man Double Elimination 1-6. Options for placing 1st-6th or 1st-8th. Adhears to 5 match per day rule.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Team point calculation</li>
|
||||
@@ -60,9 +61,23 @@
|
||||
<li>Eight pools of 3 (2 matches each) to a quarter final bracket - 17-24 wrestlers, place 1-8.</li>
|
||||
</ul>
|
||||
<br>
|
||||
<h3>Double Elimination Information</h3>
|
||||
<h3>Regular Double Elimination Information</h3>
|
||||
<p>Right now, double elimination brackets only support 8 and 16 man brackets (4-16 wrestlers). Cross bracketing will happen every other round. 16 man in quarter finals, 8 man in semi finals.</p>
|
||||
<h4>Double elimination scoring</h4>
|
||||
<p>Regular Double Elimination 1-6 places 1st through 6th. Regular Double Elimination 1-8 places 1st through 8th.</p>
|
||||
<h4>Regular Double Elimination scoring</h4>
|
||||
<ul>
|
||||
<li>Championship win: 2pt</li>
|
||||
<li>Consolation win: 1pt</li>
|
||||
<li>Win by major: 1pt extra</li>
|
||||
<li>Win by tech: 1.5pt extra</li>
|
||||
<li>Win by fall, default, dq, etc: 2pt extra</li>
|
||||
<li>BYE points: 2pts if you have a bye in the championship bracket and win the next match. 1pt if you have a bye in the consolation bracket and win the next match.</li>
|
||||
</ul>
|
||||
<br>
|
||||
<h3>Modified 16 Man Double Elimination Information</h3>
|
||||
<p>Adhears to 5 match per day rule. Allows a 16 man bracket without anyone wrestling more than 5 matches. Semi Final losers wrestle for 3rd. Anyone who loses before the Semi Finals wrestle a consolation bracket for 5th.</p>
|
||||
<p>Modified 16 Man Double Elimination 1-6 places 1st through 6th. Modified 16 Man Double Elimination 1-8 places 1st through 8th.</p>
|
||||
<h4>Modified 16 Man Double Elimination scoring (same as Regular Double Elimination)</h4>
|
||||
<ul>
|
||||
<li>Championship win: 2pt</li>
|
||||
<li>Consolation win: 1pt</li>
|
||||
@@ -127,7 +142,7 @@
|
||||
<br>
|
||||
<h3>Future Plans</h3>
|
||||
<br>
|
||||
<p>Future development plans to support 32 and 64 man double elimination as well as modified (5 per day match rule) 16 and 32 man double elimination brackets are underway.</p>
|
||||
<p>Future development plans to support 32 and 64 man regulard double elimination, modified (5 per day match rule) 32 man double elimination, and true second double elimination brackets are underway.</p>
|
||||
<br>
|
||||
<h3>Contact</h3>
|
||||
<br>
|
||||
|
||||
@@ -106,11 +106,11 @@ table.smallText tr td { font-size: 10px; }
|
||||
<%= render 'fourPoolSemiBracket' %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% elsif @tournament.tournament_type == "Modified 16 Man Double Elimination" %>
|
||||
<% elsif @tournament.tournament_type.include? "Modified 16 Man Double Elimination" %>
|
||||
<td valign="top" style="padding: 10px;">
|
||||
<%= render 'modified_sixteen_man_double_elimination_bracket' %>
|
||||
</td>
|
||||
<% elsif @tournament.tournament_type == "Double Elimination 1-6" %>
|
||||
<% elsif @tournament.tournament_type.include? "Regular Double Elimination" %>
|
||||
<td valign="top" style="padding: 10px;">
|
||||
<%= render 'double_elimination_bracket' %>
|
||||
</td>
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
<%= f.label :tournament_type %><br>
|
||||
<%= f.select :tournament_type, @tournament.tournament_types %>
|
||||
</div>
|
||||
<br>
|
||||
<div>
|
||||
See About page for information on tournament types: <%= link_to "About", "/static_pages/about" %>
|
||||
<p>For double elimination tournaments, 1-6 places 1st through 6th and 1-8 places 1st through 8th.</p>
|
||||
</div>
|
||||
<%= f.hidden_field :user_id, :value => current_user.id %>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
@@ -1,131 +1,48 @@
|
||||
<h4>Championship Bracket</h4>
|
||||
<main id="bracket">
|
||||
<ul class="round round-1">
|
||||
<% @matches.select{|m|m.bracket_position == "Bracket" and m.round == 1}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li> </li>
|
||||
<li class="game game-top "><%= match.w1_bracket_name_round_one %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name_round_one %><span></span></li>
|
||||
<li> </li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-2">
|
||||
<% @matches.select{|m|m.bracket_position == "Quarter"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li></li>
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
<li></li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-3">
|
||||
<% @matches.select{|m|m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li></li>
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
<li></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-4">
|
||||
<% @matches.select{|m|m.bracket_position == "1/2"}.each do |match| %>
|
||||
<li></li>
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
<li></li>
|
||||
|
||||
</ul>
|
||||
<ul class="round round-5">
|
||||
<li></li>
|
||||
<li class="bracket-winner"> <%= match.bracket_winner_name %> <span></span></li>
|
||||
1st
|
||||
<li></li>
|
||||
|
||||
</ul>
|
||||
<% end %>
|
||||
</main>
|
||||
<div class="bracket">
|
||||
<!--Round 1-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Bracket" and m.round == 1} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 2-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Quarter"} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 3-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Semis"} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 4-->
|
||||
<% @final_match = @matches.select{|m|m.bracket_position == "1/2"} %>
|
||||
<% @winner_place = "1st" %>
|
||||
<%= render 'bracket_final' %>
|
||||
</div>
|
||||
<h4>3/4 place match</h4>
|
||||
<main id="bracket">
|
||||
<ul class="round round-3">
|
||||
<% @matches.select{|m|m.bracket_position == "3/4"}.each do |match| %>
|
||||
<li> </li>
|
||||
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
|
||||
<li> </li>
|
||||
|
||||
</ul>
|
||||
<ul class="round round-4">
|
||||
<li> </li>
|
||||
|
||||
<li class="bracket-winner"> <%= match.bracket_winner_name %> <span></span></li>
|
||||
3rd
|
||||
|
||||
<li> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
</main>
|
||||
<div class="bracket">
|
||||
<!--Round 1-->
|
||||
<% @final_match = @matches.select{|m|m.bracket_position == "3/4"} %>
|
||||
<% @winner_place = "3rd" %>
|
||||
<%= render 'bracket_final' %>
|
||||
</div>
|
||||
<h4>Consolation Bracket</h4>
|
||||
<main id="bracket">
|
||||
<ul class="round round-1">
|
||||
<% @matches.select{|m|m.bracket_position == "Conso" and m.round == 2}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li> </li>
|
||||
<li> </li>
|
||||
|
||||
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-2">
|
||||
<% @matches.select{|m|m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li> </li>
|
||||
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
|
||||
<li> </li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-3">
|
||||
<% @matches.select{|m|m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||
<li> </li>
|
||||
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
<li> </li>
|
||||
|
||||
<% end %>
|
||||
</ul>
|
||||
<ul class="round round-4">
|
||||
<% @matches.select{|m|m.bracket_position == "5/6"}.each do |match| %>
|
||||
<li> </li>
|
||||
|
||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
||||
|
||||
<li> </li>
|
||||
|
||||
</ul>
|
||||
<ul class="round round-5">
|
||||
<li> </li>
|
||||
|
||||
<li class="bracket-winner"> <%= match.bracket_winner_name %> <span></span></li>
|
||||
5th
|
||||
|
||||
<li> </li>
|
||||
|
||||
</ul>
|
||||
<% end %>
|
||||
</main>
|
||||
<div class="bracket">
|
||||
<!--Round 1-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso" and m.round == 2} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 2-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso Quarter"} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 3-->
|
||||
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso Semis"} %>
|
||||
<%= render 'bracket_round' %>
|
||||
<!--Round 4-->
|
||||
<% @final_match = @matches.select{|m|m.bracket_position == "5/6"} %>
|
||||
<% @winner_place = "5th" %>
|
||||
<%= render 'bracket_final' %>
|
||||
</div>
|
||||
<% if @tournament.number_of_placers >= 8 %>
|
||||
<h4>7/8 place match</h4>
|
||||
<div class="bracket">
|
||||
<!--Round 1-->
|
||||
<% @final_match = @matches.select{|m|m.bracket_position == "7/8"} %>
|
||||
<% @winner_place = "7th" %>
|
||||
<%= render 'bracket_final' %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<% cache ["#{@tournament.id}_all_brackets", @tournament] do %>
|
||||
<div id="exportable" >
|
||||
<%= render :file => 'tournaments/team_scores' %>
|
||||
<%= render :template => 'tournaments/team_scores' %>
|
||||
<% @tournament.weights.sort_by{|w| w.max}.each do |weight| %>
|
||||
<table class='pagebreak'>
|
||||
<tr>
|
||||
@@ -28,7 +28,7 @@
|
||||
<% @weight = weight %>
|
||||
<%= render 'bracket_partial' %>
|
||||
</td>
|
||||
<% elsif @tournament.tournament_type == "Modified 16 Man Double Elimination" or @tournament.tournament_type == "Double Elimination 1-6" %>
|
||||
<% elsif @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or @tournament.tournament_type.include? "Regular Double Elimination" %>
|
||||
<td valign="top" style="padding: 10px;">
|
||||
<!-- Need to define what the tournaments#bracket controller defines -->
|
||||
<% @matches = weight.matches %>
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
<% end %>
|
||||
<% if @tournament.tournament_type == "Pool to bracket" %>
|
||||
<%= render 'pool_bracket_director_actions' %>
|
||||
<% elsif @tournament.tournament_type == "Modified 16 Man Double Elimination" or @tournament.tournament_type == "Double Elimination 1-6" %>
|
||||
<% elsif @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or @tournament.tournament_type.include? "Regular Double Elimination" %>
|
||||
<%= render 'bracket_director_actions' %>
|
||||
<% end %>
|
||||
@@ -24,7 +24,7 @@
|
||||
<tr>
|
||||
<td><%= match.bout_number %></td>
|
||||
<td><%= match.bracket_position %></td>
|
||||
<td><%= match.w1_bracket_name %> vs <%= match.w2_bracket_name %></td>
|
||||
<td><%= match.w1_bracket_name.html_safe %> vs <%= match.w2_bracket_name.html_safe %></td>
|
||||
<td><%= match.finished %></td>
|
||||
<td><%= link_to 'Show', match, :class=>"btn btn-default btn-sm" %>
|
||||
<%= link_to 'Edit Wrestlers', edit_match_path(match), :class=>"btn btn-primary btn-sm" %>
|
||||
|
||||
@@ -11,5 +11,5 @@ if [ $# != 1 ]; then
|
||||
fi
|
||||
|
||||
docker build -t $1 -f ${project_dir}/deploy/rails-dev-Dockerfile ${project_dir}
|
||||
docker run -it -p 3000:3000 -v ${project_dir}:/rails $1 /bin/bash
|
||||
sudo chown -R ${USER}:${USER} ${project_dir}
|
||||
docker run --rm -it -p 3000:3000 -v ${project_dir}:/rails $1 /bin/bash
|
||||
sudo chown -R ${USER_ID}:${USER_ID} ${project_dir}
|
||||
@@ -4,5 +4,5 @@ project_dir="$(dirname $( dirname $(readlink -f ${BASH_SOURCE[0]})))"
|
||||
cd ${project_dir}
|
||||
bundle exec rake db:migrate RAILS_ENV=test
|
||||
CI=true brakeman
|
||||
bundle exec hakiri gemfile:scan --force
|
||||
bundle exec bundle-audit check --update
|
||||
bundle exec rake test
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
project_dir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/.."
|
||||
|
||||
docker build -f ${project_dir}/deploy/rails-prod-Dockerfile -t wrestlingdevtests ${project_dir}/.
|
||||
docker run -it wrestlingdevtests bash /rails/bin/run-all-tests.sh
|
||||
docker run --rm -it wrestlingdevtests bash /rails/bin/run-all-tests.sh
|
||||
|
||||
@@ -33,8 +33,6 @@ module Wrestling
|
||||
DeviseController.respond_to :html, :json
|
||||
end
|
||||
|
||||
config.active_record.sqlite3.represent_boolean_as_integer = true
|
||||
|
||||
config.autoload_paths += %W(#{config.root}/app/services/tournament_services)
|
||||
config.autoload_paths += %W(#{config.root}/app/services/wrestler_services)
|
||||
config.autoload_paths += %W(#{config.root}/app/services/weight_services)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
Wrestling::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# allow all hostnames
|
||||
config.hosts.clear
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
# every request. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the web server when you make code changes.
|
||||
@@ -32,9 +35,5 @@ Wrestling::Application.configure do
|
||||
#Bullet.alert = true
|
||||
#Bullet.console = true
|
||||
#Bullet.bullet_logger = true
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ Wrestling::Application.configure do
|
||||
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
config.cache_store = :dalli_store,
|
||||
config.cache_store = :mem_cache_store,
|
||||
(ENV["MEMCACHIER_SERVERS"] || "").split(","),
|
||||
{:username => ENV["MEMCACHIER_USERNAME"],
|
||||
:password => ENV["MEMCACHIER_PASSWORD"],
|
||||
|
||||
45
config/initializers/influxdb_rails.rb
Normal file
45
config/initializers/influxdb_rails.rb
Normal file
@@ -0,0 +1,45 @@
|
||||
InfluxDB::Rails.configure do |config|
|
||||
## The only setting you actually need to update is the name of the
|
||||
## database within the InfluxDB server instance. Don't forget to
|
||||
## create this database as well.
|
||||
config.client.database = "#{ENV['WRESTLINGDEV_INFLUXDB_DATABASE']}"
|
||||
config.client.hosts = ["#{ENV['WRESTLINGDEV_INFLUXDB_HOST']}"]
|
||||
config.client.port = ENV['WRESTLINGDEV_INFLUXDB_PORT']
|
||||
|
||||
## If you've setup user authentication (and activated it in the server
|
||||
## config), you need to configure the credentials here.
|
||||
config.client.username = "#{ENV['WRESTLINGDEV_INFLUXDB_USERNAME']}"
|
||||
config.client.password = "#{ENV['WRESTLINGDEV_INFLUXDB_PASSWORD']}"
|
||||
|
||||
## If your InfluxDB service requires an HTTPS connection then you can
|
||||
## enable it here.
|
||||
# config.client.use_ssl = true
|
||||
|
||||
## Various other client and connection options. These are used to create
|
||||
## an `InfluxDB::Client` instance (i.e. `InfluxDB::Rails.client`).
|
||||
##
|
||||
## See docs for the influxdb gem for the canonical list of options:
|
||||
## https://github.com/influxdata/influxdb-ruby#list-of-configuration-options
|
||||
##
|
||||
## These defaults for the influxdb-rails gem deviate from the default
|
||||
## for the influxdb gem:
|
||||
# config.client.async = true # false
|
||||
# config.client.read_timeout = 30 # 300
|
||||
# config.client.max_delay = 300 # 30
|
||||
# config.client.time_precision = "ms" # "s"
|
||||
|
||||
## Prior to 1.0.0, this gem has written all data points in different
|
||||
## measurements (the config options were named `series_name_for_*`).
|
||||
## Since 1.0.0.beta3, we're now using a single measurements
|
||||
# config.measurement_name = "rails"
|
||||
|
||||
## Disable rails framework hooks.
|
||||
# config.ignored_hooks = ['sql.active_record', 'render_template.action_view']
|
||||
|
||||
# Modify tags on the fly.
|
||||
# config.tags_middleware = ->(tags) { tags }
|
||||
|
||||
## Set the application name to something meaningful, by default we
|
||||
## infer the app name from the Rails.application class name.
|
||||
# config.application_name = Rails.application.class.parent_name
|
||||
end
|
||||
0
config/storage.yml
Normal file
0
config/storage.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddScaleToTeamScoreDecimal < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
change_column :schools, :score, :decimal, precision: 15, scale: 1
|
||||
end
|
||||
end
|
||||
@@ -2,15 +2,15 @@
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# This file is the source Rails uses to define your schema when running `rails
|
||||
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
|
||||
# This file is the source Rails uses to define your schema when running `bin/rails
|
||||
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
||||
# be faster and is potentially less error prone than running all of your
|
||||
# migrations from scratch. Old migrations may fail to apply correctly if those
|
||||
# migrations use external dependencies or application code.
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_11_26_174257) do
|
||||
ActiveRecord::Schema.define(version: 2021_02_22_161151) do
|
||||
|
||||
create_table "delayed_jobs", force: :cascade do |t|
|
||||
t.integer "priority", default: 0, null: false
|
||||
@@ -74,7 +74,7 @@ ActiveRecord::Schema.define(version: 2019_11_26_174257) do
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "tournament_id"
|
||||
t.decimal "score"
|
||||
t.decimal "score", precision: 15, scale: 1
|
||||
t.index ["tournament_id"], name: "index_schools_on_tournament_id"
|
||||
end
|
||||
|
||||
|
||||
167
db/seeds.rb
167
db/seeds.rb
@@ -6,103 +6,88 @@
|
||||
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
||||
# Mayor.create(name: 'Emanuel', city: cities.first)
|
||||
#if Rails.env.development?
|
||||
def create_schools(tournament, number_of_schools)
|
||||
for number in (1..number_of_schools) do
|
||||
school = School.new
|
||||
school.name = "School#{number}"
|
||||
school.tournament_id = tournament.id
|
||||
school.save
|
||||
end
|
||||
end
|
||||
|
||||
def create_wrestlers_for_weight(weight, tournament, number_of_wrestlers, naming_start_number)
|
||||
naming_number = naming_start_number
|
||||
for number in (1..number_of_wrestlers) do
|
||||
wrestler = Wrestler.new
|
||||
wrestler.name = "Wrestler#{naming_number}"
|
||||
wrestler.school_id = tournament.schools.select{|s|s.name == "School#{number}"}.first.id
|
||||
wrestler.weight_id = weight.id
|
||||
wrestler.original_seed = number
|
||||
wrestler.save
|
||||
naming_number = naming_number + 1
|
||||
end
|
||||
end
|
||||
|
||||
User.create(id: 1, email: 'test@test.com', password: 'password', password_confirmation: 'password')
|
||||
Tournament.create(id: 200, name: 'test', address: 'some place', director: 'some guy', director_email: 'hismail@email.com', tournament_type: 'Pool to bracket', user_id: 1, date: Date.today)
|
||||
School.create(id: 200, name: 'Central Crossing', tournament_id: 200)
|
||||
School.create(id: 201, name: 'Turd Town', tournament_id: 200)
|
||||
School.create(id: 202, name: 'Shit Show', tournament_id: 200)
|
||||
School.create(id: 203, name: 'Westland', tournament_id: 200)
|
||||
School.create(id: 204, name: 'Grove City', tournament_id: 200)
|
||||
School.create(id: 205, name: 'Franklin Heights', tournament_id: 200)
|
||||
Weight.create(id: 200, max: 132, tournament_id: 200 )
|
||||
Weight.create(id: 201, max: 106, tournament_id: 200 )
|
||||
Weight.create(id: 202, max: 113, tournament_id: 200 )
|
||||
Weight.create(id: 203, max: 120, tournament_id: 200 )
|
||||
Weight.create(id: 204, max: 126, tournament_id: 200 )
|
||||
Weight.create(id: 205, max: 138, tournament_id: 200 )
|
||||
Mat.create(id: 200, name: "1", tournament_id: 200 )
|
||||
Mat.create(id: 201, name: "2", tournament_id: 200 )
|
||||
Mat.create(id: 202, name: "3", tournament_id: 200 )
|
||||
Mat.create(id: 203, name: "4", tournament_id: 200 )
|
||||
Wrestler.create(name: 'Guy 1', school_id: 200, weight_id: 200, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 2', school_id: 201, weight_id: 200, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 3', school_id: 202, weight_id: 200, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 4', school_id: 203, weight_id: 200, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 5', school_id: 204, weight_id: 200, original_seed: 5, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 6', school_id: 200, weight_id: 200, original_seed: 6, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 7', school_id: 200, weight_id: 200, original_seed: 7, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 8', school_id: 200, weight_id: 200, original_seed: 8, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 9', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 10', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 11', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 12', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 13', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 14', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 15', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 16', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 17', school_id: 200, weight_id: 201, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 18', school_id: 201, weight_id: 201, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 19', school_id: 202, weight_id: 201, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 20', school_id: 203, weight_id: 201, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 21', school_id: 204, weight_id: 201, original_seed: 5, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 22', school_id: 200, weight_id: 201, original_seed: 6, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 23', school_id: 200, weight_id: 201, original_seed: 7, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 24', school_id: 200, weight_id: 201, original_seed: 8, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 25', school_id: 200, weight_id: 201, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 26', school_id: 201, weight_id: 201, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 27', school_id: 202, weight_id: 201, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 30', school_id: 204, weight_id: 202, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 31', school_id: 204, weight_id: 202, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 32', school_id: 204, weight_id: 202, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 33', school_id: 204, weight_id: 202, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 34', school_id: 204, weight_id: 202, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
|
||||
Wrestler.create(name: 'Guy 35', school_id: 204, weight_id: 203, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 36', school_id: 204, weight_id: 203, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 37', school_id: 204, weight_id: 203, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 38', school_id: 204, weight_id: 203, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 39', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 40', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 41', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 42', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 43', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 44', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
# Pool to bracket
|
||||
tournament = Tournament.create(id: 200, name: 'Test1', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Pool to bracket', user_id: 1, date: Date.today)
|
||||
create_schools(tournament, 16)
|
||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||
tournament.create_pre_defined_weights(weight_classes)
|
||||
wrestler_name_number = 1
|
||||
tournament.weights.each do |weight|
|
||||
create_wrestlers_for_weight(weight, tournament, 16, wrestler_name_number)
|
||||
wrestler_name_number += 16
|
||||
end
|
||||
|
||||
Wrestler.create(name: 'Guy 45', school_id: 204, weight_id: 204, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 46', school_id: 204, weight_id: 204, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 47', school_id: 204, weight_id: 204, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 48', school_id: 204, weight_id: 204, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 49', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 50', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 51', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 52', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
# Modified 16 Man Double Elimination 1-6
|
||||
tournament = Tournament.create(id: 201, name: 'Test2', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Modified 16 Man Double Elimination 1-6', user_id: 1, date: Date.today)
|
||||
create_schools(tournament, 16)
|
||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||
tournament.create_pre_defined_weights(weight_classes)
|
||||
wrestler_name_number = 1
|
||||
tournament.weights.each do |weight|
|
||||
create_wrestlers_for_weight(weight, tournament, 16, wrestler_name_number)
|
||||
wrestler_name_number += 16
|
||||
end
|
||||
|
||||
Wrestler.create(name: 'Guy 53', school_id: 204, weight_id: 205, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 54', school_id: 204, weight_id: 205, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 55', school_id: 204, weight_id: 205, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 56', school_id: 204, weight_id: 205, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 57', school_id: 204, weight_id: 205, original_seed: 5, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 58', school_id: 204, weight_id: 205, original_seed: 6, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 59', school_id: 204, weight_id: 205, original_seed: 7, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 60', school_id: 204, weight_id: 205, original_seed: 8, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 61', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 62', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 63', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 64', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 65', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 66', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 67', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 68', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 69', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 70', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 71', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 72', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 73', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 74', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 75', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
Wrestler.create(name: 'Guy 76', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
|
||||
# Modified 16 Man Double Elimination 1-8
|
||||
tournament = Tournament.create(id: 202, name: 'Test3', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Modified 16 Man Double Elimination 1-8', user_id: 1, date: Date.today)
|
||||
create_schools(tournament, 16)
|
||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||
tournament.create_pre_defined_weights(weight_classes)
|
||||
wrestler_name_number = 1
|
||||
tournament.weights.each do |weight|
|
||||
create_wrestlers_for_weight(weight, tournament, 16, wrestler_name_number)
|
||||
wrestler_name_number += 16
|
||||
end
|
||||
|
||||
# Regular Double Elimination 1-6
|
||||
tournament = Tournament.create(id: 203, name: 'Test4', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Regular Double Elimination 1-6', user_id: 1, date: Date.today)
|
||||
create_schools(tournament, 16)
|
||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||
tournament.create_pre_defined_weights(weight_classes)
|
||||
wrestler_name_number = 1
|
||||
tournament.weights.each do |weight|
|
||||
create_wrestlers_for_weight(weight, tournament, 16, wrestler_name_number)
|
||||
wrestler_name_number += 16
|
||||
end
|
||||
|
||||
# Regular Double Elimination 1-8
|
||||
tournament = Tournament.create(id: 204, name: 'Test5', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Regular Double Elimination 1-8', user_id: 1, date: Date.today)
|
||||
create_schools(tournament, 16)
|
||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||
tournament.create_pre_defined_weights(weight_classes)
|
||||
wrestler_name_number = 1
|
||||
tournament.weights.each do |weight|
|
||||
create_wrestlers_for_weight(weight, tournament, 16, wrestler_name_number)
|
||||
wrestler_name_number += 16
|
||||
end
|
||||
#end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,11 @@ version: "2.2"
|
||||
networks:
|
||||
database:
|
||||
caching:
|
||||
metrics:
|
||||
|
||||
volumes:
|
||||
mysql:
|
||||
influxdb:
|
||||
|
||||
services:
|
||||
app:
|
||||
@@ -23,9 +25,13 @@ services:
|
||||
- MEMCACHIER_PASSWORD=
|
||||
- WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa
|
||||
- WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2
|
||||
- WRESTLINGDEV_INFLUXDB_DATABASE=wrestlingdev
|
||||
- WRESTLINGDEV_INFLUXDB_HOST=influxdb
|
||||
- WRESTLINGDEV_INFLUXDB_PORT=8086
|
||||
networks:
|
||||
database:
|
||||
caching:
|
||||
metrics:
|
||||
restart: always
|
||||
ports:
|
||||
- "80:80"
|
||||
@@ -58,16 +64,30 @@ services:
|
||||
- MEMCACHIER_PASSWORD=
|
||||
- WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa
|
||||
- WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2
|
||||
- WRESTLINGDEV_INFLUXDB_DATABASE=wrestlingdev
|
||||
- WRESTLINGDEV_INFLUXDB_HOST=influxdb
|
||||
- WRESTLINGDEV_INFLUXDB_PORT=8086
|
||||
networks:
|
||||
database:
|
||||
caching:
|
||||
metrics:
|
||||
restart: always
|
||||
command: bundle exec bin/delayed_job -n 1 run
|
||||
|
||||
influxdb:
|
||||
image: influxdb:1.8-alpine
|
||||
environment:
|
||||
- INFLUXDB_DB=wrestlingdev
|
||||
ports:
|
||||
- "8086:8086"
|
||||
networks:
|
||||
metrics:
|
||||
volumes:
|
||||
- influxdb:/var/lib/influxdb
|
||||
|
||||
memcached:
|
||||
image: memcached:1.5
|
||||
mem_limit: 64000000
|
||||
mem_limit: "64000000"
|
||||
restart: always
|
||||
networks:
|
||||
caching:
|
||||
|
||||
caching:
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
## What do I get?
|
||||
1. Wrestlingdev deployed with 2 replicas. Autoscaling is turned on up to 4 replcias.
|
||||
2. A standalone mariadb.
|
||||
2. A standalone mariadb that can back up to S3 compatable storage if you set the values in `deploy/kubernetes/secrets/secrets.yaml` and prometheus ready metrics
|
||||
3. A standalone memcahced.
|
||||
4. A single job runner to run wrestlingdev background jobs.
|
||||
|
||||
@@ -36,4 +36,4 @@ From a mysql shell> `CREATE USER ${username} IDENTIFIED BY '${password}'; GRANT
|
||||
Right now, we're also only using gmail for email.
|
||||
|
||||
## Recommended cloud machines
|
||||
In production, this runs on GKE. I have two node pools. The first is 2 x `n2-high-cpu-2` ($12.63/month preemptible). That pool can run 1 "copy" of the application. That means 2 x app pods, 1 x worker, 1 x memcached, and 1 x mariadb. The second node pool is an autoscale from 0-10 and is of the machine type `n1-standard-1` ($7.30/ month preemptible). This pool is scritly for scaling the app pods and the worker pods.
|
||||
In production, this runs on GKE. I have two node pools. The first is 2 x `n2-high-cpu-2` ($12.63/month preemptible). That pool can run 1 "copy" of the application. That means 2 x app pods, 1 x worker, 1 x memcached, and 1 x mariadb. The second node pool is an autoscale from 0-10 and is of the machine type `n1-standard-1` ($7.30/ month preemptible). This pool is strictly for scaling the app pods and the worker pods.
|
||||
74
deploy/kubernetes/manifests/influxdb.yaml
Normal file
74
deploy/kubernetes/manifests/influxdb.yaml
Normal file
@@ -0,0 +1,74 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: wrestlingdev-influxdb
|
||||
labels:
|
||||
app: wrestlingdev
|
||||
tier: metrics
|
||||
spec:
|
||||
ports:
|
||||
- port: 8086
|
||||
selector:
|
||||
app: wrestlingdev
|
||||
tier: metrics
|
||||
clusterIP: None
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: wrestlingdev-influxdb
|
||||
labels:
|
||||
app: wrestlingdev
|
||||
tier: metrics
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: wrestlingdev
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: wrestlingdev
|
||||
tier: metrics
|
||||
spec:
|
||||
containers:
|
||||
- name: wrestlingdev-influxdb
|
||||
image: influxdb:1.8-alpine
|
||||
ports:
|
||||
- containerPort: 8086
|
||||
env:
|
||||
- name: INFLUXDB_DB
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: influxdb_database
|
||||
volumeMounts:
|
||||
- name: wrestlingdev-influxdb-persistent-storage
|
||||
mountPath: /var/lib/influxdb
|
||||
resources:
|
||||
limits:
|
||||
cpu: "0.7"
|
||||
memory: "512Mi"
|
||||
requests:
|
||||
memory: "128Mi"
|
||||
cpu: "0.5"
|
||||
volumes:
|
||||
- name: wrestlingdev-influxdb-persistent-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: wrestlingdev-influxdb-pv-claim
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: wrestlingdev-influxdb-pv-claim
|
||||
labels:
|
||||
app: wrestlingdev
|
||||
tier: metrics
|
||||
spec:
|
||||
storageClassName: standard
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 100Gi
|
||||
@@ -26,13 +26,16 @@ spec:
|
||||
requests:
|
||||
storage: 20Gi
|
||||
---
|
||||
apiVersion: apps/v1beta1
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: wrestlingdev-mariadb
|
||||
labels:
|
||||
app: wrestlingdev
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: wrestlingdev
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
@@ -40,6 +43,9 @@ spec:
|
||||
labels:
|
||||
app: wrestlingdev
|
||||
tier: mariadb
|
||||
annotations:
|
||||
prometheus.io/port: "9125"
|
||||
prometheus.io/scrape: "true"
|
||||
spec:
|
||||
containers:
|
||||
- image: mariadb:10.3
|
||||
@@ -63,6 +69,111 @@ spec:
|
||||
requests:
|
||||
memory: "256Mi"
|
||||
cpu: "0.2"
|
||||
- image: jcwimer/mariadb-rclone-backup-docker:10.3
|
||||
name: mariadb-backup
|
||||
env:
|
||||
- name: DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: dbpassword
|
||||
- name: CRON_SCHEDULE
|
||||
value: "@hourly" # hourly
|
||||
- name: DB_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: dbusername
|
||||
- name: DB_HOST
|
||||
value: "127.0.0.1"
|
||||
- name: DAYS_TO_KEEP
|
||||
value: "7"
|
||||
- name: RCLONE_TYPE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: rclone_type
|
||||
- name: S3_ACCESS_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: s3_access_id
|
||||
- name: S3_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: s3_access_key
|
||||
- name: S3_ENDPOINT
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: s3_endpoint
|
||||
- name: S3_REGION
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: s3_region
|
||||
- name: RCLONE_EXTRA_ARGS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: rclone_extra_args
|
||||
- name: RCLONE_PATH
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: rclone_path
|
||||
volumeMounts:
|
||||
- name: wrestlingdev-mariadb-persistent-storage
|
||||
mountPath: /var/lib/mysql
|
||||
resources:
|
||||
limits:
|
||||
cpu: "0.2"
|
||||
memory: "100Mi"
|
||||
requests:
|
||||
memory: "50Mi"
|
||||
cpu: "0.1"
|
||||
- image: prom/mysqld-exporter:v0.11.0
|
||||
name: mariadb-exporter
|
||||
ports:
|
||||
- containerPort: 9125
|
||||
name: http"
|
||||
args:
|
||||
- --web.listen-address=0.0.0.0:9125
|
||||
- --web.telemetry-path=/metrics
|
||||
- --collect.heartbeat
|
||||
- --collect.heartbeat.database=sys_operator
|
||||
env:
|
||||
- name: DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: dbpassword
|
||||
- name: DB_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: dbusername
|
||||
- name: DB_HOST
|
||||
value: "127.0.0.1:3306"
|
||||
- name: DATA_SOURCE_NAME
|
||||
value: $(DB_USERNAME):$(DB_PASSWORD)@($(DB_HOST))/
|
||||
- name: DAYS_TO_KEEP
|
||||
value: "7"
|
||||
resources:
|
||||
limits:
|
||||
cpu: "100m"
|
||||
memory: "128Mi"
|
||||
requests:
|
||||
memory: "32Mi"
|
||||
cpu: "10m"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /metrics
|
||||
port: 9125
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 30
|
||||
volumes:
|
||||
- name: wrestlingdev-mariadb-persistent-storage
|
||||
persistentVolumeClaim:
|
||||
|
||||
@@ -81,6 +81,21 @@ spec:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: gmailemail
|
||||
- name: WRESTLINGDEV_INFLUXDB_DATABASE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: influxdb_database
|
||||
- name: WRESTLINGDEV_INFLUXDB_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: influxdb_hostname
|
||||
- name: WRESTLINGDEV_INFLUXDB_PORT
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: influxdb_port
|
||||
resources:
|
||||
limits:
|
||||
cpu: "0.5"
|
||||
@@ -187,6 +202,21 @@ spec:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: gmailemail
|
||||
- name: WRESTLINGDEV_INFLUXDB_DATABASE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: influxdb_database
|
||||
- name: WRESTLINGDEV_INFLUXDB_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: influxdb_hostname
|
||||
- name: WRESTLINGDEV_INFLUXDB_PORT
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wrestlingdev-secrets
|
||||
key: influxdb_port
|
||||
command: ["bundle"]
|
||||
args: ["exec", "bin/delayed_job", "-n", "1", "run"]
|
||||
resources:
|
||||
|
||||
@@ -5,10 +5,24 @@ metadata:
|
||||
type: Opaque
|
||||
#data:
|
||||
stringData:
|
||||
dbusername: root
|
||||
dbpassword: PUT_SECRET_HERE
|
||||
dbhost: wrestlingdev-mariadb (if using the mariadb-standalone from this repo, otherwise use your hostname for your database)
|
||||
devisesecretkey: PUT_SECRET_HERE get from running rails secret
|
||||
railssecretkey: PUT_SECRET_HERE get from running rails secret
|
||||
emailpassword: PUT_EMAIL_PASSWORD_HERE
|
||||
gmailemail: PUT EMAIL ADDRESS HERE
|
||||
# REQUIRED
|
||||
dbusername: root # if using the mariadb-standalone from this repo, otherwise use your username for your database
|
||||
dbpassword: PUT_SECRET_HERE # db password
|
||||
dbhost: wrestlingdev-mariadb # if using the mariadb-standalone from this repo, otherwise use your hostname for your database
|
||||
devisesecretkey: PUT_SECRET_HERE # get from running rails secret
|
||||
railssecretkey: PUT_SECRET_HERE # get from running rails secret
|
||||
emailpassword: PUT_EMAIL_PASSWORD_HERE # gmail password
|
||||
gmailemail: PUT EMAIL ADDRESS HERE
|
||||
# OPTIONAL
|
||||
# DELETE THESE LINES IF YOU'RE NOT USING THEM
|
||||
influxdb_database: PUT INFLUXDB DATABASE NAME HERE
|
||||
influxdb_hostname: PUT INFLUXDB HOSTNAME OR IP HERE
|
||||
influxdb_port: PUT INFLUXDB PORT HERE
|
||||
rclone_type: s3
|
||||
rclone_extra_args: # example --no-check-certificate for self signed ssl minio certs
|
||||
rclone_path: # path to put the backup, for example this would be the bucket name for s3
|
||||
# required if rclone_type is s3
|
||||
s3_access_id:
|
||||
s3_access_key:
|
||||
s3_endpoint:
|
||||
s3_region:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM ruby:2.6.5
|
||||
FROM ruby:3.0.0
|
||||
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -qq install -y \
|
||||
@@ -22,7 +22,8 @@ RUN gem install bundler
|
||||
RUN gem update --system
|
||||
ADD Gemfile* /tmp/
|
||||
WORKDIR /tmp
|
||||
RUN bundle install --jobs 4 --without production
|
||||
RUN bundle config set without 'production'
|
||||
RUN bundle install --jobs 4
|
||||
|
||||
RUN mkdir /rails
|
||||
WORKDIR /rails
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM ruby:2.6.5-slim
|
||||
FROM ruby:3.0.0-slim
|
||||
|
||||
#HEALTHCHECK --start-period=60s CMD curl http://127.0.0.1/
|
||||
|
||||
@@ -17,6 +17,7 @@ RUN apt-get -qq update \
|
||||
default-libmysqlclient-dev \
|
||||
nodejs \
|
||||
tzdata \
|
||||
git \
|
||||
&& apt-get -qq clean \
|
||||
&& apt-get autoremove -y \
|
||||
&& rm -rf \
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
task :finish_seed_tournament => :environment do
|
||||
@tournament = Tournament.where(:id => 200).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first
|
||||
GenerateTournamentMatches.new(@tournament).generate
|
||||
(1..@tournament.reload.total_rounds).each do |round|
|
||||
@tournament.reload.matches_by_round(round).select{|m| m.finished != 1}.each do |match|
|
||||
match.reload
|
||||
if match.wrestler1.bracket_line < match.wrestler2.bracket_line and match.w1
|
||||
match.winner_id = match.w1
|
||||
elsif match.w2
|
||||
match.winner_id = match.w2
|
||||
end
|
||||
if match.winner_id
|
||||
match.finished = 1
|
||||
match.score = "2-1"
|
||||
match.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
27
lib/tasks/finish_seed_tournaments.rake
Normal file
27
lib/tasks/finish_seed_tournaments.rake
Normal file
@@ -0,0 +1,27 @@
|
||||
task :finish_seed_tournaments => :environment do
|
||||
finish_tournament(tournament_id)
|
||||
@tournament = Tournament.where(:id => tournament_id).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first
|
||||
GenerateTournamentMatches.new(@tournament).generate
|
||||
(1..@tournament.reload.total_rounds).each do |round|
|
||||
@tournament.reload.matches_by_round(round).select{|m| m.finished != 1}.each do |match|
|
||||
match.reload
|
||||
if match.wrestler1.bracket_line < match.wrestler2.bracket_line and match.w1
|
||||
match.winner_id = match.w1
|
||||
elsif match.w2
|
||||
match.winner_id = match.w2
|
||||
end
|
||||
if match.winner_id
|
||||
match.finished = 1
|
||||
match.score = "2-1"
|
||||
match.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
finish_tournament(200)
|
||||
finish_tournament(201)
|
||||
finish_tournament(202)
|
||||
finish_tournament(203)
|
||||
finish_tournament(204)
|
||||
|
||||
end
|
||||
@@ -0,0 +1,65 @@
|
||||
require 'test_helper'
|
||||
|
||||
class EightManDoubleEliminationSixPlacesRunThrough < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
end
|
||||
|
||||
def winner_by_name(winner_name,match)
|
||||
wrestler = @tournament.weights.first.wrestlers.select{|w| w.name == winner_name}.first
|
||||
match.winner_id = wrestler.id
|
||||
match.finished = 1
|
||||
match.win_type = "Decision"
|
||||
match.score = "0-0"
|
||||
match.save
|
||||
end
|
||||
|
||||
test "8 man double elimination" do
|
||||
create_double_elim_tournament_single_weight_1_6(6)
|
||||
matches = @tournament.matches.reload
|
||||
|
||||
round1 = matches.select{|m| m.round == 1}
|
||||
winner_by_name("Test4", round1.select{|m| m.bracket_position_number == 2}.first)
|
||||
winner_by_name("Test3", round1.select{|m| m.bracket_position_number == 3}.first)
|
||||
|
||||
semis = matches.select{|m| m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert semis.first.reload.wrestler1.name == "Test1"
|
||||
assert semis.first.reload.wrestler2.name == "Test4"
|
||||
assert semis.second.reload.wrestler1.name == "Test3"
|
||||
assert semis.second.reload.wrestler2.name == "Test2"
|
||||
winner_by_name("Test4",semis.first)
|
||||
winner_by_name("Test2",semis.second)
|
||||
|
||||
conso_quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_quarter.first.reload.loser1_name == "BYE"
|
||||
assert conso_quarter.first.reload.wrestler2.name == "Test5"
|
||||
assert conso_quarter.second.reload.wrestler1.name == "Test6"
|
||||
assert conso_quarter.second.reload.loser2_name == "BYE"
|
||||
|
||||
conso_semis = matches.select{|m| m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_semis.first.reload.wrestler1.name == "Test3"
|
||||
assert conso_semis.first.reload.wrestler2.name == "Test5"
|
||||
assert conso_semis.second.reload.wrestler1.name == "Test1"
|
||||
assert conso_semis.second.reload.wrestler2.name == "Test6"
|
||||
winner_by_name("Test5",conso_semis.first)
|
||||
winner_by_name("Test1",conso_semis.second)
|
||||
|
||||
first_finals = matches.select{|m| m.bracket_position == "1/2"}.first
|
||||
third_finals = matches.select{|m| m.bracket_position == "3/4"}.first
|
||||
fifth_finals = matches.select{|m| m.bracket_position == "5/6"}.first
|
||||
|
||||
assert first_finals.reload.wrestler1.name == "Test4"
|
||||
assert first_finals.reload.wrestler2.name == "Test2"
|
||||
|
||||
assert third_finals.reload.wrestler1.name == "Test5"
|
||||
assert third_finals.reload.wrestler2.name == "Test1"
|
||||
|
||||
assert fifth_finals.reload.wrestler1.name == "Test3"
|
||||
assert fifth_finals.reload.wrestler2.name == "Test6"
|
||||
|
||||
# DEBUG
|
||||
# matches.sort_by{|m| m.bout_number}.each do |match|
|
||||
# match.reload
|
||||
# puts "Round #{match.round} #{match.w1_bracket_name} vs #{match.w2_bracket_name}"
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DoubleEliminationSixteenManMatchGeneration < ActionDispatch::IntegrationTest
|
||||
class DoubleEliminationSixteenManSixPlacesMatchGeneration < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
create_double_elim_tournament_single_weight_1_6(14)
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DoubleEliminationRunThrough < ActionDispatch::IntegrationTest
|
||||
class DoubleEliminationSixteenManSixPlacesRunThrough < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
end
|
||||
|
||||
@@ -13,57 +13,7 @@ class DoubleEliminationRunThrough < ActionDispatch::IntegrationTest
|
||||
match.save
|
||||
end
|
||||
|
||||
test "8 man double elimination" do
|
||||
create_double_elim_tournament_single_weight_1_6(6)
|
||||
matches = @tournament.matches.reload
|
||||
|
||||
round1 = matches.select{|m| m.round == 1}
|
||||
winner_by_name("Test4", round1.select{|m| m.bracket_position_number == 2}.first)
|
||||
winner_by_name("Test3", round1.select{|m| m.bracket_position_number == 3}.first)
|
||||
|
||||
semis = matches.select{|m| m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert semis.first.reload.wrestler1.name == "Test1"
|
||||
assert semis.first.reload.wrestler2.name == "Test4"
|
||||
assert semis.second.reload.wrestler1.name == "Test3"
|
||||
assert semis.second.reload.wrestler2.name == "Test2"
|
||||
winner_by_name("Test4",semis.first)
|
||||
winner_by_name("Test2",semis.second)
|
||||
|
||||
conso_quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_quarter.first.reload.loser1_name == "BYE"
|
||||
assert conso_quarter.first.reload.wrestler2.name == "Test5"
|
||||
assert conso_quarter.second.reload.wrestler1.name == "Test6"
|
||||
assert conso_quarter.second.reload.loser2_name == "BYE"
|
||||
|
||||
conso_semis = matches.select{|m| m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_semis.first.reload.wrestler1.name == "Test3"
|
||||
assert conso_semis.first.reload.wrestler2.name == "Test5"
|
||||
assert conso_semis.second.reload.wrestler1.name == "Test1"
|
||||
assert conso_semis.second.reload.wrestler2.name == "Test6"
|
||||
winner_by_name("Test5",conso_semis.first)
|
||||
winner_by_name("Test1",conso_semis.second)
|
||||
|
||||
first_finals = matches.select{|m| m.bracket_position == "1/2"}.first
|
||||
third_finals = matches.select{|m| m.bracket_position == "3/4"}.first
|
||||
fifth_finals = matches.select{|m| m.bracket_position == "5/6"}.first
|
||||
|
||||
assert first_finals.reload.wrestler1.name == "Test4"
|
||||
assert first_finals.reload.wrestler2.name == "Test2"
|
||||
|
||||
assert third_finals.reload.wrestler1.name == "Test5"
|
||||
assert third_finals.reload.wrestler2.name == "Test1"
|
||||
|
||||
assert fifth_finals.reload.wrestler1.name == "Test3"
|
||||
assert fifth_finals.reload.wrestler2.name == "Test6"
|
||||
|
||||
# DEBUG
|
||||
# matches.sort_by{|m| m.bout_number}.each do |match|
|
||||
# match.reload
|
||||
# puts "Round #{match.round} #{match.w1_bracket_name} vs #{match.w2_bracket_name}"
|
||||
# end
|
||||
end
|
||||
|
||||
test "16 man double elimination" do
|
||||
test "16 man double elimination placing 6 run through" do
|
||||
create_double_elim_tournament_single_weight_1_6(14)
|
||||
matches = @tournament.matches.reload
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DoubleEliminationSixteenManEightPlacesMatchGeneration < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
|
||||
end
|
||||
|
||||
test "Match generation works" do
|
||||
assert @tournament.matches.count == 30
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "1/2"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "3/4"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "5/6"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "7/8"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Bracket" and m.round == 1}.count == 8
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2}.count == 4
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Quarter"}.count == 4
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Semis"}.count == 2
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 3}.count == 4
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso Quarter"}.count == 2
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso Semis"}.count == 2
|
||||
end
|
||||
|
||||
test "Seeded wrestlers have correct first line" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 2}.first
|
||||
match3 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 3}.first
|
||||
match4 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 4}.first
|
||||
match5 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 5}.first
|
||||
match6 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 6}.first
|
||||
match7 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 7}.first
|
||||
match8 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 8}.first
|
||||
|
||||
assert match1.wrestler1.bracket_line == 1
|
||||
assert match1.loser2_name == "BYE"
|
||||
|
||||
assert match2.wrestler1.bracket_line == 8
|
||||
assert match2.wrestler2.bracket_line == 9
|
||||
|
||||
assert match3.wrestler1.bracket_line == 5
|
||||
assert match3.wrestler2.bracket_line == 12
|
||||
|
||||
assert match4.wrestler1.bracket_line == 4
|
||||
assert match4.wrestler2.bracket_line == 14
|
||||
|
||||
assert match5.wrestler1.bracket_line == 3
|
||||
assert match5.wrestler2.bracket_line == 13
|
||||
|
||||
assert match6.wrestler1.bracket_line == 6
|
||||
assert match6.wrestler2.bracket_line == 11
|
||||
|
||||
assert match7.wrestler1.bracket_line == 7
|
||||
assert match7.wrestler2.bracket_line == 10
|
||||
|
||||
assert match8.wrestler1.bracket_line == 2
|
||||
assert match8.loser2_name == "BYE"
|
||||
end
|
||||
|
||||
test "Byes are advanced correctly" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 2 and match.bracket_position == "Quarter" and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 2 and match.bracket_position == "Quarter" and match.bracket_position_number == 4}.first
|
||||
|
||||
assert match1.wrestler1.name == "Test1"
|
||||
assert match2.wrestler2.name == "Test2"
|
||||
end
|
||||
|
||||
test "Loser names set up correctly" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 2}.first
|
||||
match3 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 3}.first
|
||||
match4 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 4}.first
|
||||
match5 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 5}.first
|
||||
match6 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 6}.first
|
||||
match7 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 7}.first
|
||||
match8 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 8}.first
|
||||
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 1}.first.loser1_name == "BYE"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{match2.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 2}.first.loser1_name == "Loser of #{match3.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 2}.first.loser2_name == "Loser of #{match4.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 3}.first.loser1_name == "Loser of #{match5.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 3}.first.loser2_name == "Loser of #{match6.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 4}.first.loser1_name == "Loser of #{match7.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 4}.first.loser2_name == "BYE"
|
||||
|
||||
quarter1 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 1}.first
|
||||
quarter2 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 2}.first
|
||||
quarter3 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 3}.first
|
||||
quarter4 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 4}.first
|
||||
consoround2match1 = @tournament.matches.select{|match| match.bracket_position == "Conso" and match.round == 3 && match.bracket_position_number == 1}.first
|
||||
consoround2match2 = @tournament.matches.select{|match| match.bracket_position == "Conso" and match.round == 3 && match.bracket_position_number == 2}.first
|
||||
consoround2match3 = @tournament.matches.select{|match| match.bracket_position == "Conso" and match.round == 3 && match.bracket_position_number == 3}.first
|
||||
consoround2match4 = @tournament.matches.select{|match| match.bracket_position == "Conso" and match.round == 3 && match.bracket_position_number == 4}.first
|
||||
|
||||
assert consoround2match1.loser1_name == "Loser of #{quarter4.bout_number}"
|
||||
assert consoround2match2.loser1_name == "Loser of #{quarter3.bout_number}"
|
||||
assert consoround2match3.loser1_name == "Loser of #{quarter2.bout_number}"
|
||||
assert consoround2match4.loser1_name == "Loser of #{quarter1.bout_number}"
|
||||
|
||||
semis1 = @tournament.matches.select{|match| match.bracket_position == "Semis" and match.bracket_position_number == 1}.first
|
||||
semis2 = @tournament.matches.select{|match| match.bracket_position == "Semis" and match.bracket_position_number == 2}.first
|
||||
consosemis1 = @tournament.matches.select{|match| match.bracket_position == "Conso Semis" and match.bracket_position_number == 1}.first
|
||||
consosemis2 = @tournament.matches.select{|match| match.bracket_position == "Conso Semis" and match.bracket_position_number == 2}.first
|
||||
|
||||
assert consosemis1.loser1_name == "Loser of #{semis1.bout_number}"
|
||||
assert consosemis2.loser1_name == "Loser of #{semis2.bout_number}"
|
||||
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "5/6" && m.bracket_position_number == 1}.first.loser1_name == "Loser of #{consosemis1.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "5/6" && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{consosemis2.bout_number}"
|
||||
|
||||
consoquarters1 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.bracket_position_number == 1}.first
|
||||
consoquarters2 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.bracket_position_number == 2}.first
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "7/8" && m.bracket_position_number == 1}.first.loser1_name == "Loser of #{consoquarters1.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "7/8" && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{consoquarters2.bout_number}"
|
||||
end
|
||||
|
||||
test "Placement points are given when moving through bracket" do
|
||||
match = @tournament.matches.select{|m| m.bracket_position == "Semis"}.first
|
||||
wrestler = get_wrestler_by_name("Test1")
|
||||
match.w1 = wrestler.id
|
||||
match.save
|
||||
|
||||
match2 = @tournament.matches.select{|m| m.bracket_position == "Conso Semis"}.first
|
||||
wrestler2 = get_wrestler_by_name("Test2")
|
||||
match2.w1 = wrestler2.id
|
||||
match2.save
|
||||
|
||||
match3 = @tournament.matches.select{|m| m.bracket_position == "Conso Quarter"}.first
|
||||
wrestler3 = get_wrestler_by_name("Test3")
|
||||
match3.w1 = wrestler3.id
|
||||
match3.save
|
||||
|
||||
assert wrestler.reload.placement_points == 3
|
||||
assert wrestler2.reload.placement_points == 3
|
||||
assert wrestler3.reload.placement_points == 1
|
||||
end
|
||||
|
||||
test "Run through all matches works" do
|
||||
@tournament.matches.sort_by{ |match| match.bout_number }.each do |match|
|
||||
match.reload
|
||||
if match.finished != 1 and match.w1 and match.w2
|
||||
match.winner_id = match.w1
|
||||
match.win_type = "Decision"
|
||||
match.score = "0-0"
|
||||
match.finished = 1
|
||||
match.save
|
||||
end
|
||||
end
|
||||
assert @tournament.matches.reload.select{|m| m.finished == 0}.count == 0
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,118 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DoubleEliminationSixteenManEightPlacesRunThrough < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
end
|
||||
|
||||
def winner_by_name(winner_name,match)
|
||||
wrestler = @tournament.weights.first.wrestlers.select{|w| w.name == winner_name}.first
|
||||
match.winner_id = wrestler.id
|
||||
match.finished = 1
|
||||
match.win_type = "Decision"
|
||||
match.score = "0-0"
|
||||
match.save
|
||||
end
|
||||
|
||||
test "16 man double elimination place 1-8" do
|
||||
create_double_elim_tournament_single_weight(14, "Regular Double Elimination 1-8")
|
||||
matches = @tournament.matches.reload
|
||||
|
||||
round1 = matches.select{|m| m.round == 1}
|
||||
winner_by_name("Test9", round1.select{|m| m.bracket_position_number == 2}.first)
|
||||
winner_by_name("Test5", round1.select{|m| m.bracket_position_number == 3}.first)
|
||||
winner_by_name("Test4", round1.select{|m| m.bracket_position_number == 4}.first)
|
||||
winner_by_name("Test13", round1.select{|m| m.bracket_position_number == 5}.first)
|
||||
winner_by_name("Test6", round1.select{|m| m.bracket_position_number == 6}.first)
|
||||
winner_by_name("Test10", round1.select{|m| m.bracket_position_number == 7}.first)
|
||||
|
||||
quarter = matches.select{|m| m.bracket_position == "Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert quarter.first.reload.wrestler1.name == "Test1"
|
||||
assert quarter.first.reload.wrestler2.name == "Test9"
|
||||
assert quarter.second.reload.wrestler1.name == "Test5"
|
||||
assert quarter.second.reload.wrestler2.name == "Test4"
|
||||
assert quarter.third.reload.wrestler1.name == "Test13"
|
||||
assert quarter.third.reload.wrestler2.name == "Test6"
|
||||
assert quarter.fourth.reload.wrestler1.name == "Test10"
|
||||
assert quarter.fourth.reload.wrestler2.name == "Test2"
|
||||
|
||||
conso_round2 = matches.select{|m| m.bracket_position == "Conso" and m.round == 2}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_round2.first.reload.wrestler2.name == "Test8"
|
||||
assert conso_round2.second.reload.wrestler1.name == "Test12"
|
||||
assert conso_round2.second.reload.wrestler2.name == "Test14"
|
||||
assert conso_round2.third.reload.wrestler1.name == "Test3"
|
||||
assert conso_round2.third.reload.wrestler2.name == "Test11"
|
||||
assert conso_round2.fourth.reload.wrestler1.name == "Test7"
|
||||
|
||||
winner_by_name("Test1", quarter.first)
|
||||
winner_by_name("Test5", quarter.second)
|
||||
winner_by_name("Test13", quarter.third)
|
||||
winner_by_name("Test10", quarter.fourth)
|
||||
winner_by_name("Test12", conso_round2.second)
|
||||
winner_by_name("Test3", conso_round2.third)
|
||||
|
||||
semis = matches.select{|m| m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert semis.first.reload.wrestler1.name == "Test1"
|
||||
assert semis.first.reload.wrestler2.name == "Test5"
|
||||
assert semis.second.reload.wrestler1.name == "Test13"
|
||||
assert semis.second.reload.wrestler2.name == "Test10"
|
||||
|
||||
conso_round3 = matches.select{|m| m.bracket_position == "Conso" and m.round == 3}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_round3.first.reload.wrestler1.name == "Test2"
|
||||
assert conso_round3.first.reload.wrestler2.name == "Test8"
|
||||
assert conso_round3.second.reload.wrestler1.name == "Test6"
|
||||
assert conso_round3.second.reload.wrestler2.name == "Test12"
|
||||
assert conso_round3.third.reload.wrestler1.name == "Test4"
|
||||
assert conso_round3.third.reload.wrestler2.name == "Test3"
|
||||
assert conso_round3.fourth.reload.wrestler1.name == "Test9"
|
||||
assert conso_round3.fourth.reload.wrestler2.name == "Test7"
|
||||
|
||||
winner_by_name("Test2", conso_round3.first)
|
||||
winner_by_name("Test6", conso_round3.second)
|
||||
winner_by_name("Test3", conso_round3.third)
|
||||
winner_by_name("Test9", conso_round3.fourth)
|
||||
|
||||
conso_quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_quarter.first.reload.wrestler1.name == "Test2"
|
||||
assert conso_quarter.first.reload.wrestler2.name == "Test6"
|
||||
assert conso_quarter.second.reload.wrestler1.name == "Test3"
|
||||
assert conso_quarter.second.reload.wrestler2.name == "Test9"
|
||||
|
||||
winner_by_name("Test5",semis.first)
|
||||
winner_by_name("Test10",semis.second)
|
||||
winner_by_name("Test2", conso_quarter.first)
|
||||
winner_by_name("Test3", conso_quarter.second)
|
||||
|
||||
conso_semis = matches.select{|m| m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_semis.first.reload.wrestler1.name == "Test1"
|
||||
assert conso_semis.first.reload.wrestler2.name == "Test2"
|
||||
assert conso_semis.second.reload.wrestler1.name == "Test13"
|
||||
assert conso_semis.second.reload.wrestler2.name == "Test3"
|
||||
|
||||
winner_by_name("Test2",conso_semis.first)
|
||||
winner_by_name("Test3",conso_semis.second)
|
||||
|
||||
first_finals = matches.select{|m| m.bracket_position == "1/2"}.first
|
||||
third_finals = matches.select{|m| m.bracket_position == "3/4"}.first
|
||||
fifth_finals = matches.select{|m| m.bracket_position == "5/6"}.first
|
||||
seventh_finals = matches.select{|m| m.bracket_position == "7/8"}.first
|
||||
|
||||
|
||||
assert first_finals.reload.wrestler1.name == "Test5"
|
||||
assert first_finals.reload.wrestler2.name == "Test10"
|
||||
|
||||
assert third_finals.reload.wrestler1.name == "Test2"
|
||||
assert third_finals.reload.wrestler2.name == "Test3"
|
||||
|
||||
assert fifth_finals.reload.wrestler1.name == "Test1"
|
||||
assert fifth_finals.reload.wrestler2.name == "Test13"
|
||||
|
||||
assert seventh_finals.reload.wrestler1.name == "Test6"
|
||||
assert seventh_finals.reload.wrestler2.name == "Test9"
|
||||
|
||||
# DEBUG
|
||||
# matches.sort_by{|m| m.bout_number}.each do |match|
|
||||
# match.reload
|
||||
# puts "Round #{match.round} #{match.w1_bracket_name} vs #{match.w2_bracket_name}"
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,129 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ModifiedDoubleEliminationSixPlacesManMatchGeneration < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
create_double_elim_tournament_single_weight(14, "Modified 16 Man Double Elimination 1-6")
|
||||
end
|
||||
|
||||
test "Match generation works" do
|
||||
assert @tournament.matches.count == 27
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "1/2"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "3/4"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "5/6"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Bracket" and m.round == 1}.count == 8
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2}.count == 4
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Quarter"}.count == 4
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Semis"}.count == 2
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso Quarter"}.count == 4
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso Semis"}.count == 2
|
||||
end
|
||||
|
||||
test "Seeded wrestlers have correct first line" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 2}.first
|
||||
match3 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 3}.first
|
||||
match4 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 4}.first
|
||||
match5 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 5}.first
|
||||
match6 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 6}.first
|
||||
match7 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 7}.first
|
||||
match8 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 8}.first
|
||||
|
||||
assert match1.wrestler1.bracket_line == 1
|
||||
assert match1.loser2_name == "BYE"
|
||||
|
||||
assert match2.wrestler1.bracket_line == 8
|
||||
assert match2.wrestler2.bracket_line == 9
|
||||
|
||||
assert match3.wrestler1.bracket_line == 5
|
||||
assert match3.wrestler2.bracket_line == 12
|
||||
|
||||
assert match4.wrestler1.bracket_line == 4
|
||||
assert match4.wrestler2.bracket_line == 14
|
||||
|
||||
assert match5.wrestler1.bracket_line == 3
|
||||
assert match5.wrestler2.bracket_line == 13
|
||||
|
||||
assert match6.wrestler1.bracket_line == 6
|
||||
assert match6.wrestler2.bracket_line == 11
|
||||
|
||||
assert match7.wrestler1.bracket_line == 7
|
||||
assert match7.wrestler2.bracket_line == 10
|
||||
|
||||
assert match8.wrestler1.bracket_line == 2
|
||||
assert match8.loser2_name == "BYE"
|
||||
end
|
||||
|
||||
test "Byes are advanced correctly" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 2 and match.bracket_position == "Quarter" and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 2 and match.bracket_position == "Quarter" and match.bracket_position_number == 4}.first
|
||||
|
||||
assert match1.wrestler1.name == "Test1"
|
||||
assert match2.wrestler2.name == "Test2"
|
||||
end
|
||||
|
||||
test "Loser names set up correctly" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 2}.first
|
||||
match3 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 3}.first
|
||||
match4 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 4}.first
|
||||
match5 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 5}.first
|
||||
match6 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 6}.first
|
||||
match7 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 7}.first
|
||||
match8 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 8}.first
|
||||
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 1}.first.loser1_name == "BYE"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{match2.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 2}.first.loser1_name == "Loser of #{match3.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 2}.first.loser2_name == "Loser of #{match4.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 3}.first.loser1_name == "Loser of #{match5.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 3}.first.loser2_name == "Loser of #{match6.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 4}.first.loser1_name == "Loser of #{match7.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 4}.first.loser2_name == "BYE"
|
||||
|
||||
quarter1 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 1}.first
|
||||
quarter2 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 2}.first
|
||||
quarter3 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 3}.first
|
||||
quarter4 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 4}.first
|
||||
consoround2match1 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.round == 3 && match.bracket_position_number == 1}.first
|
||||
consoround2match2 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.round == 3 && match.bracket_position_number == 2}.first
|
||||
consoround2match3 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.round == 3 && match.bracket_position_number == 3}.first
|
||||
consoround2match4 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.round == 3 && match.bracket_position_number == 4}.first
|
||||
|
||||
assert consoround2match1.loser1_name == "Loser of #{quarter4.bout_number}"
|
||||
assert consoround2match2.loser1_name == "Loser of #{quarter3.bout_number}"
|
||||
assert consoround2match3.loser1_name == "Loser of #{quarter2.bout_number}"
|
||||
assert consoround2match4.loser1_name == "Loser of #{quarter1.bout_number}"
|
||||
|
||||
semis1 = @tournament.matches.select{|match| match.bracket_position == "Semis" and match.bracket_position_number == 1}.first
|
||||
semis2 = @tournament.matches.select{|match| match.bracket_position == "Semis" and match.bracket_position_number == 2}.first
|
||||
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "3/4" && m.bracket_position_number == 1}.first.loser1_name == "Loser of #{semis1.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "3/4" && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{semis2.bout_number}"
|
||||
end
|
||||
|
||||
test "Placement points are given when moving through bracket" do
|
||||
match = @tournament.matches.select{|m| m.bracket_position == "Semis"}.first
|
||||
wrestler = get_wrestler_by_name("Test1")
|
||||
match.w1 = wrestler.id
|
||||
match.save
|
||||
|
||||
assert wrestler.reload.placement_points == 7
|
||||
end
|
||||
|
||||
test "Run through all matches works" do
|
||||
@tournament.matches.sort_by{ |match| match.bout_number }.each do |match|
|
||||
match.reload
|
||||
if match.finished != 1 and match.w1 and match.w2
|
||||
match.winner_id = match.w1
|
||||
match.win_type = "Decision"
|
||||
match.score = "0-0"
|
||||
match.finished = 1
|
||||
match.save
|
||||
end
|
||||
end
|
||||
assert @tournament.matches.reload.select{|m| m.finished == 0}.count == 0
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,104 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ModifiedDoubleEliminationSixPlacesRunThrough < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
end
|
||||
|
||||
def winner_by_name(winner_name,match)
|
||||
wrestler = @tournament.weights.first.wrestlers.select{|w| w.name == winner_name}.first
|
||||
match.winner_id = wrestler.id
|
||||
match.finished = 1
|
||||
match.win_type = "Decision"
|
||||
match.score = "0-0"
|
||||
match.save
|
||||
end
|
||||
|
||||
test "16 man modified double elimination placing 1-6" do
|
||||
@tournament = create_double_elim_tournament_single_weight(14, "Modified 16 Man Double Elimination 1-6")
|
||||
matches = @tournament.matches.reload
|
||||
|
||||
round1 = matches.select{|m| m.round == 1}
|
||||
winner_by_name("Test9", round1.select{|m| m.bracket_position_number == 2}.first)
|
||||
winner_by_name("Test5", round1.select{|m| m.bracket_position_number == 3}.first)
|
||||
winner_by_name("Test4", round1.select{|m| m.bracket_position_number == 4}.first)
|
||||
winner_by_name("Test13", round1.select{|m| m.bracket_position_number == 5}.first)
|
||||
winner_by_name("Test6", round1.select{|m| m.bracket_position_number == 6}.first)
|
||||
winner_by_name("Test10", round1.select{|m| m.bracket_position_number == 7}.first)
|
||||
|
||||
quarter = matches.select{|m| m.bracket_position == "Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert quarter.first.reload.wrestler1.name == "Test1"
|
||||
assert quarter.first.reload.wrestler2.name == "Test9"
|
||||
assert quarter.second.reload.wrestler1.name == "Test5"
|
||||
assert quarter.second.reload.wrestler2.name == "Test4"
|
||||
assert quarter.third.reload.wrestler1.name == "Test13"
|
||||
assert quarter.third.reload.wrestler2.name == "Test6"
|
||||
assert quarter.fourth.reload.wrestler1.name == "Test10"
|
||||
assert quarter.fourth.reload.wrestler2.name == "Test2"
|
||||
|
||||
conso_round2 = matches.select{|m| m.bracket_position == "Conso" and m.round == 2}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_round2.first.reload.wrestler2.name == "Test8"
|
||||
assert conso_round2.second.reload.wrestler1.name == "Test12"
|
||||
assert conso_round2.second.reload.wrestler2.name == "Test14"
|
||||
assert conso_round2.third.reload.wrestler1.name == "Test3"
|
||||
assert conso_round2.third.reload.wrestler2.name == "Test11"
|
||||
assert conso_round2.fourth.reload.wrestler1.name == "Test7"
|
||||
|
||||
winner_by_name("Test1", quarter.first)
|
||||
winner_by_name("Test5", quarter.second)
|
||||
winner_by_name("Test13", quarter.third)
|
||||
winner_by_name("Test10", quarter.fourth)
|
||||
winner_by_name("Test12", conso_round2.second)
|
||||
winner_by_name("Test3", conso_round2.third)
|
||||
|
||||
semis = matches.select{|m| m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert semis.first.reload.wrestler1.name == "Test1"
|
||||
assert semis.first.reload.wrestler2.name == "Test5"
|
||||
assert semis.second.reload.wrestler1.name == "Test13"
|
||||
assert semis.second.reload.wrestler2.name == "Test10"
|
||||
|
||||
conso_quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_quarter.first.reload.wrestler1.name == "Test2"
|
||||
assert conso_quarter.first.reload.wrestler2.name == "Test8"
|
||||
assert conso_quarter.second.reload.wrestler1.name == "Test6"
|
||||
assert conso_quarter.second.reload.wrestler2.name == "Test12"
|
||||
assert conso_quarter.third.reload.wrestler1.name == "Test4"
|
||||
assert conso_quarter.third.reload.wrestler2.name == "Test3"
|
||||
assert conso_quarter.fourth.reload.wrestler1.name == "Test9"
|
||||
assert conso_quarter.fourth.reload.wrestler2.name == "Test7"
|
||||
|
||||
winner_by_name("Test5",semis.first)
|
||||
winner_by_name("Test10",semis.second)
|
||||
winner_by_name("Test2", conso_quarter.first)
|
||||
winner_by_name("Test12", conso_quarter.second)
|
||||
winner_by_name("Test4", conso_quarter.third)
|
||||
winner_by_name("Test7", conso_quarter.fourth)
|
||||
|
||||
conso_semis = matches.select{|m| m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_semis.first.reload.wrestler1.name == "Test2"
|
||||
assert conso_semis.first.reload.wrestler2.name == "Test12"
|
||||
assert conso_semis.second.reload.wrestler1.name == "Test4"
|
||||
assert conso_semis.second.reload.wrestler2.name == "Test7"
|
||||
|
||||
winner_by_name("Test2",conso_semis.first)
|
||||
winner_by_name("Test4",conso_semis.second)
|
||||
|
||||
first_finals = matches.select{|m| m.bracket_position == "1/2"}.first
|
||||
third_finals = matches.select{|m| m.bracket_position == "3/4"}.first
|
||||
fifth_finals = matches.select{|m| m.bracket_position == "5/6"}.first
|
||||
|
||||
assert first_finals.reload.wrestler1.name == "Test5"
|
||||
assert first_finals.reload.wrestler2.name == "Test10"
|
||||
|
||||
assert third_finals.reload.wrestler1.name == "Test1"
|
||||
assert third_finals.reload.wrestler2.name == "Test13"
|
||||
|
||||
assert fifth_finals.reload.wrestler1.name == "Test2"
|
||||
assert fifth_finals.reload.wrestler2.name == "Test4"
|
||||
|
||||
# DEBUG
|
||||
# matches.sort_by{|m| m.bout_number}.each do |match|
|
||||
# match.reload
|
||||
# puts "Round #{match.round} #{match.w1_bracket_name} vs #{match.w2_bracket_name}"
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,142 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ModifiedDoubleEliminationEightPlacesManMatchGeneration < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
create_double_elim_tournament_single_weight(14, "Modified 16 Man Double Elimination 1-8")
|
||||
end
|
||||
|
||||
test "Match generation works" do
|
||||
assert @tournament.matches.count == 28
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "1/2"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "3/4"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "5/6"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "7/8"}.count == 1
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Bracket" and m.round == 1}.count == 8
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Quarter"}.count == 4
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Semis"}.count == 2
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2}.count == 4
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso Quarter"}.count == 4
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso Semis"}.count == 2
|
||||
end
|
||||
|
||||
test "Seeded wrestlers have correct first line" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 2}.first
|
||||
match3 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 3}.first
|
||||
match4 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 4}.first
|
||||
match5 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 5}.first
|
||||
match6 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 6}.first
|
||||
match7 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 7}.first
|
||||
match8 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 8}.first
|
||||
|
||||
assert match1.wrestler1.bracket_line == 1
|
||||
assert match1.loser2_name == "BYE"
|
||||
|
||||
assert match2.wrestler1.bracket_line == 8
|
||||
assert match2.wrestler2.bracket_line == 9
|
||||
|
||||
assert match3.wrestler1.bracket_line == 5
|
||||
assert match3.wrestler2.bracket_line == 12
|
||||
|
||||
assert match4.wrestler1.bracket_line == 4
|
||||
assert match4.wrestler2.bracket_line == 14
|
||||
|
||||
assert match5.wrestler1.bracket_line == 3
|
||||
assert match5.wrestler2.bracket_line == 13
|
||||
|
||||
assert match6.wrestler1.bracket_line == 6
|
||||
assert match6.wrestler2.bracket_line == 11
|
||||
|
||||
assert match7.wrestler1.bracket_line == 7
|
||||
assert match7.wrestler2.bracket_line == 10
|
||||
|
||||
assert match8.wrestler1.bracket_line == 2
|
||||
assert match8.loser2_name == "BYE"
|
||||
end
|
||||
|
||||
test "Byes are advanced correctly" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 2 and match.bracket_position == "Quarter" and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 2 and match.bracket_position == "Quarter" and match.bracket_position_number == 4}.first
|
||||
|
||||
assert match1.wrestler1.name == "Test1"
|
||||
assert match2.wrestler2.name == "Test2"
|
||||
end
|
||||
|
||||
test "Loser names set up correctly" do
|
||||
@tournament.matches.reload
|
||||
match1 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 1}.first
|
||||
match2 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 2}.first
|
||||
match3 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 3}.first
|
||||
match4 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 4}.first
|
||||
match5 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 5}.first
|
||||
match6 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 6}.first
|
||||
match7 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 7}.first
|
||||
match8 = @tournament.matches.select{|match| match.round == 1 and match.bracket_position_number == 8}.first
|
||||
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 1}.first.loser1_name == "BYE"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{match2.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 2}.first.loser1_name == "Loser of #{match3.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 2}.first.loser2_name == "Loser of #{match4.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 3}.first.loser1_name == "Loser of #{match5.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 3}.first.loser2_name == "Loser of #{match6.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 4}.first.loser1_name == "Loser of #{match7.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "Conso" and m.round == 2 && m.bracket_position_number == 4}.first.loser2_name == "BYE"
|
||||
|
||||
quarter1 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 1}.first
|
||||
quarter2 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 2}.first
|
||||
quarter3 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 3}.first
|
||||
quarter4 = @tournament.matches.select{|match| match.bracket_position == "Quarter" and match.bracket_position_number == 4}.first
|
||||
consoround2match1 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.round == 3 && match.bracket_position_number == 1}.first
|
||||
consoround2match2 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.round == 3 && match.bracket_position_number == 2}.first
|
||||
consoround2match3 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.round == 3 && match.bracket_position_number == 3}.first
|
||||
consoround2match4 = @tournament.matches.select{|match| match.bracket_position == "Conso Quarter" and match.round == 3 && match.bracket_position_number == 4}.first
|
||||
|
||||
assert consoround2match1.loser1_name == "Loser of #{quarter4.bout_number}"
|
||||
assert consoround2match2.loser1_name == "Loser of #{quarter3.bout_number}"
|
||||
assert consoround2match3.loser1_name == "Loser of #{quarter2.bout_number}"
|
||||
assert consoround2match4.loser1_name == "Loser of #{quarter1.bout_number}"
|
||||
|
||||
semis1 = @tournament.matches.select{|match| match.bracket_position == "Semis" and match.bracket_position_number == 1}.first
|
||||
semis2 = @tournament.matches.select{|match| match.bracket_position == "Semis" and match.bracket_position_number == 2}.first
|
||||
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "3/4" && m.bracket_position_number == 1}.first.loser1_name == "Loser of #{semis1.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "3/4" && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{semis2.bout_number}"
|
||||
|
||||
consosemis1 = @tournament.matches.select{|match| match.bracket_position == "Conso Semis" and match.bracket_position_number == 1}.first
|
||||
consosemis2 = @tournament.matches.select{|match| match.bracket_position == "Conso Semis" and match.bracket_position_number == 2}.first
|
||||
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "7/8" && m.bracket_position_number == 1}.first.loser1_name == "Loser of #{consosemis1.bout_number}"
|
||||
assert @tournament.matches.select{|m| m.bracket_position == "7/8" && m.bracket_position_number == 1}.first.loser2_name == "Loser of #{consosemis2.bout_number}"
|
||||
end
|
||||
|
||||
test "Placement points are given when moving through bracket" do
|
||||
match = @tournament.matches.select{|m| m.bracket_position == "Semis"}.first
|
||||
wrestler = get_wrestler_by_name("Test1")
|
||||
match.w1 = wrestler.id
|
||||
match.save
|
||||
|
||||
match2 = @tournament.matches.select{|m| m.bracket_position == "Conso Semis"}.first
|
||||
wrestler2 = get_wrestler_by_name("Test2")
|
||||
match2.w1 = wrestler2.id
|
||||
match2.save
|
||||
|
||||
assert wrestler.reload.placement_points == 7
|
||||
assert wrestler2.reload.placement_points == 1
|
||||
end
|
||||
|
||||
test "Run through all matches works" do
|
||||
@tournament.matches.sort_by{ |match| match.bout_number }.each do |match|
|
||||
match.reload
|
||||
if match.finished != 1 and match.w1 and match.w2
|
||||
match.winner_id = match.w1
|
||||
match.win_type = "Decision"
|
||||
match.score = "0-0"
|
||||
match.finished = 1
|
||||
match.save
|
||||
end
|
||||
end
|
||||
assert @tournament.matches.reload.select{|m| m.finished == 0}.count == 0
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,108 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ModifiedDoubleEliminationEightPlacesRunThrough < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
end
|
||||
|
||||
def winner_by_name(winner_name,match)
|
||||
wrestler = @tournament.weights.first.wrestlers.select{|w| w.name == winner_name}.first
|
||||
match.winner_id = wrestler.id
|
||||
match.finished = 1
|
||||
match.win_type = "Decision"
|
||||
match.score = "0-0"
|
||||
match.save
|
||||
end
|
||||
|
||||
test "16 man modified double elimination placing 1-8" do
|
||||
@tournament = create_double_elim_tournament_single_weight(14, "Modified 16 Man Double Elimination 1-8")
|
||||
matches = @tournament.matches.reload
|
||||
|
||||
round1 = matches.select{|m| m.round == 1}
|
||||
winner_by_name("Test9", round1.select{|m| m.bracket_position_number == 2}.first)
|
||||
winner_by_name("Test5", round1.select{|m| m.bracket_position_number == 3}.first)
|
||||
winner_by_name("Test4", round1.select{|m| m.bracket_position_number == 4}.first)
|
||||
winner_by_name("Test13", round1.select{|m| m.bracket_position_number == 5}.first)
|
||||
winner_by_name("Test6", round1.select{|m| m.bracket_position_number == 6}.first)
|
||||
winner_by_name("Test10", round1.select{|m| m.bracket_position_number == 7}.first)
|
||||
|
||||
quarter = matches.select{|m| m.bracket_position == "Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert quarter.first.reload.wrestler1.name == "Test1"
|
||||
assert quarter.first.reload.wrestler2.name == "Test9"
|
||||
assert quarter.second.reload.wrestler1.name == "Test5"
|
||||
assert quarter.second.reload.wrestler2.name == "Test4"
|
||||
assert quarter.third.reload.wrestler1.name == "Test13"
|
||||
assert quarter.third.reload.wrestler2.name == "Test6"
|
||||
assert quarter.fourth.reload.wrestler1.name == "Test10"
|
||||
assert quarter.fourth.reload.wrestler2.name == "Test2"
|
||||
|
||||
conso_round2 = matches.select{|m| m.bracket_position == "Conso" and m.round == 2}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_round2.first.reload.wrestler2.name == "Test8"
|
||||
assert conso_round2.second.reload.wrestler1.name == "Test12"
|
||||
assert conso_round2.second.reload.wrestler2.name == "Test14"
|
||||
assert conso_round2.third.reload.wrestler1.name == "Test3"
|
||||
assert conso_round2.third.reload.wrestler2.name == "Test11"
|
||||
assert conso_round2.fourth.reload.wrestler1.name == "Test7"
|
||||
|
||||
winner_by_name("Test1", quarter.first)
|
||||
winner_by_name("Test5", quarter.second)
|
||||
winner_by_name("Test13", quarter.third)
|
||||
winner_by_name("Test10", quarter.fourth)
|
||||
winner_by_name("Test12", conso_round2.second)
|
||||
winner_by_name("Test3", conso_round2.third)
|
||||
|
||||
semis = matches.select{|m| m.bracket_position == "Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert semis.first.reload.wrestler1.name == "Test1"
|
||||
assert semis.first.reload.wrestler2.name == "Test5"
|
||||
assert semis.second.reload.wrestler1.name == "Test13"
|
||||
assert semis.second.reload.wrestler2.name == "Test10"
|
||||
|
||||
conso_quarter = matches.select{|m| m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_quarter.first.reload.wrestler1.name == "Test2"
|
||||
assert conso_quarter.first.reload.wrestler2.name == "Test8"
|
||||
assert conso_quarter.second.reload.wrestler1.name == "Test6"
|
||||
assert conso_quarter.second.reload.wrestler2.name == "Test12"
|
||||
assert conso_quarter.third.reload.wrestler1.name == "Test4"
|
||||
assert conso_quarter.third.reload.wrestler2.name == "Test3"
|
||||
assert conso_quarter.fourth.reload.wrestler1.name == "Test9"
|
||||
assert conso_quarter.fourth.reload.wrestler2.name == "Test7"
|
||||
|
||||
winner_by_name("Test5",semis.first)
|
||||
winner_by_name("Test10",semis.second)
|
||||
winner_by_name("Test2", conso_quarter.first)
|
||||
winner_by_name("Test12", conso_quarter.second)
|
||||
winner_by_name("Test4", conso_quarter.third)
|
||||
winner_by_name("Test7", conso_quarter.fourth)
|
||||
|
||||
conso_semis = matches.select{|m| m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}
|
||||
assert conso_semis.first.reload.wrestler1.name == "Test2"
|
||||
assert conso_semis.first.reload.wrestler2.name == "Test12"
|
||||
assert conso_semis.second.reload.wrestler1.name == "Test4"
|
||||
assert conso_semis.second.reload.wrestler2.name == "Test7"
|
||||
|
||||
winner_by_name("Test2",conso_semis.first)
|
||||
winner_by_name("Test4",conso_semis.second)
|
||||
|
||||
first_finals = matches.select{|m| m.bracket_position == "1/2"}.first
|
||||
third_finals = matches.select{|m| m.bracket_position == "3/4"}.first
|
||||
fifth_finals = matches.select{|m| m.bracket_position == "5/6"}.first
|
||||
seventh_finals = matches.select{|m| m.bracket_position == "7/8"}.first
|
||||
|
||||
assert first_finals.reload.wrestler1.name == "Test5"
|
||||
assert first_finals.reload.wrestler2.name == "Test10"
|
||||
|
||||
assert third_finals.reload.wrestler1.name == "Test1"
|
||||
assert third_finals.reload.wrestler2.name == "Test13"
|
||||
|
||||
assert fifth_finals.reload.wrestler1.name == "Test2"
|
||||
assert fifth_finals.reload.wrestler2.name == "Test4"
|
||||
|
||||
assert seventh_finals.reload.wrestler1.name == "Test12"
|
||||
assert seventh_finals.reload.wrestler2.name == "Test7"
|
||||
|
||||
# DEBUG
|
||||
# matches.sort_by{|m| m.bout_number}.each do |match|
|
||||
# match.reload
|
||||
# puts "Round #{match.round} #{match.w1_bracket_name} vs #{match.w2_bracket_name}"
|
||||
# end
|
||||
end
|
||||
end
|
||||
@@ -8,6 +8,6 @@ class MatTest < ActiveSupport::TestCase
|
||||
test "Mat validations" do
|
||||
mat = Mat.new
|
||||
assert_not mat.valid?
|
||||
assert_equal [:name], mat.errors.keys
|
||||
assert_equal [:name], mat.errors.attribute_names
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,6 @@ class SchoolTest < ActiveSupport::TestCase
|
||||
test "School validations" do
|
||||
school = School.new
|
||||
assert_not school.valid?
|
||||
assert_equal [:name], school.errors.keys
|
||||
assert_equal [:name], school.errors.attribute_names
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,6 +9,22 @@ class TournamentTest < ActiveSupport::TestCase
|
||||
test "Tournament validations" do
|
||||
tourney = Tournament.new
|
||||
assert_not tourney.valid?
|
||||
assert_equal [:date, :name, :tournament_type, :address, :director, :director_email], tourney.errors.keys
|
||||
assert_equal [:date, :name, :tournament_type, :address, :director, :director_email], tourney.errors.attribute_names
|
||||
end
|
||||
|
||||
test "Tournament create_pre_defined_weights High School Boys Weights" do
|
||||
tournament = Tournament.find(1)
|
||||
tournament.create_pre_defined_weights(Weight::HS_WEIGHT_CLASSES.split(","))
|
||||
Weight::HS_WEIGHT_CLASSES.split(",").each do |weight|
|
||||
assert tournament.weights.select{|w| w.max == weight.to_i}.count == 1
|
||||
end
|
||||
end
|
||||
|
||||
test "Tournament create_pre_defined_weights High School Girls Weights" do
|
||||
tournament = Tournament.find(1)
|
||||
tournament.create_pre_defined_weights(Weight::HS_GIRLS_WEIGHT_CLASSES.split(","))
|
||||
Weight::HS_GIRLS_WEIGHT_CLASSES.split(",").each do |weight|
|
||||
assert tournament.weights.select{|w| w.max == weight.to_i}.count == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,6 @@ class WeightTest < ActiveSupport::TestCase
|
||||
test "Weight validations" do
|
||||
weight = Weight.new
|
||||
assert_not weight.valid?
|
||||
assert_equal [:max], weight.errors.keys
|
||||
assert_equal [:max], weight.errors.attribute_names
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,6 @@ class WrestlerTest < ActiveSupport::TestCase
|
||||
test "Wrestler validations" do
|
||||
wrestler = Wrestler.new
|
||||
assert_not wrestler.valid?
|
||||
assert_equal [:name, :weight_id, :school_id], wrestler.errors.keys
|
||||
assert_equal [:name, :weight_id, :school_id], wrestler.errors.attribute_names
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,7 +41,29 @@ class ActiveSupport::TestCase
|
||||
@tournament.address = "some place"
|
||||
@tournament.director = "some guy"
|
||||
@tournament.director_email= "test@test.com"
|
||||
@tournament.tournament_type = "Double Elimination 1-6"
|
||||
@tournament.tournament_type = "Regular Double Elimination 1-6"
|
||||
@tournament.date = "2015-12-30"
|
||||
@tournament.save
|
||||
@school = School.new
|
||||
@school.name = "Test"
|
||||
@school.tournament_id = @tournament.id
|
||||
@school.save
|
||||
@weight = Weight.new
|
||||
@weight.max = 106
|
||||
@weight.tournament_id = @tournament.id
|
||||
@weight.save
|
||||
create_wrestlers_for_weight_for_double_elim(@weight, @school, number_of_wrestlers, 1)
|
||||
GenerateTournamentMatches.new(@tournament).generate
|
||||
return @tournament
|
||||
end
|
||||
|
||||
def create_double_elim_tournament_single_weight(number_of_wrestlers, tournament_type)
|
||||
@tournament = Tournament.new
|
||||
@tournament.name = "Test Tournament"
|
||||
@tournament.address = "some place"
|
||||
@tournament.director = "some guy"
|
||||
@tournament.director_email= "test@test.com"
|
||||
@tournament.tournament_type = tournament_type
|
||||
@tournament.date = "2015-12-30"
|
||||
@tournament.save
|
||||
@school = School.new
|
||||
|
||||
Reference in New Issue
Block a user