mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-05-09 23:33:26 +00:00
Compare commits
32 Commits
circleci-p
...
e36de59971
| Author | SHA1 | Date | |
|---|---|---|---|
| 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
|
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:
|
jobs:
|
||||||
build:
|
build:
|
||||||
machine: true
|
machine: true
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
# start proprietary DB using private Docker image
|
|
||||||
# with credentials stored in the UI
|
|
||||||
- run: |
|
- 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
|
|
||||||
4
Gemfile
4
Gemfile
@@ -1,8 +1,8 @@
|
|||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
ruby '2.6.5'
|
ruby '3.0.0'
|
||||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||||
gem 'rails', '6.0.3.2'
|
gem 'rails', '6.1.2'
|
||||||
# Use sqlite3 as the database for Active Record
|
# Use sqlite3 as the database for Active Record
|
||||||
#gem 'sqlite3', '~> 1.3', '< 1.4', :group => :development
|
#gem 'sqlite3', '~> 1.3', '< 1.4', :group => :development
|
||||||
gem 'sqlite3', :group => :development
|
gem 'sqlite3', :group => :development
|
||||||
|
|||||||
231
Gemfile.lock
231
Gemfile.lock
@@ -1,71 +1,75 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actioncable (6.0.3.2)
|
actioncable (6.1.2)
|
||||||
actionpack (= 6.0.3.2)
|
actionpack (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
websocket-driver (>= 0.6.1)
|
websocket-driver (>= 0.6.1)
|
||||||
actionmailbox (6.0.3.2)
|
actionmailbox (6.1.2)
|
||||||
actionpack (= 6.0.3.2)
|
actionpack (= 6.1.2)
|
||||||
activejob (= 6.0.3.2)
|
activejob (= 6.1.2)
|
||||||
activerecord (= 6.0.3.2)
|
activerecord (= 6.1.2)
|
||||||
activestorage (= 6.0.3.2)
|
activestorage (= 6.1.2)
|
||||||
activesupport (= 6.0.3.2)
|
activesupport (= 6.1.2)
|
||||||
mail (>= 2.7.1)
|
mail (>= 2.7.1)
|
||||||
actionmailer (6.0.3.2)
|
actionmailer (6.1.2)
|
||||||
actionpack (= 6.0.3.2)
|
actionpack (= 6.1.2)
|
||||||
actionview (= 6.0.3.2)
|
actionview (= 6.1.2)
|
||||||
activejob (= 6.0.3.2)
|
activejob (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
mail (~> 2.5, >= 2.5.4)
|
mail (~> 2.5, >= 2.5.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
actionpack (6.0.3.2)
|
actionpack (6.1.2)
|
||||||
actionview (= 6.0.3.2)
|
actionview (= 6.1.2)
|
||||||
activesupport (= 6.0.3.2)
|
activesupport (= 6.1.2)
|
||||||
rack (~> 2.0, >= 2.0.8)
|
rack (~> 2.0, >= 2.0.9)
|
||||||
rack-test (>= 0.6.3)
|
rack-test (>= 0.6.3)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
||||||
actiontext (6.0.3.2)
|
actiontext (6.1.2)
|
||||||
actionpack (= 6.0.3.2)
|
actionpack (= 6.1.2)
|
||||||
activerecord (= 6.0.3.2)
|
activerecord (= 6.1.2)
|
||||||
activestorage (= 6.0.3.2)
|
activestorage (= 6.1.2)
|
||||||
activesupport (= 6.0.3.2)
|
activesupport (= 6.1.2)
|
||||||
nokogiri (>= 1.8.5)
|
nokogiri (>= 1.8.5)
|
||||||
actionview (6.0.3.2)
|
actionview (6.1.2)
|
||||||
activesupport (= 6.0.3.2)
|
activesupport (= 6.1.2)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubi (~> 1.4)
|
erubi (~> 1.4)
|
||||||
rails-dom-testing (~> 2.0)
|
rails-dom-testing (~> 2.0)
|
||||||
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
||||||
activejob (6.0.3.2)
|
activejob (6.1.2)
|
||||||
activesupport (= 6.0.3.2)
|
activesupport (= 6.1.2)
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
activemodel (6.0.3.2)
|
activemodel (6.1.2)
|
||||||
activesupport (= 6.0.3.2)
|
activesupport (= 6.1.2)
|
||||||
activerecord (6.0.3.2)
|
activerecord (6.1.2)
|
||||||
activemodel (= 6.0.3.2)
|
activemodel (= 6.1.2)
|
||||||
activesupport (= 6.0.3.2)
|
activesupport (= 6.1.2)
|
||||||
activestorage (6.0.3.2)
|
activestorage (6.1.2)
|
||||||
actionpack (= 6.0.3.2)
|
actionpack (= 6.1.2)
|
||||||
activejob (= 6.0.3.2)
|
activejob (= 6.1.2)
|
||||||
activerecord (= 6.0.3.2)
|
activerecord (= 6.1.2)
|
||||||
|
activesupport (= 6.1.2)
|
||||||
marcel (~> 0.3.1)
|
marcel (~> 0.3.1)
|
||||||
activesupport (6.0.3.2)
|
mimemagic (~> 0.3.2)
|
||||||
|
activesupport (6.1.2)
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||||
i18n (>= 0.7, < 2)
|
i18n (>= 1.6, < 2)
|
||||||
minitest (~> 5.1)
|
minitest (>= 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 2.0)
|
||||||
zeitwerk (~> 2.2, >= 2.2.2)
|
zeitwerk (~> 2.3)
|
||||||
addressable (2.4.0)
|
addressable (2.4.0)
|
||||||
ast (2.4.1)
|
ast (2.4.2)
|
||||||
backports (3.18.2)
|
backports (3.20.2)
|
||||||
bcrypt (3.1.16)
|
bcrypt (3.1.16)
|
||||||
brakeman (4.9.1)
|
brakeman (5.0.0)
|
||||||
builder (3.2.4)
|
builder (3.2.4)
|
||||||
bullet (6.1.0)
|
bullet (6.1.3)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
uniform_notifier (~> 1.11)
|
uniform_notifier (~> 1.11)
|
||||||
cancancan (3.1.0)
|
cancancan (3.2.1)
|
||||||
coffee-rails (5.0.0)
|
coffee-rails (5.0.0)
|
||||||
coffee-script (>= 2.2.0)
|
coffee-script (>= 2.2.0)
|
||||||
railties (>= 5.2.0)
|
railties (>= 5.2.0)
|
||||||
@@ -75,21 +79,21 @@ GEM
|
|||||||
coffee-script-source (1.12.2)
|
coffee-script-source (1.12.2)
|
||||||
commander (4.4.6)
|
commander (4.4.6)
|
||||||
highline (~> 1.7.2)
|
highline (~> 1.7.2)
|
||||||
concurrent-ruby (1.1.7)
|
concurrent-ruby (1.1.8)
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
daemons (1.3.1)
|
daemons (1.3.1)
|
||||||
dalli (2.7.10)
|
dalli (2.7.11)
|
||||||
delayed_job (4.1.8)
|
delayed_job (4.1.9)
|
||||||
activesupport (>= 3.0, < 6.1)
|
activesupport (>= 3.0, < 6.2)
|
||||||
delayed_job_active_record (4.1.4)
|
delayed_job_active_record (4.1.5)
|
||||||
activerecord (>= 3.0, < 6.1)
|
activerecord (>= 3.0, < 6.2)
|
||||||
delayed_job (>= 3.0, < 5)
|
delayed_job (>= 3.0, < 5)
|
||||||
delayed_job_web (1.4.3)
|
delayed_job_web (1.4.3)
|
||||||
activerecord (> 3.0.0)
|
activerecord (> 3.0.0)
|
||||||
delayed_job (> 2.0.3)
|
delayed_job (> 2.0.3)
|
||||||
rack-protection (>= 1.5.5)
|
rack-protection (>= 1.5.5)
|
||||||
sinatra (>= 1.4.4)
|
sinatra (>= 1.4.4)
|
||||||
devise (4.7.2)
|
devise (4.7.3)
|
||||||
bcrypt (~> 3.0)
|
bcrypt (~> 3.0)
|
||||||
orm_adapter (~> 0.1)
|
orm_adapter (~> 0.1)
|
||||||
railties (>= 4.1.0)
|
railties (>= 4.1.0)
|
||||||
@@ -97,15 +101,15 @@ GEM
|
|||||||
warden (~> 1.2.3)
|
warden (~> 1.2.3)
|
||||||
domain_name (0.5.20190701)
|
domain_name (0.5.20190701)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
erubi (1.9.0)
|
erubi (1.10.0)
|
||||||
ethon (0.12.0)
|
ethon (0.12.0)
|
||||||
ffi (>= 1.3.0)
|
ffi (>= 1.3.0)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
faraday (0.17.3)
|
faraday (0.17.4)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
faraday_middleware (0.14.0)
|
faraday_middleware (0.14.0)
|
||||||
faraday (>= 0.7.4, < 1.0)
|
faraday (>= 0.7.4, < 1.0)
|
||||||
ffi (1.13.1)
|
ffi (1.14.2)
|
||||||
gh (0.15.1)
|
gh (0.15.1)
|
||||||
addressable (~> 2.4.0)
|
addressable (~> 2.4.0)
|
||||||
backports
|
backports
|
||||||
@@ -128,19 +132,19 @@ GEM
|
|||||||
http-accept (1.7.0)
|
http-accept (1.7.0)
|
||||||
http-cookie (1.0.3)
|
http-cookie (1.0.3)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
i18n (1.8.5)
|
i18n (1.8.8)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
jbuilder (2.10.1)
|
jbuilder (2.11.2)
|
||||||
activesupport (>= 5.0.0)
|
activesupport (>= 5.0.0)
|
||||||
jquery-rails (4.4.0)
|
jquery-rails (4.4.0)
|
||||||
rails-dom-testing (>= 1, < 3)
|
rails-dom-testing (>= 1, < 3)
|
||||||
railties (>= 4.2.0)
|
railties (>= 4.2.0)
|
||||||
thor (>= 0.14, < 2.0)
|
thor (>= 0.14, < 2.0)
|
||||||
json (2.3.1)
|
json (2.5.1)
|
||||||
launchy (2.4.3)
|
launchy (2.4.3)
|
||||||
addressable (~> 2.3)
|
addressable (~> 2.3)
|
||||||
libv8 (3.16.14.19)
|
libv8 (3.16.14.19)
|
||||||
loofah (2.7.0)
|
loofah (2.9.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
mail (2.7.1)
|
mail (2.7.1)
|
||||||
@@ -150,11 +154,11 @@ GEM
|
|||||||
method_source (1.0.0)
|
method_source (1.0.0)
|
||||||
mime-types (3.3.1)
|
mime-types (3.3.1)
|
||||||
mime-types-data (~> 3.2015)
|
mime-types-data (~> 3.2015)
|
||||||
mime-types-data (3.2020.0512)
|
mime-types-data (3.2020.1104)
|
||||||
mimemagic (0.3.5)
|
mimemagic (0.3.5)
|
||||||
mini_mime (1.0.2)
|
mini_mime (1.0.2)
|
||||||
mini_portile2 (2.4.0)
|
mini_portile2 (2.5.0)
|
||||||
minitest (5.14.2)
|
minitest (5.14.3)
|
||||||
multi_json (1.15.0)
|
multi_json (1.15.0)
|
||||||
multipart-post (2.1.1)
|
multipart-post (2.1.1)
|
||||||
mustermann (1.1.1)
|
mustermann (1.1.1)
|
||||||
@@ -163,41 +167,43 @@ GEM
|
|||||||
net-http-persistent (2.9.4)
|
net-http-persistent (2.9.4)
|
||||||
net-http-pipeline (1.0.1)
|
net-http-pipeline (1.0.1)
|
||||||
netrc (0.11.0)
|
netrc (0.11.0)
|
||||||
newrelic_rpm (6.12.0.367)
|
newrelic_rpm (6.15.0)
|
||||||
nio4r (2.5.3)
|
nio4r (2.5.5)
|
||||||
nokogiri (1.10.10)
|
nokogiri (1.11.1)
|
||||||
mini_portile2 (~> 2.4.0)
|
mini_portile2 (~> 2.5.0)
|
||||||
|
racc (~> 1.4)
|
||||||
orm_adapter (0.5.0)
|
orm_adapter (0.5.0)
|
||||||
parallel (1.19.2)
|
parallel (1.20.1)
|
||||||
parser (2.7.1.4)
|
parser (3.0.0.0)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
passenger (6.0.6)
|
passenger (6.0.7)
|
||||||
rack
|
rack
|
||||||
rake (>= 0.8.1)
|
rake (>= 0.8.1)
|
||||||
puma (4.3.6)
|
puma (5.2.1)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
pusher-client (0.6.2)
|
pusher-client (0.6.2)
|
||||||
json
|
json
|
||||||
websocket (~> 1.0)
|
websocket (~> 1.0)
|
||||||
|
racc (1.5.2)
|
||||||
rack (2.2.3)
|
rack (2.2.3)
|
||||||
rack-protection (2.1.0)
|
rack-protection (2.1.0)
|
||||||
rack
|
rack
|
||||||
rack-test (1.1.0)
|
rack-test (1.1.0)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
rails (6.0.3.2)
|
rails (6.1.2)
|
||||||
actioncable (= 6.0.3.2)
|
actioncable (= 6.1.2)
|
||||||
actionmailbox (= 6.0.3.2)
|
actionmailbox (= 6.1.2)
|
||||||
actionmailer (= 6.0.3.2)
|
actionmailer (= 6.1.2)
|
||||||
actionpack (= 6.0.3.2)
|
actionpack (= 6.1.2)
|
||||||
actiontext (= 6.0.3.2)
|
actiontext (= 6.1.2)
|
||||||
actionview (= 6.0.3.2)
|
actionview (= 6.1.2)
|
||||||
activejob (= 6.0.3.2)
|
activejob (= 6.1.2)
|
||||||
activemodel (= 6.0.3.2)
|
activemodel (= 6.1.2)
|
||||||
activerecord (= 6.0.3.2)
|
activerecord (= 6.1.2)
|
||||||
activestorage (= 6.0.3.2)
|
activestorage (= 6.1.2)
|
||||||
activesupport (= 6.0.3.2)
|
activesupport (= 6.1.2)
|
||||||
bundler (>= 1.3.0)
|
bundler (>= 1.15.0)
|
||||||
railties (= 6.0.3.2)
|
railties (= 6.1.2)
|
||||||
sprockets-rails (>= 2.0.0)
|
sprockets-rails (>= 2.0.0)
|
||||||
rails-dom-testing (2.0.3)
|
rails-dom-testing (2.0.3)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
@@ -209,18 +215,18 @@ GEM
|
|||||||
rails_stdout_logging
|
rails_stdout_logging
|
||||||
rails_serve_static_assets (0.0.5)
|
rails_serve_static_assets (0.0.5)
|
||||||
rails_stdout_logging (0.0.5)
|
rails_stdout_logging (0.0.5)
|
||||||
railties (6.0.3.2)
|
railties (6.1.2)
|
||||||
actionpack (= 6.0.3.2)
|
actionpack (= 6.1.2)
|
||||||
activesupport (= 6.0.3.2)
|
activesupport (= 6.1.2)
|
||||||
method_source
|
method_source
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (>= 0.20.3, < 2.0)
|
thor (~> 1.0)
|
||||||
rainbow (3.0.0)
|
rainbow (3.0.0)
|
||||||
rake (13.0.1)
|
rake (13.0.3)
|
||||||
rb-readline (0.5.5)
|
rb-readline (0.5.5)
|
||||||
rdoc (6.2.1)
|
rdoc (6.3.0)
|
||||||
ref (2.0.0)
|
ref (2.0.0)
|
||||||
regexp_parser (1.7.1)
|
regexp_parser (2.0.3)
|
||||||
responders (3.0.1)
|
responders (3.0.1)
|
||||||
actionpack (>= 5.0)
|
actionpack (>= 5.0)
|
||||||
railties (>= 5.0)
|
railties (>= 5.0)
|
||||||
@@ -230,21 +236,21 @@ GEM
|
|||||||
mime-types (>= 1.16, < 4.0)
|
mime-types (>= 1.16, < 4.0)
|
||||||
netrc (~> 0.8)
|
netrc (~> 0.8)
|
||||||
rexml (3.2.4)
|
rexml (3.2.4)
|
||||||
round_robin_tournament (0.0.1)
|
round_robin_tournament (0.1.1)
|
||||||
rubocop (0.91.0)
|
rubocop (1.9.1)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
parser (>= 2.7.1.1)
|
parser (>= 3.0.0.0)
|
||||||
rainbow (>= 2.2.2, < 4.0)
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
regexp_parser (>= 1.7)
|
regexp_parser (>= 1.8, < 3.0)
|
||||||
rexml
|
rexml
|
||||||
rubocop-ast (>= 0.4.0, < 1.0)
|
rubocop-ast (>= 1.2.0, < 2.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (>= 1.4.0, < 2.0)
|
unicode-display_width (>= 1.4.0, < 3.0)
|
||||||
rubocop-ast (0.4.0)
|
rubocop-ast (1.4.1)
|
||||||
parser (>= 2.7.1.4)
|
parser (>= 2.7.1.5)
|
||||||
ruby-progressbar (1.10.1)
|
ruby-progressbar (1.11.0)
|
||||||
ruby2_keywords (0.0.2)
|
ruby2_keywords (0.0.4)
|
||||||
sdoc (1.1.0)
|
sdoc (2.0.3)
|
||||||
rdoc (>= 5.0)
|
rdoc (>= 5.0)
|
||||||
sinatra (2.1.0)
|
sinatra (2.1.0)
|
||||||
mustermann (~> 1.0)
|
mustermann (~> 1.0)
|
||||||
@@ -260,13 +266,12 @@ GEM
|
|||||||
activesupport (>= 4.0)
|
activesupport (>= 4.0)
|
||||||
sprockets (>= 3.0.0)
|
sprockets (>= 3.0.0)
|
||||||
sqlite3 (1.4.2)
|
sqlite3 (1.4.2)
|
||||||
terminal-table (1.8.0)
|
terminal-table (3.0.0)
|
||||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||||
therubyracer (0.12.3)
|
therubyracer (0.12.3)
|
||||||
libv8 (~> 3.16.14.15)
|
libv8 (~> 3.16.14.15)
|
||||||
ref
|
ref
|
||||||
thor (1.0.1)
|
thor (1.1.0)
|
||||||
thread_safe (0.3.6)
|
|
||||||
tilt (2.0.10)
|
tilt (2.0.10)
|
||||||
travis (1.8.13)
|
travis (1.8.13)
|
||||||
backports
|
backports
|
||||||
@@ -282,9 +287,9 @@ GEM
|
|||||||
turbolinks-source (5.2.0)
|
turbolinks-source (5.2.0)
|
||||||
typhoeus (0.8.0)
|
typhoeus (0.8.0)
|
||||||
ethon (>= 0.8.0)
|
ethon (>= 0.8.0)
|
||||||
tzinfo (1.2.7)
|
tzinfo (2.0.4)
|
||||||
thread_safe (~> 0.1)
|
concurrent-ruby (~> 1.0)
|
||||||
tzinfo-data (1.2020.1)
|
tzinfo-data (1.2021.1)
|
||||||
tzinfo (>= 1.0.0)
|
tzinfo (>= 1.0.0)
|
||||||
uglifier (4.2.0)
|
uglifier (4.2.0)
|
||||||
execjs (>= 0.3.0, < 3)
|
execjs (>= 0.3.0, < 3)
|
||||||
@@ -292,14 +297,14 @@ GEM
|
|||||||
unf_ext
|
unf_ext
|
||||||
unf_ext (0.0.7.7)
|
unf_ext (0.0.7.7)
|
||||||
unicode-display_width (1.7.0)
|
unicode-display_width (1.7.0)
|
||||||
uniform_notifier (1.13.0)
|
uniform_notifier (1.13.2)
|
||||||
warden (1.2.9)
|
warden (1.2.9)
|
||||||
rack (>= 2.0.9)
|
rack (>= 2.0.9)
|
||||||
websocket (1.2.8)
|
websocket (1.2.9)
|
||||||
websocket-driver (0.7.3)
|
websocket-driver (0.7.3)
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.5)
|
websocket-extensions (0.1.5)
|
||||||
zeitwerk (2.4.0)
|
zeitwerk (2.4.2)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
@@ -321,7 +326,7 @@ DEPENDENCIES
|
|||||||
newrelic_rpm
|
newrelic_rpm
|
||||||
passenger
|
passenger
|
||||||
puma
|
puma
|
||||||
rails (= 6.0.3.2)
|
rails (= 6.1.2)
|
||||||
rails_12factor
|
rails_12factor
|
||||||
rb-readline
|
rb-readline
|
||||||
round_robin_tournament
|
round_robin_tournament
|
||||||
@@ -336,7 +341,7 @@ DEPENDENCIES
|
|||||||
uglifier
|
uglifier
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 2.6.5p114
|
ruby 3.0.0p0
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.0.2
|
2.2.9
|
||||||
|
|||||||
@@ -2,10 +2,10 @@
|
|||||||
This application is being created to run a wrestling tournament.
|
This application is being created to run a wrestling tournament.
|
||||||
|
|
||||||
### Current master status
|
### Current master status
|
||||||
[](https://travis-ci.org/jcwimer/wrestlingApp)
|
[](https://travis-ci.org/jcwimer/wrestlingApp)
|
||||||
|
|
||||||
### Current development status
|
### Current development status
|
||||||
[](https://travis-ci.org/jcwimer/wrestlingApp)
|
[](https://travis-ci.org/jcwimer/wrestlingApp)
|
||||||
|
|
||||||
# Info
|
# Info
|
||||||
**License:** MIT License
|
**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)
|
**Public Production Url:** [https://wrestlingdev.com](http://wrestlingdev.com)
|
||||||
|
|
||||||
**App Info**
|
**App Info**
|
||||||
* Ruby 2.6.5
|
* Ruby 3.0.0
|
||||||
* Rails 6.0.1
|
* Rails 6.1.2
|
||||||
* DB mysql or mariadb
|
* DB mysql or mariadb
|
||||||
* Memcached
|
* Memcached
|
||||||
* Delayed Jobs
|
* Delayed Jobs
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_custom_weights
|
def create_custom_weights
|
||||||
@custom = params[:customValue].to_s
|
@custom = params[:customValue].split(",")
|
||||||
@tournament.create_pre_defined_weights(@custom)
|
@tournament.create_pre_defined_weights(@custom)
|
||||||
redirect_to "/tournaments/#{@tournament.id}"
|
redirect_to "/tournaments/#{@tournament.id}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class Match < ActiveRecord::Base
|
|||||||
elsif self.win_type == "DQ"
|
elsif self.win_type == "DQ"
|
||||||
return "(DQ)"
|
return "(DQ)"
|
||||||
elsif self.win_type == "Forfeit"
|
elsif self.win_type == "Forfeit"
|
||||||
return "(For)"
|
return "(FF)"
|
||||||
else
|
else
|
||||||
win_type_abbreviation = "#{self.win_type.chars.to_a[0..2].join('')}"
|
win_type_abbreviation = "#{self.win_type.chars.to_a[0..2].join('')}"
|
||||||
return "(#{win_type_abbreviation} #{self.score})"
|
return "(#{win_type_abbreviation} #{self.score})"
|
||||||
|
|||||||
@@ -14,10 +14,15 @@ class School < ActiveRecord::Base
|
|||||||
|
|
||||||
def abbreviation
|
def abbreviation
|
||||||
name_array = self.name.split(' ')
|
name_array = self.name.split(' ')
|
||||||
if name_array.size > 1
|
if name_array.size > 2
|
||||||
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a[0..1].join('').upcase}"
|
# 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
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -40,31 +45,24 @@ class School < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def calculate_score_raw
|
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.score = newScore
|
||||||
self.save
|
self.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_points_scored_by_wrestlers
|
def total_points_scored_by_wrestlers
|
||||||
points = 0
|
points = 0.0
|
||||||
self.wrestlers.each do |w|
|
self.wrestlers.each do |w|
|
||||||
if w.extra != true
|
points = points + w.total_team_points
|
||||||
points = points + w.total_team_points
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
points
|
points
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_points_deducted
|
def total_points_deducted
|
||||||
points = 0
|
points = 0.0
|
||||||
deductedPoints.each do |d|
|
deductedPoints.each do |d|
|
||||||
points = points + d.points
|
points = points + d.points
|
||||||
end
|
end
|
||||||
self.wrestlers.each do |w|
|
|
||||||
w.deductedPoints.each do |d|
|
|
||||||
points = points + d.points
|
|
||||||
end
|
|
||||||
end
|
|
||||||
points
|
points
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -29,17 +29,21 @@ class Tournament < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tournament_types
|
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
|
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
|
weights.destroy_all
|
||||||
if value == 'hs'
|
weight_classes.each do |w|
|
||||||
Weight::HS_WEIGHT_CLASSES.each do |w|
|
weights.create(max: w)
|
||||||
weights.create(max: w)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
raise "Unspecified behavior"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -116,7 +120,7 @@ class Tournament < ActiveRecord::Base
|
|||||||
|
|
||||||
def modified_sixteen_man_number_of_wrestlers
|
def modified_sixteen_man_number_of_wrestlers
|
||||||
error_string = ""
|
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}
|
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 16}
|
||||||
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 12}
|
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 12}
|
||||||
weights_with_too_many_wrestlers.each do |weight|
|
weights_with_too_many_wrestlers.each do |weight|
|
||||||
@@ -145,17 +149,17 @@ class Tournament < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def match_generation_error
|
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
|
modified_sixteen_man_error = modified_sixteen_man_number_of_wrestlers
|
||||||
double_elim_error = double_elim_number_of_wrestlers
|
double_elim_error = double_elim_number_of_wrestlers
|
||||||
if pool_to_bracket_weights_with_too_many_wrestlers != nil
|
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|
|
pool_to_bracket_weights_with_too_many_wrestlers.each do |w|
|
||||||
errorString = errorString + "#{w.max} "
|
error_string = error_string + "#{w.max} "
|
||||||
end
|
end
|
||||||
return errorString
|
return error_string
|
||||||
elsif modified_sixteen_man_error.length > 0
|
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
|
elsif double_elim_error.length > 0
|
||||||
return error_string + double_elim_error
|
return error_string + double_elim_error
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -7,7 +7,11 @@ class Weight < ActiveRecord::Base
|
|||||||
|
|
||||||
validates :max, presence: true
|
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,145,152,160,170,182,195,220,285"
|
||||||
|
HS_GIRLS_WEIGHT_CLASSES = "101,106,111,116,121,126,131,137,143,150,160,170,189,235"
|
||||||
|
|
||||||
before_destroy do
|
before_destroy do
|
||||||
self.tournament.destroy_all_matches
|
self.tournament.destroy_all_matches
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ class AdvanceWrestler
|
|||||||
|
|
||||||
def advance_raw
|
def advance_raw
|
||||||
pool_to_bracket_advancement if @tournament.tournament_type == "Pool to bracket"
|
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
|
DoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or
|
||||||
@tournament.tournament_type == "Double Elimination 1-6"
|
@tournament.tournament_type.include? "Regular Double Elimination"
|
||||||
end
|
end
|
||||||
|
|
||||||
def pool_to_bracket_advancement
|
def pool_to_bracket_advancement
|
||||||
|
|||||||
@@ -28,17 +28,18 @@ class DoubleEliminationAdvance
|
|||||||
update_new_match(new_match, get_wrestler_number)
|
update_new_match(new_match, get_wrestler_number)
|
||||||
elsif @last_match.bracket_position == "Conso Semis"
|
elsif @last_match.bracket_position == "Conso Semis"
|
||||||
# if its a regular double elim
|
# 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
|
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)
|
update_new_match(new_match, get_wrestler_number)
|
||||||
# if it's a special bracket where consolations wrestler for 5th
|
# 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
|
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)
|
update_new_match(new_match, get_wrestler_number)
|
||||||
end
|
end
|
||||||
elsif @last_match.bracket_position == "Conso Quarter"
|
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}
|
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")
|
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 next_round_matches.size == this_round_matches.size
|
||||||
# if a semi loser is dropping down
|
# 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
|
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
|
def generate_raw
|
||||||
standardStartingActions
|
standardStartingActions
|
||||||
PoolToBracketMatchGeneration.new(@tournament).generatePoolToBracketMatches if @tournament.tournament_type == "Pool to bracket"
|
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"
|
ModifiedSixteenManMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||||
DoubleEliminationMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type == "Double Elimination 1-6"
|
DoubleEliminationMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type.include? "Regular Double Elimination"
|
||||||
postMatchCreationActions
|
postMatchCreationActions
|
||||||
PoolToBracketMatchGeneration.new(@tournament).assignLoserNames if @tournament.tournament_type == "Pool to bracket"
|
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"
|
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 == "Double Elimination 1-6"
|
DoubleEliminationGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type.include? "Regular Double Elimination"
|
||||||
end
|
end
|
||||||
|
|
||||||
def standardStartingActions
|
def standardStartingActions
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class ModifiedSixteenManGenerateLoserNames
|
|||||||
conso_round_2(matches_by_weight)
|
conso_round_2(matches_by_weight)
|
||||||
conso_round_3(matches_by_weight)
|
conso_round_3(matches_by_weight)
|
||||||
third_fourth(matches_by_weight)
|
third_fourth(matches_by_weight)
|
||||||
|
seventh_eighth(matches_by_weight)
|
||||||
save_matches(matches_by_weight)
|
save_matches(matches_by_weight)
|
||||||
matches_by_weight = @tournament.matches.where(weight_id: w.id).reload
|
matches_by_weight = @tournament.matches.where(weight_id: w.id).reload
|
||||||
advance_bye_matches_championship(matches_by_weight)
|
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}"
|
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Semis"}.second.bout_number}"
|
||||||
end
|
end
|
||||||
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)
|
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|
|
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
|
if match.w1 == nil or match.w2 == nil
|
||||||
puts match.bout_number
|
|
||||||
match.finished = 1
|
match.finished = 1
|
||||||
match.win_type = "BYE"
|
match.win_type = "BYE"
|
||||||
if match.w1 != nil
|
if match.w1 != nil
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
class ModifiedSixteenManMatchGeneration
|
class ModifiedSixteenManMatchGeneration
|
||||||
def initialize( tournament )
|
def initialize( tournament )
|
||||||
@tournament = tournament
|
@tournament = tournament
|
||||||
|
@number_of_placers = @tournament.number_of_placers
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_matches
|
def generate_matches
|
||||||
@@ -57,6 +58,9 @@ class ModifiedSixteenManMatchGeneration
|
|||||||
create_matchup(nil,nil,"1/2",1,5,weight)
|
create_matchup(nil,nil,"1/2",1,5,weight)
|
||||||
create_matchup(nil,nil,"3/4",1,5,weight)
|
create_matchup(nil,nil,"3/4",1,5,weight)
|
||||||
create_matchup(nil,nil,"5/6",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
|
end
|
||||||
|
|
||||||
def wrestler_with_seed(seed,weight)
|
def wrestler_with_seed(seed,weight)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class SixteenManDoubleEliminationGenerateLoserNames
|
|||||||
conso_round_3(matches_by_weight)
|
conso_round_3(matches_by_weight)
|
||||||
conso_round_5(matches_by_weight)
|
conso_round_5(matches_by_weight)
|
||||||
fifth_sixth(matches_by_weight)
|
fifth_sixth(matches_by_weight)
|
||||||
|
seventh_eighth(matches_by_weight)
|
||||||
save_matches(matches_by_weight)
|
save_matches(matches_by_weight)
|
||||||
matches_by_weight = @weight.matches.reload
|
matches_by_weight = @weight.matches.reload
|
||||||
advance_bye_matches_championship(matches_by_weight)
|
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}"
|
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Semis"}.second.bout_number}"
|
||||||
end
|
end
|
||||||
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)
|
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|
|
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
|
class SixteenManDoubleEliminationMatchGeneration
|
||||||
def initialize( weight )
|
def initialize( weight )
|
||||||
@weight = weight
|
@weight = weight
|
||||||
|
@number_of_placers = @weight.tournament.number_of_placers
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_matches_for_weight
|
def generate_matches_for_weight
|
||||||
@@ -57,6 +58,9 @@ class SixteenManDoubleEliminationMatchGeneration
|
|||||||
create_matchup(nil,nil,"1/2",1,6,weight)
|
create_matchup(nil,nil,"1/2",1,6,weight)
|
||||||
create_matchup(nil,nil,"3/4",1,6,weight)
|
create_matchup(nil,nil,"3/4",1,6,weight)
|
||||||
create_matchup(nil,nil,"5/6",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
|
end
|
||||||
|
|
||||||
def wrestler_with_seed(seed,weight)
|
def wrestler_with_seed(seed,weight)
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ class CalculateWrestlerTeamScore
|
|||||||
|
|
||||||
def placement_points
|
def placement_points
|
||||||
return PoolBracketPlacementPoints.new(@wrestler).calcPoints if @tournament.tournament_type == "Pool to bracket"
|
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 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 == "Double Elimination 1-6"
|
return DoubleEliminationPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type.include? "Regular Double Elimination"
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
class DoubleEliminationPlacementPoints
|
class DoubleEliminationPlacementPoints
|
||||||
def initialize(wrestler)
|
def initialize(wrestler)
|
||||||
@wrestler = wrestler
|
@wrestler = wrestler
|
||||||
if wrestler.tournament.tournament_type == "Double Elimination 1-6"
|
@number_of_placers = @wrestler.tournament.number_of_placers
|
||||||
@number_of_placers = 6
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def calc_points
|
def calc_points
|
||||||
@@ -22,7 +20,7 @@ class DoubleEliminationPlacementPoints
|
|||||||
elsif won_bracket_position_size("7/8") > 0
|
elsif won_bracket_position_size("7/8") > 0
|
||||||
return PlacementPoints.new(@number_of_placers).seventhPlace
|
return PlacementPoints.new(@number_of_placers).seventhPlace
|
||||||
elsif bracket_position_size("Conso Quarter") > 0 and @number_of_placers >= 8
|
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
|
else
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
class ModifiedSixteenManPlacementPoints
|
class ModifiedSixteenManPlacementPoints
|
||||||
def initialize(wrestler)
|
def initialize(wrestler)
|
||||||
@wrestler = wrestler
|
@wrestler = wrestler
|
||||||
@number_of_placers = 6
|
@wrestler = wrestler
|
||||||
|
@number_of_placers = @wrestler.tournament.number_of_placers
|
||||||
end
|
end
|
||||||
|
|
||||||
def calc_points
|
def calc_points
|
||||||
@@ -17,6 +18,10 @@ class ModifiedSixteenManPlacementPoints
|
|||||||
return PlacementPoints.new(@number_of_placers).fifthPlace
|
return PlacementPoints.new(@number_of_placers).fifthPlace
|
||||||
elsif bracket_position_size("5/6") > 0
|
elsif bracket_position_size("5/6") > 0
|
||||||
return PlacementPoints.new(@number_of_placers).sixthPlace
|
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
|
else
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -42,7 +42,8 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><strong>Time Savers</strong></li>
|
<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><strong>Tournament Actions</strong></li>
|
||||||
<li><%= link_to "Calculate Team Scores" , "/tournaments/#{@tournament.id}/calculate_team_scores", method: :post %></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>
|
<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
|
<li>Tournament Types
|
||||||
<ul>
|
<ul>
|
||||||
<li>Pool to bracket (adhears to 5 match per day rule)</li>
|
<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>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li>Team point calculation</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>
|
<li>Eight pools of 3 (2 matches each) to a quarter final bracket - 17-24 wrestlers, place 1-8.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br>
|
<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>
|
<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>
|
<ul>
|
||||||
<li>Championship win: 2pt</li>
|
<li>Championship win: 2pt</li>
|
||||||
<li>Consolation win: 1pt</li>
|
<li>Consolation win: 1pt</li>
|
||||||
@@ -127,7 +142,7 @@
|
|||||||
<br>
|
<br>
|
||||||
<h3>Future Plans</h3>
|
<h3>Future Plans</h3>
|
||||||
<br>
|
<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>
|
<br>
|
||||||
<h3>Contact</h3>
|
<h3>Contact</h3>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -106,11 +106,11 @@ table.smallText tr td { font-size: 10px; }
|
|||||||
<%= render 'fourPoolSemiBracket' %>
|
<%= render 'fourPoolSemiBracket' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</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;">
|
<td valign="top" style="padding: 10px;">
|
||||||
<%= render 'modified_sixteen_man_double_elimination_bracket' %>
|
<%= render 'modified_sixteen_man_double_elimination_bracket' %>
|
||||||
</td>
|
</td>
|
||||||
<% elsif @tournament.tournament_type == "Double Elimination 1-6" %>
|
<% elsif @tournament.tournament_type.include? "Regular Double Elimination" %>
|
||||||
<td valign="top" style="padding: 10px;">
|
<td valign="top" style="padding: 10px;">
|
||||||
<%= render 'double_elimination_bracket' %>
|
<%= render 'double_elimination_bracket' %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -35,6 +35,11 @@
|
|||||||
<%= f.label :tournament_type %><br>
|
<%= f.label :tournament_type %><br>
|
||||||
<%= f.select :tournament_type, @tournament.tournament_types %>
|
<%= f.select :tournament_type, @tournament.tournament_types %>
|
||||||
</div>
|
</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 %>
|
<%= f.hidden_field :user_id, :value => current_user.id %>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -1,131 +1,48 @@
|
|||||||
<h4>Championship Bracket</h4>
|
<h4>Championship Bracket</h4>
|
||||||
<main id="bracket">
|
<div class="bracket">
|
||||||
<ul class="round round-1">
|
<!--Round 1-->
|
||||||
<% @matches.select{|m|m.bracket_position == "Bracket" and m.round == 1}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
<% @round_matches = @matches.select{|m|m.bracket_position == "Bracket" and m.round == 1} %>
|
||||||
<li> </li>
|
<%= render 'bracket_round' %>
|
||||||
<li class="game game-top "><%= match.w1_bracket_name_round_one %> <span></span></li>
|
<!--Round 2-->
|
||||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
<% @round_matches = @matches.select{|m|m.bracket_position == "Quarter"} %>
|
||||||
<li class="game game-bottom "><%= match.w2_bracket_name_round_one %><span></span></li>
|
<%= render 'bracket_round' %>
|
||||||
<li> </li>
|
<!--Round 3-->
|
||||||
|
<% @round_matches = @matches.select{|m|m.bracket_position == "Semis"} %>
|
||||||
<% end %>
|
<%= render 'bracket_round' %>
|
||||||
</ul>
|
<!--Round 4-->
|
||||||
<ul class="round round-2">
|
<% @final_match = @matches.select{|m|m.bracket_position == "1/2"} %>
|
||||||
<% @matches.select{|m|m.bracket_position == "Quarter"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
<% @winner_place = "1st" %>
|
||||||
<li></li>
|
<%= render 'bracket_final' %>
|
||||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
</div>
|
||||||
<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>
|
|
||||||
<h4>3/4 place match</h4>
|
<h4>3/4 place match</h4>
|
||||||
<main id="bracket">
|
<div class="bracket">
|
||||||
<ul class="round round-3">
|
<!--Round 1-->
|
||||||
<% @matches.select{|m|m.bracket_position == "3/4"}.each do |match| %>
|
<% @final_match = @matches.select{|m|m.bracket_position == "3/4"} %>
|
||||||
<li> </li>
|
<% @winner_place = "3rd" %>
|
||||||
|
<%= render 'bracket_final' %>
|
||||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
</div>
|
||||||
<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>
|
|
||||||
<h4>Consolation Bracket</h4>
|
<h4>Consolation Bracket</h4>
|
||||||
<main id="bracket">
|
<div class="bracket">
|
||||||
<ul class="round round-1">
|
<!--Round 1-->
|
||||||
<% @matches.select{|m|m.bracket_position == "Conso" and m.round == 2}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso" and m.round == 2} %>
|
||||||
<li> </li>
|
<%= render 'bracket_round' %>
|
||||||
<li> </li>
|
<!--Round 2-->
|
||||||
|
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso Quarter"} %>
|
||||||
|
<%= render 'bracket_round' %>
|
||||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
<!--Round 3-->
|
||||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso Semis"} %>
|
||||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
<%= render 'bracket_round' %>
|
||||||
|
<!--Round 4-->
|
||||||
<% end %>
|
<% @final_match = @matches.select{|m|m.bracket_position == "5/6"} %>
|
||||||
</ul>
|
<% @winner_place = "5th" %>
|
||||||
<ul class="round round-2">
|
<%= render 'bracket_final' %>
|
||||||
<% @matches.select{|m|m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
</div>
|
||||||
<li> </li>
|
<% if @tournament.number_of_placers >= 8 %>
|
||||||
|
<h4>7/8 place match</h4>
|
||||||
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
|
<div class="bracket">
|
||||||
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </li>
|
<!--Round 1-->
|
||||||
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
|
<% @final_match = @matches.select{|m|m.bracket_position == "7/8"} %>
|
||||||
|
<% @winner_place = "7th" %>
|
||||||
<li> </li>
|
<%= render 'bracket_final' %>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% 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>
|
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<% cache ["#{@tournament.id}_all_brackets", @tournament] do %>
|
<% cache ["#{@tournament.id}_all_brackets", @tournament] do %>
|
||||||
<div id="exportable" >
|
<div id="exportable" >
|
||||||
<%= render :file => 'tournaments/team_scores' %>
|
<%= render :template => 'tournaments/team_scores' %>
|
||||||
<% @tournament.weights.sort_by{|w| w.max}.each do |weight| %>
|
<% @tournament.weights.sort_by{|w| w.max}.each do |weight| %>
|
||||||
<table class='pagebreak'>
|
<table class='pagebreak'>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
<% @weight = weight %>
|
<% @weight = weight %>
|
||||||
<%= render 'bracket_partial' %>
|
<%= render 'bracket_partial' %>
|
||||||
</td>
|
</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;">
|
<td valign="top" style="padding: 10px;">
|
||||||
<!-- Need to define what the tournaments#bracket controller defines -->
|
<!-- Need to define what the tournaments#bracket controller defines -->
|
||||||
<% @matches = weight.matches %>
|
<% @matches = weight.matches %>
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% if @tournament.tournament_type == "Pool to bracket" %>
|
<% if @tournament.tournament_type == "Pool to bracket" %>
|
||||||
<%= render 'pool_bracket_director_actions' %>
|
<%= 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' %>
|
<%= render 'bracket_director_actions' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= match.bout_number %></td>
|
<td><%= match.bout_number %></td>
|
||||||
<td><%= match.bracket_position %></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><%= match.finished %></td>
|
||||||
<td><%= link_to 'Show', match, :class=>"btn btn-default btn-sm" %>
|
<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" %>
|
<%= link_to 'Edit Wrestlers', edit_match_path(match), :class=>"btn btn-primary btn-sm" %>
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ if [ $# != 1 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
docker build -t $1 -f ${project_dir}/deploy/rails-dev-Dockerfile ${project_dir}
|
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
|
docker run --rm -it -p 3000:3000 -v ${project_dir}:/rails $1 /bin/bash
|
||||||
sudo chown -R ${USER}:${USER} ${project_dir}
|
sudo chown -R ${USER_ID}:${USER_ID} ${project_dir}
|
||||||
@@ -2,4 +2,4 @@
|
|||||||
project_dir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/.."
|
project_dir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/.."
|
||||||
|
|
||||||
docker build -f ${project_dir}/deploy/rails-prod-Dockerfile -t wrestlingdevtests ${project_dir}/.
|
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
|
DeviseController.respond_to :html, :json
|
||||||
end
|
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/tournament_services)
|
||||||
config.autoload_paths += %W(#{config.root}/app/services/wrestler_services)
|
config.autoload_paths += %W(#{config.root}/app/services/wrestler_services)
|
||||||
config.autoload_paths += %W(#{config.root}/app/services/weight_services)
|
config.autoload_paths += %W(#{config.root}/app/services/weight_services)
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
Wrestling::Application.configure do
|
Wrestling::Application.configure do
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# 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
|
# In the development environment your application's code is reloaded on
|
||||||
# every request. This slows down response time but is perfect for development
|
# 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.
|
# 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.alert = true
|
||||||
#Bullet.console = true
|
#Bullet.console = true
|
||||||
#Bullet.bullet_logger = true
|
#Bullet.bullet_logger = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ Wrestling::Application.configure do
|
|||||||
|
|
||||||
# Use a different cache store in production.
|
# Use a different cache store in production.
|
||||||
# config.cache_store = :mem_cache_store
|
# config.cache_store = :mem_cache_store
|
||||||
config.cache_store = :dalli_store,
|
config.cache_store = :mem_cache_store,
|
||||||
(ENV["MEMCACHIER_SERVERS"] || "").split(","),
|
(ENV["MEMCACHIER_SERVERS"] || "").split(","),
|
||||||
{:username => ENV["MEMCACHIER_USERNAME"],
|
{:username => ENV["MEMCACHIER_USERNAME"],
|
||||||
:password => ENV["MEMCACHIER_PASSWORD"],
|
:password => ENV["MEMCACHIER_PASSWORD"],
|
||||||
|
|||||||
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
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
# incrementally modify your database, and then regenerate this schema definition.
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
#
|
#
|
||||||
# This file is the source Rails uses to define your schema when running `rails
|
# This file is the source Rails uses to define your schema when running `bin/rails
|
||||||
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
|
# 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
|
# 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 from scratch. Old migrations may fail to apply correctly if those
|
||||||
# migrations use external dependencies or application code.
|
# migrations use external dependencies or application code.
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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|
|
create_table "delayed_jobs", force: :cascade do |t|
|
||||||
t.integer "priority", default: 0, null: false
|
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 "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.integer "tournament_id"
|
t.integer "tournament_id"
|
||||||
t.decimal "score"
|
t.decimal "score", precision: 15, scale: 1
|
||||||
t.index ["tournament_id"], name: "index_schools_on_tournament_id"
|
t.index ["tournament_id"], name: "index_schools_on_tournament_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM ruby:2.6.5
|
FROM ruby:3.0.0
|
||||||
|
|
||||||
RUN apt-get -qq update \
|
RUN apt-get -qq update \
|
||||||
&& apt-get -qq install -y \
|
&& apt-get -qq install -y \
|
||||||
@@ -22,7 +22,8 @@ RUN gem install bundler
|
|||||||
RUN gem update --system
|
RUN gem update --system
|
||||||
ADD Gemfile* /tmp/
|
ADD Gemfile* /tmp/
|
||||||
WORKDIR /tmp
|
WORKDIR /tmp
|
||||||
RUN bundle install --jobs 4 --without production
|
RUN bundle config set without 'production'
|
||||||
|
RUN bundle install --jobs 4
|
||||||
|
|
||||||
RUN mkdir /rails
|
RUN mkdir /rails
|
||||||
WORKDIR /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/
|
#HEALTHCHECK --start-period=60s CMD curl http://127.0.0.1/
|
||||||
|
|
||||||
|
|||||||
@@ -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'
|
require 'test_helper'
|
||||||
|
|
||||||
class DoubleEliminationSixteenManMatchGeneration < ActionDispatch::IntegrationTest
|
class DoubleEliminationSixteenManSixPlacesMatchGeneration < ActionDispatch::IntegrationTest
|
||||||
def setup
|
def setup
|
||||||
create_double_elim_tournament_single_weight_1_6(14)
|
create_double_elim_tournament_single_weight_1_6(14)
|
||||||
end
|
end
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class DoubleEliminationRunThrough < ActionDispatch::IntegrationTest
|
class DoubleEliminationSixteenManSixPlacesRunThrough < ActionDispatch::IntegrationTest
|
||||||
def setup
|
def setup
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -13,57 +13,7 @@ class DoubleEliminationRunThrough < ActionDispatch::IntegrationTest
|
|||||||
match.save
|
match.save
|
||||||
end
|
end
|
||||||
|
|
||||||
test "8 man double elimination" do
|
test "16 man double elimination placing 6 run through" 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
|
|
||||||
create_double_elim_tournament_single_weight_1_6(14)
|
create_double_elim_tournament_single_weight_1_6(14)
|
||||||
matches = @tournament.matches.reload
|
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
|
test "Mat validations" do
|
||||||
mat = Mat.new
|
mat = Mat.new
|
||||||
assert_not mat.valid?
|
assert_not mat.valid?
|
||||||
assert_equal [:name], mat.errors.keys
|
assert_equal [:name], mat.errors.attribute_names
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ class SchoolTest < ActiveSupport::TestCase
|
|||||||
test "School validations" do
|
test "School validations" do
|
||||||
school = School.new
|
school = School.new
|
||||||
assert_not school.valid?
|
assert_not school.valid?
|
||||||
assert_equal [:name], school.errors.keys
|
assert_equal [:name], school.errors.attribute_names
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,6 +9,22 @@ class TournamentTest < ActiveSupport::TestCase
|
|||||||
test "Tournament validations" do
|
test "Tournament validations" do
|
||||||
tourney = Tournament.new
|
tourney = Tournament.new
|
||||||
assert_not tourney.valid?
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ class WeightTest < ActiveSupport::TestCase
|
|||||||
test "Weight validations" do
|
test "Weight validations" do
|
||||||
weight = Weight.new
|
weight = Weight.new
|
||||||
assert_not weight.valid?
|
assert_not weight.valid?
|
||||||
assert_equal [:max], weight.errors.keys
|
assert_equal [:max], weight.errors.attribute_names
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ class WrestlerTest < ActiveSupport::TestCase
|
|||||||
test "Wrestler validations" do
|
test "Wrestler validations" do
|
||||||
wrestler = Wrestler.new
|
wrestler = Wrestler.new
|
||||||
assert_not wrestler.valid?
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -41,7 +41,29 @@ class ActiveSupport::TestCase
|
|||||||
@tournament.address = "some place"
|
@tournament.address = "some place"
|
||||||
@tournament.director = "some guy"
|
@tournament.director = "some guy"
|
||||||
@tournament.director_email= "test@test.com"
|
@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.date = "2015-12-30"
|
||||||
@tournament.save
|
@tournament.save
|
||||||
@school = School.new
|
@school = School.new
|
||||||
|
|||||||
Reference in New Issue
Block a user