1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

109 Commits

Author SHA1 Message Date
fc3623008b Fixed slowlog path on mariadb 2023-03-07 17:34:14 +00:00
508dd493a1 Added slowlog to mariadb 2023-03-07 13:59:46 +00:00
92bd1ec3c9 Fixed yaml error in k8s manifest, added a passenger pool size secret, and added multiple workers 2023-03-01 21:58:24 +00:00
87353da05e Updated to rails 6.1.7.2 2023-03-01 21:58:24 +00:00
57baa3ea45 Remove tty from docker commands in test deploy 2023-02-02 13:37:13 +00:00
2eb38ce788 Allow decimals in the weight max form and remove references to lbs in views 2023-02-02 13:36:52 +00:00
e047383fe4 Added first cypress e2e tests 2023-02-02 13:16:26 +00:00
05b42dbf0e Changed weights max to decimal 2023-02-02 13:16:13 +00:00
f011dae730 Seed the test db every deploy 2023-02-02 13:11:16 +00:00
1078dc9e97 Fixed caching of school view 2023-02-02 13:11:01 +00:00
c133a8b051 Added safeguards for generating pool matches along with tests, updated two errors on about page, and added time saver to create middle school weights 2023-01-24 22:56:22 +00:00
1d0cff0e6f Pool order tests are not asserting properly and once fixed some were failing. All tests fixed and passing now. 2023-01-23 22:14:00 +00:00
1ee886abd3 Fixed creating a teampointadjust with a wrestler 2023-01-19 22:48:41 +00:00
86bb0b8410 Fixed spelling of Neutral 2023-01-19 22:48:41 +00:00
c3480909a2 Fixed school show caching 2023-01-19 01:47:32 +00:00
bde2b6d8c4 Added tests for assign_next_match mat action permissions 2023-01-09 19:55:19 -05:00
288c144f53 Added permissions tests for mat#assign_next_match 2023-01-09 19:33:41 -05:00
371b44977f Redirect errors on match#stat back to match#stat 2023-01-09 19:27:31 -05:00
eb56b9d16c Clear the cache of wrestlers when next matches are assigned to a mat 2023-01-09 19:19:30 -05:00
6b57246080 Fixed the mat#show route by defining the correct vars in the controller and added a route for assign_next_match on mat 2023-01-09 19:16:36 -05:00
ffb7d8be5b Always clear the cache for wrestlers when the match changes 2023-01-09 19:15:51 -05:00
22f5733160 Fixed export bug when adding overtime type to matches 2023-01-05 22:47:29 -05:00
b5ab929270 Hide one more text on tournament show page depending on if tournament is public or not 2023-01-02 22:08:31 -05:00
1d646cb05d Do not show brackets or bout board if you tournament is not public 2023-01-02 15:57:08 -05:00
c328bbd91c Added is_public to a tournament to hide lineups and brackets until you're ready to make it public 2023-01-01 23:16:12 -05:00
d675337d7a Updated gems 2022-12-21 22:04:44 +00:00
2dccf8dd55 Using a proxy for plausible 2022-10-05 00:46:39 +00:00
6eb71ef59e Using a proxy for plausible 2022-10-04 22:54:43 +00:00
67bee921ab Using a proxy for plausible 2022-10-04 22:06:38 +00:00
8672bdd73d Moved from google analytics to plausible 2022-10-04 13:39:47 +00:00
9c1563febf Do not initialize InfluxDB::Rails unless the host environment variable is defined 2022-09-16 19:21:58 +00:00
994fc18365 Added overtime_type to matches 2022-09-13 14:42:40 +00:00
645fb59e5b Fixed tournament search to search each term for both date and name 2022-09-08 14:13:21 +00:00
05acebbf5b Updated passenger pools for test deploy and moved workers to statefulsets in production 2022-08-15 23:26:44 +00:00
9c5ac6c1aa Updated to rails 6.1.6.1 2022-07-12 22:14:34 +00:00
85b0da6a30 Upgraded to rails 6.1.6 2022-07-07 11:58:20 +00:00
907a2eadef Fixed bug on matchstats where p2 was out of line and time_ago_in_words wasn't working 2022-04-29 11:09:22 +00:00
e6797fcce9 Remove therubyracer 2022-04-28 11:22:04 +00:00
add48b95c3 Took away cpu limits due to recommendations in the industry and moved from the beta to v1 ingress apis in K8s 2022-04-28 00:54:03 +00:00
85701e194a Upgraded to rails 6.1.5.1 and Ruby 3.0.4 2022-04-28 00:53:18 +00:00
4d3f93a109 Updated to rails 6.1.5 2022-03-23 19:36:55 +00:00
f9095d8c99 Upgrading circleci machine 2022-03-23 17:43:49 +00:00
a3724914aa Print before import 2022-02-25 13:07:54 +00:00
6e712cd199 Added caching to the school#show page 2022-02-23 21:25:01 +00:00
a3391afe02 Added indexs for matches on weight_id and wrestlers on school_id 2022-02-23 21:25:01 +00:00
cce2e5b5f8 When delegating, only directly match the email to not expose user emails 2022-02-23 21:25:01 +00:00
2cd62bbbd5 Added P2 to stats page 2022-02-23 21:25:00 +00:00
d6a273c964 Fixed the multiplication expr 2022-02-07 13:03:23 +00:00
78bd51cafb export the passenger pool size 2022-02-04 13:29:00 +00:00
ae70128479 Docker compose deploys use the correct passenger workers 2022-02-03 21:33:24 +00:00
9fec6c079f Fixed the stats page 2022-02-03 21:33:24 +00:00
58d088907a Allow nil when modifiying match wrestlers, allow nil when stating a match, fixed tournament navbar on wrestler edit, fixed tournament navbar on edit match wrestlers 2022-01-24 21:54:50 +00:00
7220ffe3c6 Fixed first round bracket name for 8 man brackets 2022-01-22 03:48:50 +00:00
0c9349c871 Moved some text on the tournament show page 2022-01-21 20:45:10 +00:00
d42b683f67 Added a sort by bout number for assign_next_match 2022-01-19 03:28:16 +00:00
f0e8c99b9f Use match id instead of bout number when looking stuff up on bracket view. 2021-12-22 13:13:44 +00:00
6db1dacbb6 Bracket name should not only rely on the round number 2021-12-22 13:12:59 +00:00
eae2c6756c Added 7/8 place match for double elimination bracket view 2021-12-22 13:12:59 +00:00
194fbca978 Updating calculating team scores as a put 2021-12-21 02:38:43 +00:00
1c8e3af5f4 Fixed navbar on school show page 2021-12-21 02:04:08 +00:00
b571bcc749 Fix calculate team scores 2021-12-21 01:23:28 +00:00
a6cc05424c Do not award bye points if they get bye's all the way to the finals and win by bye 2021-12-21 00:39:40 +00:00
efeea574ed Upgraded to rails 6.1.4.4 2021-12-21 00:29:42 +00:00
54e755ba3a Added bye points for double elimination and modified double elimination 2021-12-20 20:48:29 +00:00
8430949a37 Fixed a couple slow queries 2021-12-11 03:08:43 +00:00
5ef27f19cc Fixed ad blocker checker 2021-12-11 03:08:43 +00:00
09651ff12e Updated gems 2021-12-11 03:08:43 +00:00
c0ad06cea7 Fixed syntax error in rake task to finish seed tournaments 2021-11-08 23:09:04 +00:00
ad259f00b5 Fixed n+1 error for matches page on tournament 2021-11-08 22:42:55 +00:00
7ee8abe81a Updated db seeding for all tournament types 2021-11-08 22:42:16 +00:00
cc38c842e0 Updated manifest for mariadb to include backup and metrics 2021-10-21 23:56:49 +00:00
f7ea68da17 Updated gems and rails for vulnerabilities, switched to bundle-audit from hakiri due to hakiri not supporting ruby 3, and removed the travisci gem. 2021-08-30 20:06:31 +00:00
cb5f0e28ae Fixed the CI links on README 2021-08-20 20:29:35 +00:00
873e5b9465 Fixed development compose file syntax error 2021-05-01 13:17:29 +00:00
df6a029ef1 Persist influxdb on dev docker compose 2021-04-01 21:45:47 +00:00
03d884e672 Updated rails to 6.1.3.1 to fix the mimemagic issues 2021-04-01 20:06:51 +00:00
e1cba865b0 Added influxdb to wrestlingdev 2021-04-01 19:52:18 +00:00
e36de59971 Mispelled include for fixing bracket partial bug 2021-03-03 00:39:34 +00:00
329c01db79 Added 1 more hint for tournament types 2021-03-03 00:38:01 +00:00
4cdc9e7df1 Split bracket integration tests into a logical separation 2021-03-03 00:24:14 +00:00
1f43fdf8fa Updated about page for modified 16 man bracket 2021-03-03 00:24:14 +00:00
f6aff5a753 Fixed bracket partial bug 2021-03-03 00:24:14 +00:00
3dabc16a82 Added regular double elimination placing 1-8 tournament 2021-03-01 23:55:35 +00:00
9d51ef7b51 Fixed all brackets page 2021-03-01 13:28:00 +00:00
63b0541aa4 Added a precision and scale to the school score to make sure decimals are stored in mysql 2021-02-22 16:22:06 +00:00
1e30344be8 Fixed bug where wrestler deducted points were deducting twice from the team score 2021-02-22 16:21:22 +00:00
683b2967af Fix team score to have half a point 2021-02-22 15:29:29 +00:00
432903e7a9 Fixed small bug in modified 16 man double elim brackets 2021-02-22 13:42:25 +00:00
537eccf04d Added tests for modified double elimination, added a 1-8 place modified double elimination, and renamed regular double elimination 2021-02-20 01:33:31 +00:00
89a695388a Change school abbreviation if school has 3 names 2021-02-19 17:09:47 +00:00
0aea26967a Added quick create high school girls weight classes 2021-02-18 20:27:44 +00:00
5677f4e944 Updated development to allow all hostnames (for localtunnel) 2021-02-18 20:27:44 +00:00
f5ddc6652d Trying to fix all_brackets 2021-02-17 04:00:59 +00:00
987c89b7d5 Fix all brackets view for Rails 6 2021-02-17 03:44:55 +00:00
b2ba1901df Changed forfeit bracket label to FF 2021-02-17 03:38:03 +00:00
6c86f25add Added html_safe for all_matches view 2021-02-17 03:37:52 +00:00
ce063f5faa Fixed error_string bug in match generations 2021-02-15 13:40:54 +00:00
396e4be5b3 Fix deploy job and put into workflow 2021-02-12 19:29:27 +00:00
46919a2b1b Add heroku deploy to circleci 2021-02-12 19:13:39 +00:00
55d122771c Had to create storage.yml for activestorage for Rails 6.1 upgrade and changed config to use mem_cache_store instead of dalli_store 2021-02-12 13:16:30 +00:00
e43f3253d4 Updated README for new versions of rails and ruby 2021-02-12 12:54:00 +00:00
f720de0db6 Fixed deprecations for rails 6.1 and 6.2 2021-02-12 12:17:46 +00:00
44c9f947d7 Use user_id for dev script 2021-02-11 16:39:29 +00:00
ee8d861bee Updated to rails 6.1.2 and updated all gems 2021-02-11 16:39:17 +00:00
bdd80fc1d2 Updated to ruby 3.0.0 2021-02-11 12:33:25 +00:00
db15e79c0f Updated to rails 6.0.3.4 2020-11-10 15:58:26 -05:00
1f5aa304ff Updated to ruby 2.7.2 and rails 6.0.3.3 2020-11-10 15:45:30 -05:00
4522113396 Added status badge for circleci and removed travisci config 2020-11-10 15:44:51 -05:00
7327902fe8 Merge pull request #13 from jcwimer/circleci-project-setup
Add .circleci/config.yml
2020-11-06 12:29:02 -05:00
121 changed files with 3844 additions and 1500 deletions

View File

@@ -1,10 +1,43 @@
version: 2
workflows: # Define a Workflow running the build job, then the deploy job
version: 2
build-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master # Only deploys when the commit is on the Master branch
jobs:
build:
machine: true
steps:
- checkout
# start proprietary DB using private Docker image
# with credentials stored in the UI
- run: |
bash bin/run-tests-with-docker.sh
bash bin/run-tests-with-docker.sh
# https://github.com/circleci/circleci-docs/blob/master/jekyll/_cci1/continuous-deployment-with-heroku.md
deploy:
machine:
image: ubuntu-2004:current
docker_layer_caching: true
steps:
- checkout
- run: |
echo Deploys are happening on my home Jenkins server
echo this is a placeholder in case I want to move that
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

View File

@@ -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

10
Gemfile
View File

@@ -1,8 +1,8 @@
source 'https://rubygems.org'
ruby '2.6.5'
ruby '3.0.4'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '6.0.3.2'
gem 'rails', '6.1.7.2'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3', '~> 1.3', '< 1.4', :group => :development
gem 'sqlite3', :group => :development
@@ -38,16 +38,15 @@ gem 'spring', :group => :development
# Use debugger
# gem 'debugger', group: [:development, :test]
#Installed by me
group :production do
gem 'rails_12factor'
gem 'mysql2'
gem 'therubyracer'
gem 'newrelic_rpm'
gem 'dalli'
end
gem 'influxdb-rails'
gem 'devise'
gem 'cancancan'
gem 'round_robin_tournament'
@@ -63,7 +62,6 @@ group :development do
gem 'rubocop'
gem 'bullet'
gem 'brakeman'
gem 'hakiri'
gem 'travis'
gem 'bundler-audit'
end

View File

@@ -1,71 +1,76 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (6.0.3.2)
actionpack (= 6.0.3.2)
actioncable (6.1.7.2)
actionpack (= 6.1.7.2)
activesupport (= 6.1.7.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
actionmailbox (6.1.7.2)
actionpack (= 6.1.7.2)
activejob (= 6.1.7.2)
activerecord (= 6.1.7.2)
activestorage (= 6.1.7.2)
activesupport (= 6.1.7.2)
mail (>= 2.7.1)
actionmailer (6.0.3.2)
actionpack (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
actionmailer (6.1.7.2)
actionpack (= 6.1.7.2)
actionview (= 6.1.7.2)
activejob (= 6.1.7.2)
activesupport (= 6.1.7.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3.2)
actionview (= 6.0.3.2)
activesupport (= 6.0.3.2)
rack (~> 2.0, >= 2.0.8)
actionpack (6.1.7.2)
actionview (= 6.1.7.2)
activesupport (= 6.1.7.2)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3.2)
actionpack (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
actiontext (6.1.7.2)
actionpack (= 6.1.7.2)
activerecord (= 6.1.7.2)
activestorage (= 6.1.7.2)
activesupport (= 6.1.7.2)
nokogiri (>= 1.8.5)
actionview (6.0.3.2)
activesupport (= 6.0.3.2)
actionview (6.1.7.2)
activesupport (= 6.1.7.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (6.0.3.2)
activesupport (= 6.0.3.2)
activejob (6.1.7.2)
activesupport (= 6.1.7.2)
globalid (>= 0.3.6)
activemodel (6.0.3.2)
activesupport (= 6.0.3.2)
activerecord (6.0.3.2)
activemodel (= 6.0.3.2)
activesupport (= 6.0.3.2)
activestorage (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
marcel (~> 0.3.1)
activesupport (6.0.3.2)
activemodel (6.1.7.2)
activesupport (= 6.1.7.2)
activerecord (6.1.7.2)
activemodel (= 6.1.7.2)
activesupport (= 6.1.7.2)
activestorage (6.1.7.2)
actionpack (= 6.1.7.2)
activejob (= 6.1.7.2)
activerecord (= 6.1.7.2)
activesupport (= 6.1.7.2)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.7.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
addressable (2.4.0)
ast (2.4.1)
backports (3.18.2)
bcrypt (3.1.16)
brakeman (4.9.1)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
ast (2.4.2)
bcrypt (3.1.18)
brakeman (5.4.0)
builder (3.2.4)
bullet (6.1.0)
bullet (7.0.7)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
cancancan (3.1.0)
bundler-audit (0.9.1)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
cancancan (3.4.0)
coffee-rails (5.0.0)
coffee-script (>= 2.2.0)
railties (>= 5.2.0)
@@ -73,240 +78,191 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
commander (4.4.6)
highline (~> 1.7.2)
concurrent-ruby (1.1.7)
concurrent-ruby (1.2.0)
crass (1.0.6)
daemons (1.3.1)
dalli (2.7.10)
delayed_job (4.1.8)
activesupport (>= 3.0, < 6.1)
delayed_job_active_record (4.1.4)
activerecord (>= 3.0, < 6.1)
daemons (1.4.1)
dalli (3.2.3)
date (3.3.3)
delayed_job (4.1.11)
activesupport (>= 3.0, < 8.0)
delayed_job_active_record (4.1.7)
activerecord (>= 3.0, < 8.0)
delayed_job (>= 3.0, < 5)
delayed_job_web (1.4.3)
delayed_job_web (1.4.4)
activerecord (> 3.0.0)
delayed_job (> 2.0.3)
rack-protection (>= 1.5.5)
sinatra (>= 1.4.4)
devise (4.7.2)
devise (4.8.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
erubi (1.9.0)
ethon (0.12.0)
ffi (>= 1.3.0)
execjs (2.7.0)
faraday (0.17.3)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.14.0)
faraday (>= 0.7.4, < 1.0)
ffi (1.13.1)
gh (0.15.1)
addressable (~> 2.4.0)
backports
faraday (~> 0.8)
multi_json (~> 1.0)
net-http-persistent (~> 2.9)
net-http-pipeline
globalid (0.4.2)
activesupport (>= 4.2.0)
hakiri (0.7.2)
activesupport
bundler
commander
i18n
json
rake
rest-client
terminal-table
highline (1.7.10)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.8.5)
erubi (1.12.0)
execjs (2.8.1)
globalid (1.1.0)
activesupport (>= 5.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
jbuilder (2.10.1)
influxdb (0.8.1)
influxdb-rails (1.0.3)
influxdb (~> 0.6, >= 0.6.4)
railties (>= 5.0)
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jquery-rails (4.4.0)
jquery-rails (4.5.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.3.1)
launchy (2.4.3)
addressable (~> 2.3)
libv8 (3.16.14.19)
loofah (2.7.0)
json (2.6.3)
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mail (2.8.0.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
mimemagic (~> 0.3.2)
net-imap
net-pop
net-smtp
marcel (1.0.2)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
minitest (5.14.2)
multi_json (1.15.0)
multipart-post (2.1.1)
mustermann (1.1.1)
mini_mime (1.1.2)
minitest (5.17.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
net-http-persistent (2.9.4)
net-http-pipeline (1.0.1)
netrc (0.11.0)
newrelic_rpm (6.12.0.367)
nio4r (2.5.3)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
mysql2 (0.5.5)
net-imap (0.3.4)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
timeout
net-smtp (0.3.3)
net-protocol
newrelic_rpm (8.15.0)
nio4r (2.5.8)
nokogiri (1.14.1-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.19.2)
parser (2.7.1.4)
parallel (1.22.1)
parser (3.2.0.0)
ast (~> 2.4.1)
passenger (6.0.6)
passenger (6.0.17)
rack
rake (>= 0.8.1)
puma (4.3.6)
psych (5.0.2)
stringio
puma (6.0.2)
nio4r (~> 2.0)
pusher-client (0.6.2)
json
websocket (~> 1.0)
rack (2.2.3)
rack-protection (2.1.0)
racc (1.6.2)
rack (2.2.6.2)
rack-protection (3.0.5)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3.2)
actioncable (= 6.0.3.2)
actionmailbox (= 6.0.3.2)
actionmailer (= 6.0.3.2)
actionpack (= 6.0.3.2)
actiontext (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
activemodel (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
bundler (>= 1.3.0)
railties (= 6.0.3.2)
rack-test (2.0.2)
rack (>= 1.3)
rails (6.1.7.2)
actioncable (= 6.1.7.2)
actionmailbox (= 6.1.7.2)
actionmailer (= 6.1.7.2)
actionpack (= 6.1.7.2)
actiontext (= 6.1.7.2)
actionview (= 6.1.7.2)
activejob (= 6.1.7.2)
activemodel (= 6.1.7.2)
activerecord (= 6.1.7.2)
activestorage (= 6.1.7.2)
activesupport (= 6.1.7.2)
bundler (>= 1.15.0)
railties (= 6.1.7.2)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (6.0.3.2)
actionpack (= 6.0.3.2)
activesupport (= 6.0.3.2)
railties (6.1.7.2)
actionpack (= 6.1.7.2)
activesupport (= 6.1.7.2)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
rainbow (3.0.0)
rake (13.0.1)
rake (>= 12.2)
thor (~> 1.0)
rainbow (3.1.1)
rake (13.0.6)
rb-readline (0.5.5)
rdoc (6.2.1)
ref (2.0.0)
regexp_parser (1.7.1)
rdoc (6.5.0)
psych (>= 4.0.0)
regexp_parser (2.6.2)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.4)
round_robin_tournament (0.0.1)
rubocop (0.91.0)
rexml (3.2.5)
round_robin_tournament (0.1.1)
rubocop (1.44.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 2.7.1.1)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.4.0, < 1.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.24.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.4.0)
parser (>= 2.7.1.4)
ruby-progressbar (1.10.1)
ruby2_keywords (0.0.2)
sdoc (1.1.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.24.1)
parser (>= 3.1.1.0)
ruby-progressbar (1.11.0)
ruby2_keywords (0.0.5)
sdoc (2.6.0)
rdoc (>= 5.0)
sinatra (2.1.0)
mustermann (~> 1.0)
rack (~> 2.2)
rack-protection (= 2.1.0)
sinatra (3.0.5)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.0.5)
tilt (~> 2.0)
spring (2.1.1)
sprockets (4.0.2)
spring (4.1.1)
sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.4.2)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (1.0.1)
thread_safe (0.3.6)
tilt (2.0.10)
travis (1.8.13)
backports
faraday (~> 0.9)
faraday_middleware (~> 0.9, >= 0.9.1)
gh (~> 0.13)
highline (~> 1.6)
launchy (~> 2.1)
pusher-client (~> 0.4)
typhoeus (~> 0.6, >= 0.6.8)
sqlite3 (1.6.0-x86_64-linux)
stringio (3.0.4)
thor (1.2.1)
tilt (2.0.11)
timeout (0.3.1)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
typhoeus (0.8.0)
ethon (>= 0.8.0)
tzinfo (1.2.7)
thread_safe (~> 0.1)
tzinfo-data (1.2020.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2022.7)
tzinfo (>= 1.0.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
unicode-display_width (1.7.0)
uniform_notifier (1.13.0)
unicode-display_width (2.4.2)
uniform_notifier (1.16.0)
warden (1.2.9)
rack (>= 2.0.9)
websocket (1.2.8)
websocket-driver (0.7.3)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
zeitwerk (2.4.0)
zeitwerk (2.6.6)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
brakeman
bullet
bundler-audit
cancancan
coffee-rails
daemons
@@ -314,14 +270,14 @@ DEPENDENCIES
delayed_job_active_record
delayed_job_web
devise
hakiri
influxdb-rails
jbuilder
jquery-rails
mysql2
newrelic_rpm
passenger
puma
rails (= 6.0.3.2)
rails (= 6.1.7.2)
rails_12factor
rb-readline
round_robin_tournament
@@ -329,14 +285,12 @@ DEPENDENCIES
sdoc
spring
sqlite3
therubyracer
travis
turbolinks
tzinfo-data
uglifier
RUBY VERSION
ruby 2.6.5p114
ruby 3.0.4p208
BUNDLED WITH
2.0.2
2.2.30

View File

@@ -2,10 +2,10 @@
This application is being created to run a wrestling tournament.
### Current master status
[![Build Status](https://travis-ci.org/jcwimer/wrestlingApp.svg?branch=master)](https://travis-ci.org/jcwimer/wrestlingApp)
[![Build Status](https://circleci.com/gh/jcwimer/wrestlingApp/tree/master.svg)](https://circleci.com/gh/jcwimer/wrestlingApp/tree/master)
### Current development status
[![Build Status](https://travis-ci.org/jcwimer/wrestlingApp.svg?branch=development)](https://travis-ci.org/jcwimer/wrestlingApp)
[![Build Status](https://circleci.com/gh/jcwimer/wrestlingApp/tree/development.svg)](https://circleci.com/gh/jcwimer/wrestlingApp/tree/development)
# Info
**License:** MIT License
@@ -13,8 +13,8 @@ This application is being created to run a wrestling tournament.
**Public Production Url:** [https://wrestlingdev.com](http://wrestlingdev.com)
**App Info**
* Ruby 2.6.5
* Rails 6.0.1
* Ruby 3.0.0
* Rails 6.1.2
* DB mysql or mariadb
* Memcached
* Delayed Jobs
@@ -30,10 +30,27 @@ From here, you can run the normal rails commands.
* `rails generate blah blah blah`
* ` rails s -b 0.0.0.0` port 3000 is exposed. You can open [http://localhost:3000](http://localhost:3000) after running that command
* etc.
* `rake finish_seed_tournament` will complete all matches from the seed data. This command takes about 5 minutes to execute
* `rake finish_seed_tournaments` will complete all matches from the seed data. This command takes about 5 minutes to execute
To deploy a a full local version of the app `bash deploy/deploy-test.sh` (this requires docker-compose to be installed). This deploys a full version of the app. App, delayed job, memcached, and mariadb. Now, you can open [http://localhost](http://localhost). Delayed jobs are turned off in dev and everything that is a delayed job in prod just runs in browser.
To run a single test file:
1. Get a shell with ruby and rails: `bash bin/rails-dev-run.sh wrestlingdev-development`
2. `rake test TEST=test/models/match_test.rb`
To run a single test inside a file:
1. Get a shell with ruby and rails: `bash bin/rails-dev-run.sh wrestlingdev-development`
2. `rake test TEST=test/models/match_test.rb TESTOPTS="--name='/test_Match_should_not_be_valid_if_an_incorrect_win_type_is_given/'"`
## Update gems
1. `bash bin/rails-dev-run.sh wrestlingdev-dev` to open a contianer with a rails shell available
2. `bundle config --delete without` to remove the bundle config that ignores production gems
3. `bundle update`
Note: If updating rails, do not change the version in `Gemfile` until after you run `bash bin/run-rails-dev.sh wrestlingdev-dev`. Creating the container will fail due to a mismatch in Gemfile and Gemfile.lock.
Then run `rails app:update` to update rails.
# Deployment
The production version of this is currently deployed in Kubernetes. See [Deploying with Kubernetes](deploy/kubernetes/README.md)
@@ -54,3 +71,8 @@ The production version of this is currently deployed in Kubernetes. See [Deployi
* `MEMCACHIER_SERVERS=memcachier_hostname:memcachier_port` needed for caching
* `MEMCACHIER_USERNAME=memcachier_username` needed for caching
* `WRESTLINGDEV_NEW_RELIC_LICENSE_KEY=new_relic_license_key` this is only needed to use new relic
* `WRESTLINGDEV_INFLUXDB_DATABASE=influx_db_name` to send metrics to influxdb this is required
* `WRESTLINGDEV_INFLUXDB_HOST=influx_db_ip_or_hostname` to send metrics to influxdb this is required
* `WRESTLINGDEV_INFLUXDB_PORT=influx_db_port` to send metrics to influxdb this is required
* `WRESTLINGDEV_INFLUXDB_USERNAME=influx_db_username` to send metrics to influxdb this is optional
* `WRESTLINGDEV_INFLUXDB_PASSWORD=influx_db_password` to send metrics to influxdb this is optional

View File

@@ -15,6 +15,10 @@ class ApiController < ApplicationController
def tournament
@tournament = Tournament.where(:id => params[:tournament]).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first
@schools = @tournament.schools.includes(:wrestlers)
@weights = @tournament.weights.includes(:wrestlers)
@matches = @tournament.matches.includes(:wrestlers,:schools)
@mats = @tournament.mats.includes(:matches)
end
def newTournament

View File

@@ -16,6 +16,7 @@ class MatchesController < ApplicationController
end
if @match
@wrestlers = @match.weight.wrestlers
@tournament = @match.tournament
end
session[:return_path] = "/tournaments/#{@match.tournament.id}/matches"
end
@@ -24,13 +25,32 @@ class MatchesController < ApplicationController
if params[:match]
@match = Match.where(:id => params[:match]).includes(:wrestlers).first
end
@wrestlers = []
if @match
@w1 = @match.wrestler1
@w2 = @match.wrestler2
@wrestlers = [@w1,@w2]
if @match.w1
@wrestler1_name = @match.wrestler1.name
@wrestler1_school_name = @match.wrestler1.school.name
@wrestler1_last_match = @match.wrestler1.last_match
@wrestlers.push(@match.wrestler1)
else
@wrestler1_name = "Not assigned"
@wrestler1_school_name = "N/A"
@wrestler1_last_match = nil
end
if @match.w2
@wrestler2_name = @match.wrestler2.name
@wrestler2_school_name = @match.wrestler2.school.name
@wrestler2_last_match = @match.wrestler2.last_match
@wrestlers.push(@match.wrestler2)
else
@wrestler2_name = "Not assigned"
@wrestler2_school_name = "N/A"
@wrestler2_last_match = nil
end
@tournament = @match.tournament
end
session[:return_path] = "/tournaments/#{@tournament.id}/matches"
session[:error_return_path] = "/matches/#{@match.id}/stat"
end
@@ -46,8 +66,13 @@ class MatchesController < ApplicationController
end
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @match.errors, status: :unprocessable_entity }
if session[:error_return_path]
format.html { redirect_to session.delete(:error_return_path), alert: "Match did not save because: #{@match.errors.full_messages.to_s}" }
format.json { render json: @match.errors, status: :unprocessable_entity }
else
format.html { redirect_to "/tournaments/#{@match.tournament.id}", alert: "Match did not save because: #{@match.errors.full_messages.to_s}" }
format.json { render json: @match.errors, status: :unprocessable_entity }
end
end
end
end
@@ -61,7 +86,7 @@ class MatchesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def match_params
params.require(:match).permit(:w1, :w2, :w1_stat, :w2_stat, :winner_id, :win_type, :score, :finished)
params.require(:match).permit(:w1, :w2, :w1_stat, :w2_stat, :winner_id, :win_type, :score, :overtime_type, :finished)
end
def check_access

View File

@@ -1,18 +1,38 @@
class MatsController < ApplicationController
before_action :set_mat, only: [:show, :edit, :update, :destroy]
before_action :check_access, only: [:new,:create,:update,:destroy,:edit,:show]
before_action :set_mat, only: [:show, :edit, :update, :destroy, :assign_next_match]
before_action :check_access, only: [:new,:create,:update,:destroy,:edit,:show, :assign_next_match]
before_action :check_for_matches, only: [:show]
# GET /mats/1
# GET /mats/1.json
def show
@match = @mat.unfinished_matches.first
@wrestlers = []
if @match
@w1 = @match.wrestler1
@w2 = @match.wrestler2
@wrestlers = [@w1,@w2]
if @match.w1
@wrestler1_name = @match.wrestler1.name
@wrestler1_school_name = @match.wrestler1.school.name
@wrestler1_last_match = @match.wrestler1.last_match
@wrestlers.push(@match.wrestler1)
else
@wrestler1_name = "Not assigned"
@wrestler1_school_name = "N/A"
@wrestler1_last_match = nil
end
if @match.w2
@wrestler2_name = @match.wrestler2.name
@wrestler2_school_name = @match.wrestler2.school.name
@wrestler2_last_match = @match.wrestler2.last_match
@wrestlers.push(@match.wrestler2)
else
@wrestler2_name = "Not assigned"
@wrestler2_school_name = "N/A"
@wrestler2_last_match = nil
end
@tournament = @match.tournament
end
session[:return_path] = request.original_fullpath
session[:error_return_path] = request.original_fullpath
end
# GET /mats/new
@@ -44,6 +64,20 @@ class MatsController < ApplicationController
end
end
# POST /mats/1/assign_next_match
def assign_next_match
@tournament = @mat.tournament_id
respond_to do |format|
if @mat.assign_next_match
format.html { redirect_to "/tournaments/#{@mat.tournament.id}", notice: "Next Match on Mat #{@mat.name} successfully completed." }
format.json { head :no_content }
else
format.html { redirect_to "/tournaments/#{@mat.tournament.id}", alert: "There was an error." }
format.json { head :no_content }
end
end
end
# PATCH/PUT /mats/1
# PATCH/PUT /mats/1.json
def update

View File

@@ -2,7 +2,7 @@ class SchoolsController < ApplicationController
before_action :set_school, only: [:import_baumspage_roster, :show, :edit, :update, :destroy, :stats]
before_action :check_access_director, only: [:new,:create,:destroy]
before_action :check_access_delegate, only: [:import_baumspage_roster, :update,:edit]
before_action :check_read_access, only: [:show]
def stats
@tournament = @school.tournament
@@ -12,7 +12,7 @@ class SchoolsController < ApplicationController
# GET /schools/1.json
def show
session.delete(:return_path)
@wrestlers = @school.wrestlers.includes(:deductedPoints,:matches,:weight)
@wrestlers = @school.wrestlers.includes(:deductedPoints,:matches,:weight,:school)
@tournament = @school.tournament
end
@@ -108,5 +108,9 @@ class SchoolsController < ApplicationController
def check_access_delegate
authorize! :manage, @school
end
def check_read_access
authorize! :read, @school
end
end

View File

@@ -4,6 +4,7 @@ class TournamentsController < ApplicationController
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
before_action :check_tournament_errors, only: [:generate_matches]
before_action :check_for_matches, only: [:up_matches,:bracket,:all_brackets]
before_action :check_access_read, only: [:up_matches,:bracket,:all_brackets]
def weigh_in_sheet
@@ -14,11 +15,11 @@ class TournamentsController < ApplicationController
end
def calculate_team_scores
@tournament.schools.each do |school|
school.calculate_score
end
respond_to do |format|
format.html { redirect_to "/tournaments/#{@tournament.id}", notice: 'Team scores are calcuating.' }
if @tournament.calculate_all_team_scores
format.html { redirect_to "/tournaments/#{@tournament.id}", notice: 'Team scores are calcuating.' }
format.json { head :no_content }
end
end
end
@@ -27,7 +28,7 @@ class TournamentsController < ApplicationController
respond_to do |format|
if WrestlingdevImporter.new(@tournament,import_text).import
format.html { redirect_to "/tournaments/#{@tournament.id}", notice: 'Import is on-going. This will take 1-5 minutes.' }
format.json { render action: 'show', status: :created, location: @tournament }
format.json { head :no_content }
end
end
end
@@ -92,7 +93,7 @@ class TournamentsController < ApplicationController
def school_delegate
if params[:search]
@users = User.limit(200).search(params[:search])
@user = User.where('email = ?', params[:search]).first
elsif params[:school_delegate]
@delegate = SchoolDelegate.new
@delegate.user_id = params[:school_delegate]["user_id"]
@@ -104,19 +105,18 @@ class TournamentsController < ApplicationController
format.html { redirect_to "/tournaments/#{@tournament.id}/school_delegate", notice: 'There was an issue delegating permissions please try again' }
end
end
else
@users_delegates = []
@tournament.schools.each do |s|
s.delegates.each do |d|
@users_delegates << d
end
end
@users_delegates = []
@tournament.schools.each do |s|
s.delegates.each do |d|
@users_delegates << d
end
end
end
def delegate
if params[:search]
@users = User.limit(200).search(params[:search])
@user = User.where('email = ?', params[:search]).first
elsif params[:tournament_delegate]
@delegate = TournamentDelegate.new
@delegate.user_id = params[:tournament_delegate]["user_id"]
@@ -128,13 +128,12 @@ class TournamentsController < ApplicationController
format.html { redirect_to "/tournaments/#{@tournament.id}/delegate", notice: 'There was an issue delegating permissions please try again' }
end
end
else
@users_delegates = @tournament.delegates
end
@users_delegates = @tournament.delegates
end
def matches
@matches = @tournament.matches.sort_by{|m| m.bout_number}
@matches = @tournament.matches.includes(:wrestlers,:schools).sort_by{|m| m.bout_number}
if @match
@w1 = @match.wrestler1
@w2 = @match.wrestler2
@@ -165,7 +164,7 @@ class TournamentsController < ApplicationController
end
def create_custom_weights
@custom = params[:customValue].to_s
@custom = params[:customValue].split(",")
@tournament.create_pre_defined_weights(@custom)
redirect_to "/tournaments/#{@tournament.id}"
end
@@ -174,12 +173,14 @@ class TournamentsController < ApplicationController
def all_brackets
@schools = @tournament.schools
@schools = @schools.sort_by{|s| s.page_score_string}.reverse!
@matches = @tournament.matches.includes(:wrestlers,:schools)
@weights = @tournament.weights.includes(:matches,:wrestlers)
end
def bracket
if params[:weight]
@weight = Weight.where(:id => params[:weight]).includes(:matches,:wrestlers).first
@matches = @weight.matches
@matches = @weight.matches.includes(:schools,:wrestlers)
@wrestlers = @weight.wrestlers.includes(:school)
if @tournament.tournament_type == "Pool to bracket"
@pools = @weight.pool_rounds(@matches)
@@ -221,16 +222,17 @@ class TournamentsController < ApplicationController
def index
if params[:search]
@tournaments = Tournament.limit(200).search(params[:search]).order("created_at DESC")
# @tournaments = Tournament.limit(200).search(params[:search]).order("date DESC")
@tournaments = Tournament.limit(200).search_date_name(params[:search]).order("date DESC")
else
@tournaments = Tournament.all.sort_by{|t| t.days_until_start}.first(20)
end
end
def show
@schools = @tournament.schools.includes(:delegates)
@schools = @tournament.schools.includes(:delegates).sort_by{|school|school.name}
@weights = @tournament.weights.sort_by{|x|[x.max]}
@mats = @tournament.mats
@mats = @tournament.mats.sort_by{|mat|mat.name}
end
def new
@@ -288,7 +290,7 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
params.require(:tournament).permit(:name, :address, :director, :director_email, :tournament_type, :weigh_in_ref, :user_id, :date, :originalId, :swapId)
params.require(:tournament).permit(:name, :address, :director, :director_email, :tournament_type, :weigh_in_ref, :user_id, :date, :originalId, :swapId, :is_public)
end
#Check for tournament owner
@@ -300,6 +302,10 @@ class TournamentsController < ApplicationController
authorize! :manage, @tournament
end
def check_access_read
authorize! :read, @tournament
end
def check_for_matches
if @tournament
if @tournament.matches.empty? or @tournament.curently_generating_matches == 1

View File

@@ -1,6 +1,7 @@
class WeightsController < ApplicationController
before_action :set_weight, only: [:pool_order, :show, :edit, :update, :destroy,:re_gen]
before_action :check_access, only: [:pool_order, :new,:create,:update,:destroy,:edit, :re_gen]
before_action :check_access_manage, only: [:pool_order, :new,:create,:update,:destroy,:edit, :re_gen]
before_action :check_access_read, only: [:show]
# GET /weights/1
@@ -103,7 +104,7 @@ class WeightsController < ApplicationController
def weight_params
params.require(:weight).permit(:max, :tournament_id, :mat_id)
end
def check_access
def check_access_manage
if params[:tournament]
@tournament = Tournament.find(params[:tournament])
elsif params[:weight]
@@ -114,5 +115,16 @@ class WeightsController < ApplicationController
authorize! :manage, @tournament
end
def check_access_read
if params[:tournament]
@tournament = Tournament.find(params[:tournament])
elsif params[:weight]
@tournament = Tournament.find(params[:weight]["tournament_id"])
elsif @weight
@tournament = @weight.tournament
end
authorize! :read, @tournament
end
end

View File

@@ -30,6 +30,7 @@ class WrestlersController < ApplicationController
# GET /wrestlers/1/edit
def edit
@tournament = @wrestler.tournament
@weight = @wrestler.weight
@weights = @school.tournament.weights.sort_by{|w| w.max}
@school = @wrestler.school

View File

@@ -38,6 +38,16 @@ class Ability
cannot :destroy, Tournament do |tournament|
tournament.delegates.map(&:user_id).include? user.id
end
# Can read tournament if tournament owner or tournament delegate
can :read, Tournament do |tournament|
if tournament.is_public
true
elsif tournament.delegates.map(&:user_id).include? user.id or tournament.user_id == user.id
true
else
false
end
end
#Can manage school if tournament owner
can :manage, School do |school|
school.tournament.user_id == user.id
@@ -53,6 +63,34 @@ class Ability
cannot :destroy, School do |school|
school.delegates.map(&:user_id).include? user.id
end
# Can read school if school delegate, tournament delegate, or tournament director
can :read, School do |school|
if school.tournament.is_public
true
elsif school.delegates.map(&:user_id).include? user.id or school.tournament.delegates.map(&:user_id).include? user.id or school.tournament.user_id == user.id
true
else
false
end
end
# Default for non logged in users
else
# Can read tournament if tournament is public
can :read, Tournament do |tournament|
if tournament.is_public
true
else
false
end
end
# Can read school if tournament is public
can :read, School do |school|
if school.tournament.is_public
true
else
false
end
end
end
end
end

View File

@@ -21,11 +21,25 @@ class Mat < ActiveRecord::Base
end
def assign_next_match
t_matches = tournament.matches.select{|m| m.mat_id == nil && m.finished != 1 && m.bout_number != nil}
if t_matches.size > 0
t_matches = tournament.matches.select{|m| m.mat_id == nil && m.finished != 1 && m.bout_number != nil}.sort_by{|m| m.bout_number}
if t_matches.size > 0 and self.unfinished_matches.size < 4
match = t_matches.sort_by{|m| m.bout_number}.first
match.mat_id = self.id
match.save
if match.save
if match.w1
match.wrestler1.touch
match.wrestler1.school.touch
end
if match.w2
match.wrestler2.touch
match.wrestler2.school.touch
end
return true
else
return false
end
else
return true
end
end

View File

@@ -3,16 +3,18 @@ class Match < ActiveRecord::Base
belongs_to :weight, touch: true
belongs_to :mat, touch: true
has_many :wrestlers, :through => :weight
has_many :schools, :through => :wrestlers
validate :score_validation, :win_type_validation, :bracket_position_validation, :overtime_type_validation
after_update :after_finished_actions, :if => :saved_change_to_finished? or :saved_change_to_winner_id? or :saved_change_to_win_type? or :saved_change_to_score?
def after_finished_actions
if self.w1
wrestler1.touch
end
if self.w2
wrestler2.touch
end
if self.finished == 1 && self.winner_id != nil
if self.w1
wrestler1.touch
end
if self.w2
wrestler2.touch
end
if self.mat
self.mat.assign_next_match
end
@@ -23,6 +25,45 @@ class Match < ActiveRecord::Base
BRACKET_POSITIONS = ["Pool","1/2","3/4","5/6","7/8","Quarter","Semis","Conso Semis","Bracket","Conso", "Conso Quarter"]
WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default", "DQ", "BYE"]
OVERTIME_TYPES = ["", "SV-1", "TB-1", "UTB", "SV-2", "TB-2", "OT"] # had to keep the blank here for validations
def score_validation
if finished == 1
if ! winner_id
errors.add(:winner_id, "cannot be blank")
end
if win_type == "Pin" and ! score.match(/^[0-5]?[0-9]:[0-5][0-9]/)
errors.add(:score, "needs to be in time format MM:SS when win type is Pin example: 1:23 or 10:03")
end
if win_type == "Decision" or win_type == "Tech Fall" or win_type == "Major" and ! score.match(/^[0-9]?[0-9]-[0-9]?[0-9]/)
errors.add(:score, "needs to be in Number-Number format when win type is Decision, Tech Fall, and Major example: 10-2")
end
if (win_type == "Forfeit" or win_type == "Injury Default" or win_type == "Default" or win_type == "BYE" or win_type == "DQ") and (score != "")
errors.add(:score, "needs to be blank when win type is Forfeit, Injury Default, Default, BYE, or DQ win_type")
end
end
end
def win_type_validation
if finished == 1
if ! WIN_TYPES.include? win_type
errors.add(:win_type, "can only be one of the following #{WIN_TYPES.to_s}")
end
end
end
def overtime_type_validation
# overtime_type can be nil or of type OVERTIME_TYPES
if overtime_type != nil and ! OVERTIME_TYPES.include? overtime_type
errors.add(:overtime_type, "can only be one of the following #{OVERTIME_TYPES.to_s}")
end
end
def bracket_position_validation
if ! BRACKET_POSITIONS.include? bracket_position
errors.add(:bracket_position, "can only be one of the following #{BRACKET_POSITIONS.to_s}")
end
end
def is_consolation_match
if self.bracket_position == "Conso" or self.bracket_position == "Conso Quarter" or self.bracket_position == "Conso Semis" or self.bracket_position == "3/4" or self.bracket_position == "5/6" or self.bracket_position == "7/8"
@@ -89,17 +130,19 @@ class Match < ActiveRecord::Base
return ""
end
if self.finished == 1
if self.win_type == "Default"
return "(Def)"
elsif self.win_type == "Injury Default"
overtime_type_abbreviation = ""
if self.overtime_type != "" and self.overtime_type
overtime_type_abbreviation = " #{self.overtime_type}"
end
if self.win_type == "Injury Default"
return "(Inj)"
elsif self.win_type == "DQ"
return "(DQ)"
elsif self.win_type == "Forfeit"
return "(For)"
return "(FF)"
else
win_type_abbreviation = "#{self.win_type.chars.to_a[0..2].join('')}"
return "(#{win_type_abbreviation} #{self.score})"
return "(#{win_type_abbreviation} #{self.score}#{overtime_type_abbreviation})"
end
end
end
@@ -136,7 +179,7 @@ class Match < ActiveRecord::Base
return_string_ending = return_string_ending + "</strong>"
end
if self.w1 != nil
if self.round == 1
if self.round == 1 and (self.bracket_position == "Bracket" or self.bracket_position == "Quarter")
if self.wrestler1.original_seed
return_string = return_string + "[#{wrestler1.original_seed}] "
end
@@ -158,7 +201,7 @@ class Match < ActiveRecord::Base
return_string_ending = return_string_ending + "</strong>"
end
if self.w2 != nil
if self.round == 1
if self.round == 1 and self.bracket_position == "Bracket"
if self.wrestler2.original_seed
return_string = return_string + "#{wrestler2.original_seed} "
end

View File

@@ -14,10 +14,15 @@ class School < ActiveRecord::Base
def abbreviation
name_array = self.name.split(' ')
if name_array.size > 1
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a[0..1].join('').upcase}"
if name_array.size > 2
# If three words, use first letter of first word, first letter of second, and first two of third
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a.first}#{name_array[2].chars.to_a[0..1].join('').upcase}"
elsif name_array.size > 1
# If two words use first letter of first word and first three of the second
return "#{name_array[0].chars.to_a.first}#{name_array[1].chars.to_a[0..2].join('').upcase}"
else
return "#{name_array[0].chars.to_a[0..2].join('').upcase}"
# If one word use first four letters
return "#{name_array[0].chars.to_a[0..3].join('').upcase}"
end
end
@@ -40,31 +45,24 @@ class School < ActiveRecord::Base
end
def calculate_score_raw
newScore = total_points_scored_by_wrestlers - total_points_deducted
newScore = total_points_scored_by_wrestlers - total_points_deducted
self.score = newScore
self.save
end
def total_points_scored_by_wrestlers
points = 0
points = 0.0
self.wrestlers.each do |w|
if w.extra != true
points = points + w.total_team_points
end
points = points + w.total_team_points
end
points
end
def total_points_deducted
points = 0
points = 0.0
deductedPoints.each do |d|
points = points + d.points
end
self.wrestlers.each do |w|
w.deductedPoints.each do |d|
points = points + d.points
end
end
points
end
end

View File

@@ -14,7 +14,7 @@ class Teampointadjust < ActiveRecord::Base
#Team score needs calculated
if self.wrestler_id != nil
#In case this affects pool order
AdvanceWrestler.new(self.wrestler).advance
AdvanceWrestler.new(self.wrestler,self.wrestler.last_match).advance
self.wrestler.school.calculate_score
elsif self.school_id != nil
self.school.calculate_score

View File

@@ -16,9 +16,26 @@ class Tournament < ActiveRecord::Base
Delayed::Job.where(job_owner_id: self.id)
end
def self.search(search)
where("date LIKE ? or name LIKE ?", "%#{search}%", "%#{search}%")
end
def self.search_date_name(pattern)
if pattern.blank? # blank? covers both nil and empty string
all
else
search_functions = []
search_variables = []
search_terms = pattern.split(' ').map{|word| "%#{word.downcase}%"}
search_terms.each do |word|
search_functions << '(LOWER(name) LIKE ? or LOWER(date) LIKE ?)'
# add twice for both ?'s in the function above
search_variables << word
search_variables << word
end
like_patterns = search_functions.join(' and ')
# puts "where(#{like_patterns})"
# puts *search_variables
# example: (LOWER(name LIKE ? or LOWER(date) LIKE ?) and (LOWER(name) LIKE ? or LOWER(date) LIKE ?), %test%, %test%, %2016%, %2016%
where("#{like_patterns}", *search_variables)
end
end
def days_until_start
time = (Date.today - self.date).to_i
@@ -29,17 +46,27 @@ class Tournament < ActiveRecord::Base
end
def tournament_types
["Pool to bracket","Modified 16 Man Double Elimination","Double Elimination 1-6"]
["Pool to bracket","Modified 16 Man Double Elimination 1-6","Modified 16 Man Double Elimination 1-8","Regular Double Elimination 1-6","Regular Double Elimination 1-8"]
end
def create_pre_defined_weights(value)
def number_of_placers
if self.tournament_type.include? "1-8"
return 8
elsif self.tournament_type.include? "1-6"
return 6
end
end
def calculate_all_team_scores
self.schools.each do |school|
school.calculate_score
end
end
def create_pre_defined_weights(weight_classes)
weights.destroy_all
if value == 'hs'
Weight::HS_WEIGHT_CLASSES.each do |w|
weights.create(max: w)
end
else
raise "Unspecified behavior"
weight_classes.each do |w|
weights.create(max: w)
end
end
@@ -101,22 +128,24 @@ class Tournament < ActiveRecord::Base
end
end
def pool_to_bracket_weights_with_too_many_wrestlers
if self.tournament_type == "Pool to bracket"
weightsWithTooManyWrestlers = weights.select{|w| w.wrestlers.size > 24}
if weightsWithTooManyWrestlers.size < 1
return nil
else
return weightsWithTooManyWrestlers
end
else
nil
end
def pool_to_bracket_number_of_wrestlers
error_string = ""
if self.tournament_type.include? "Pool to bracket"
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 24}
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 2}
weights_with_too_many_wrestlers.each do |weight|
error_string = error_string + " The weight class #{weight.max} has more than 24 wrestlers."
end
weight_with_too_few_wrestlers.each do |weight|
error_string = error_string + " The weight class #{weight.max} has less than 2 wrestlers."
end
end
return error_string
end
def modified_sixteen_man_number_of_wrestlers
error_string = ""
if self.tournament_type == "Modified 16 Man Double Elimination"
if self.tournament_type.include? "Modified 16 Man Double Elimination"
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 16}
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 12}
weights_with_too_many_wrestlers.each do |weight|
@@ -131,7 +160,7 @@ class Tournament < ActiveRecord::Base
def double_elim_number_of_wrestlers
error_string = ""
if self.tournament_type == "Double Elimination 1-6"
if self.tournament_type == "Double Elimination 1-6" or self.tournament_type == "Double Elimination 1-8"
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 16}
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 4}
weights_with_too_many_wrestlers.each do |weight|
@@ -145,17 +174,14 @@ class Tournament < ActiveRecord::Base
end
def match_generation_error
errorString = "There is a tournament error."
error_string = "There is a tournament error."
modified_sixteen_man_error = modified_sixteen_man_number_of_wrestlers
double_elim_error = double_elim_number_of_wrestlers
if pool_to_bracket_weights_with_too_many_wrestlers != nil
errorString = errorString + " The following weights have too many wrestlers "
pool_to_bracket_weights_with_too_many_wrestlers.each do |w|
errorString = errorString + "#{w.max} "
end
return errorString
elsif modified_sixteen_man_error.length > 0
return errorString + modified_sixteen_man_error
double_elim_error = double_elim_number_of_wrestlers
pool_to_bracket_error = pool_to_bracket_number_of_wrestlers
if pool_to_bracket_error.length > 0
return error_string + pool_to_bracket_error
elsif modified_sixteen_man_error.length > 0
return error_string + modified_sixteen_man_error
elsif double_elim_error.length > 0
return error_string + double_elim_error
else

View File

@@ -7,7 +7,12 @@ class Weight < ActiveRecord::Base
validates :max, presence: true
HS_WEIGHT_CLASSES = [106,113,120,126,132,138,145,152,160,170,182,195,220,285]
# passed via layouts/_tournament-navbar.html.erb
# tournaments controller does a .split(',') on this string and creates an array via commas
# tournament model runs the code via method create_pre_defined_weights
HS_WEIGHT_CLASSES = "106,113,120,126,132,138,144,150,157,165,175,190,215,285"
HS_GIRLS_WEIGHT_CLASSES = "100,105,110,115,120,125,130,135,140,145,155,170,190,235"
MS_WEIGHT_CLASSES = "80,86,92,98,104,110,116,122,128,134,142,150,160,172,205,245"
before_destroy do
self.tournament.destroy_all_matches

View File

@@ -85,7 +85,7 @@ class Wrestler < ActiveRecord::Base
def unfinished_matches
all_matches.select{|m| m.finished != 1}.sort_by{|m| m.bout_number}
end
def result_by_bout(bout)
bout_match = all_matches.select{|m| m.bout_number == bout and m.finished == 1}
if bout_match.size == 0
@@ -99,6 +99,19 @@ class Wrestler < ActiveRecord::Base
end
end
def result_by_id(id)
bout_match = all_matches.select{|m| m.id == id and m.finished == 1}
if bout_match.size == 0
return ""
end
if bout_match.first.winner_id == self.id
return "W #{bout_match.first.bracket_score_string}"
end
if bout_match.first.winner_id != self.id
return "L #{bout_match.first.bracket_score_string}"
end
end
def match_against(opponent)
all_matches.select{|m| m.w1 == opponent.id or m.w2 == opponent.id}
end
@@ -119,6 +132,15 @@ class Wrestler < ActiveRecord::Base
return round_match.bout_number
end
end
def match_id_by_round(round)
round_match = all_matches.select{|m| m.round == round}.first
if round_match.blank?
return "BYE"
else
return round_match.id
end
end
def all_matches
return matches.select{|m| m.w1 == self.id or m.w2 == self.id}
@@ -145,6 +167,14 @@ class Wrestler < ActiveRecord::Base
matches_won.select{|m| (m.bracket_position == "Conso Semis" or m.bracket_position == "Conso" or m.bracket_position == "Conso Quarter") and m.win_type != "BYE"}
end
def championship_byes
matches_won.select{|m| (m.bracket_position == "Quarter" or m.bracket_position == "Semis" or m.bracket_position == "Bracket") and m.win_type == "BYE"}
end
def consolation_byes
matches_won.select{|m| (m.bracket_position == "Conso Semis" or m.bracket_position == "Conso" or m.bracket_position == "Conso Quarter") and m.win_type == "BYE"}
end
def finished_matches
all_matches.select{|m| m.finished == 1}
end
@@ -196,9 +226,28 @@ class Wrestler < ActiveRecord::Base
points_scored
end
def decision_points_scored_pool
points_scored = 0
decision_wins.select{|m| m.bracket_position == "Pool"}.each do |m|
score_of_match = m.score.delete(" ")
score_one = score_of_match.partition('-').first.to_i
score_two = score_of_match.partition('-').last.to_i
if score_one > score_two
points_scored = points_scored + score_one
elsif score_two > score_one
points_scored = points_scored + score_two
end
end
points_scored
end
def fastest_pin
pin_wins.sort_by{|m| m.pin_time_in_seconds}.first
end
def fastest_pin_pool
pin_wins.select{|m| m.bracket_position == "Pool"}.sort_by{|m| m.pin_time_in_seconds}.first
end
def pin_time
time = 0
@@ -208,6 +257,14 @@ class Wrestler < ActiveRecord::Base
time
end
def pin_time_pool
time = 0
pin_wins.select{|m| m.bracket_position == "Pool"}.each do | m |
time = time + m.pin_time_in_seconds
end
time
end
def season_win_percentage
win = self.season_win.to_f
loss = self.season_loss.to_f

View File

@@ -14,9 +14,11 @@ class AdvanceWrestler
end
def advance_raw
if @last_match && @last_match.finished?
pool_to_bracket_advancement if @tournament.tournament_type == "Pool to bracket"
DoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type == "Modified 16 Man Double Elimination" or
@tournament.tournament_type == "Double Elimination 1-6"
DoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or
@tournament.tournament_type.include? "Regular Double Elimination"
end
end
def pool_to_bracket_advancement

View File

@@ -28,17 +28,18 @@ class DoubleEliminationAdvance
update_new_match(new_match, get_wrestler_number)
elsif @last_match.bracket_position == "Conso Semis"
# if its a regular double elim
if Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","Conso Semis",@next_match_position_number.ceil,@wrestler.weight_id).first.loser1_name != nil
if @wrestler.tournament.tournament_type.include? "Regular Double Elimination"
new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","3/4",@next_match_position_number.ceil,@wrestler.weight_id).first
update_new_match(new_match, get_wrestler_number)
# if it's a special bracket where consolations wrestler for 5th
else
elsif @wrestler.tournament.tournament_type.include? "Modified 16 Man Double Elimination"
new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","5/6",@next_match_position_number.ceil,@wrestler.weight_id).first
update_new_match(new_match, get_wrestler_number)
end
elsif @last_match.bracket_position == "Conso Quarter"
next_round_matches = Match.where("weight_id = ? and bracket_position = ?", @wrestler.weight_id, "Conso Semis").sort_by{|m| m.round}
this_round_matches = Match.where("weight_id = ? and round = ? and bracket_position = ?", @wrestler.weight_id, @last_match.round, "Conso Quarter")
# bracket position is different depending on if a semi loser is dropping or if there are 4 conso quarter matches
if next_round_matches.size == this_round_matches.size
# if a semi loser is dropping down
new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","Conso Semis",@last_match.bracket_position_number,@wrestler.weight_id).first

View File

@@ -5,17 +5,26 @@ class PoolOrder
def getPoolOrder
setOriginalPoints
while checkForTieBreakers == true
breakTie
while checkForTies(@wrestlers) == true
getWrestlersOrderByPoolAdvancePoints.each do |wrestler|
wrestlers_with_same_points = getWrestlersOrderByPoolAdvancePoints.select{|w| w.poolAdvancePoints == wrestler.poolAdvancePoints}
if wrestlers_with_same_points.size > 1
breakTie(wrestlers_with_same_points)
end
end
end
@wrestlers.sort_by{|w| w.poolAdvancePoints}.reverse.each_with_index do |wrestler, index|
placement = index + 1
wrestler.pool_placement = placement
wrestler.save
getWrestlersOrderByPoolAdvancePoints.each_with_index do |wrestler, index|
placement = index + 1
wrestler.pool_placement = placement
wrestler.save
end
@wrestlers.sort_by{|w| w.poolAdvancePoints}.reverse!
end
def getWrestlersOrderByPoolAdvancePoints
@wrestlers.sort_by{|w| w.poolAdvancePoints}.reverse
end
def setOriginalPoints
@wrestlers.each do |w|
w.pool_placement_tiebreaker = nil
@@ -24,16 +33,16 @@ class PoolOrder
end
end
def checkForTieBreakers
if wrestlersWithSamePoints.size > 1
def checkForTies(wrestlers_to_check)
if wrestlersWithSamePoints(wrestlers_to_check).size > 1
return true
end
return false
end
def wrestlersWithSamePoints
@wrestlers.each do |w|
wrestlersWithSamePointsLocal = @wrestlers.select{|wr| wr.poolAdvancePoints == w.poolAdvancePoints}
def wrestlersWithSamePoints(wrestlers_to_check)
wrestlers_to_check.each do |w|
wrestlersWithSamePointsLocal = wrestlers_to_check.select{|wr| wr.poolAdvancePoints == w.poolAdvancePoints}
if wrestlersWithSamePointsLocal.size > 1
return wrestlersWithSamePointsLocal
end
@@ -41,34 +50,34 @@ class PoolOrder
return []
end
def ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize)
if wrestlersWithSamePoints.size == originalTieSize
def ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize,wrestlers_to_check)
if wrestlersWithSamePoints(wrestlers_to_check).size == originalTieSize
return true
else
return false
end
end
def breakTie
originalTieSize = wrestlersWithSamePoints.size
deductedPoints(originalTieSize) if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize)
def breakTie(wrestlers_with_same_points)
originalTieSize = wrestlers_with_same_points.size
deductedPoints(originalTieSize,wrestlers_with_same_points) if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize,wrestlers_with_same_points)
if originalTieSize == 2
headToHead if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize)
headToHead(wrestlers_with_same_points) if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize,wrestlers_with_same_points)
end
teamPoints if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize)
mostFalls if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize)
mostTechs if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize)
mostMajors if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize)
mostDecisionPointsScored if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize)
fastest_pins if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize)
coinFlip if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize)
teamPoints(wrestlers_with_same_points) if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize,wrestlers_with_same_points)
mostFalls(wrestlers_with_same_points) if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize,wrestlers_with_same_points)
mostTechs(wrestlers_with_same_points) if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize,wrestlers_with_same_points)
mostMajors(wrestlers_with_same_points) if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize,wrestlers_with_same_points)
mostDecisionPointsScored(wrestlers_with_same_points) if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize,wrestlers_with_same_points)
fastest_pins(wrestlers_with_same_points) if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize,wrestlers_with_same_points)
coinFlip(wrestlers_with_same_points) if ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize,wrestlers_with_same_points)
end
def headToHead
wrestlersWithSamePoints.each do |wr|
otherWrestler = wrestlersWithSamePoints.select{|w| w.id != wr.id}.first
if otherWrestler and wr.match_against(otherWrestler).first.winner_id == wr.id
def headToHead(wrestlers_with_same_points)
wrestlers_with_same_points.each do |wr|
otherWrestler = wrestlers_with_same_points.select{|w| w.id != wr.id}.first
if otherWrestler and wr.match_against(otherWrestler).select{|match| match.bracket_position == "Pool"}.first.winner_id == wr.id
addPointsToWrestlersAhead(wr)
wr.pool_placement_tiebreaker = "Head to Head"
addPoints(wr)
@@ -77,6 +86,8 @@ class PoolOrder
end
def addPoints(wrestler)
# addPointsToWrestlersAhead(wrestler)
# Cannot go here because if team points are the same the first with points added will stay ahead
wrestler.poolAdvancePoints = wrestler.poolAdvancePoints + 1
end
@@ -87,13 +98,13 @@ class PoolOrder
end
end
def deductedPoints(originalTieSize)
def deductedPoints(originalTieSize,wrestlers_with_same_points)
pointsArray = []
wrestlersWithSamePoints.each do |w|
wrestlers_with_same_points.each do |w|
pointsArray << w.total_points_deducted
end
leastPoints = pointsArray.min
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.total_points_deducted == leastPoints}
wrestlersWithLeastDeductedPoints = wrestlers_with_same_points.select{|w| w.total_points_deducted == leastPoints}
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
if wrestlersWithLeastDeductedPoints.size != originalTieSize
wrestlersWithLeastDeductedPoints.each do |wr|
@@ -103,38 +114,37 @@ class PoolOrder
end
end
def mostDecisionPointsScored
def mostDecisionPointsScored(wrestlers_with_same_points)
pointsArray = []
wrestlersWithSamePoints.each do |w|
pointsArray << w.decision_points_scored
wrestlers_with_same_points.each do |w|
pointsArray << w.decision_points_scored_pool
end
mostPoints = pointsArray.max
wrestlersWithMostPoints = wrestlersWithSamePoints.select{|w| w.decision_points_scored == mostPoints}
wrestlersWithMostPoints = wrestlers_with_same_points.select{|w| w.decision_points_scored_pool == mostPoints}
addPointsToWrestlersAhead(wrestlersWithMostPoints.first)
wrestlersWithMostPoints.each do |wr|
wr.pool_placement_tiebreaker = "Points Scored"
wr.pool_placement_tiebreaker = "Decision Points Scored"
addPoints(wr)
end
secondPoints = pointsArray.sort[-2]
wrestlersWithSecondMostPoints = wrestlersWithSamePoints.select{|w| w.decision_points_scored == secondPoints}
wrestlersWithSecondMostPoints = wrestlers_with_same_points.select{|w| w.decision_points_scored_pool == secondPoints}
addPointsToWrestlersAhead(wrestlersWithSecondMostPoints.first)
wrestlersWithSecondMostPoints.each do |wr|
wr.pool_placement_tiebreaker = "Points Scored"
wr.pool_placement_tiebreaker = "Decision Points Scored"
addPoints(wr)
end
end
def fastest_pins
def fastest_pins(wrestlers_with_same_points)
wrestlersWithSamePointsWithPins = []
wrestlersWithSamePoints.each do |wr|
if wr.pin_wins.size > 0
wrestlers_with_same_points.each do |wr|
if wr.pin_wins.select{|m| m.bracket_position == "Pool"}.size > 0
wrestlersWithSamePointsWithPins << wr
end
end
if wrestlersWithSamePointsWithPins.size > 0
fastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.fastest_pin.pin_time_in_seconds}.first.fastest_pin
secondFastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.fastest_pin.pin_time_in_seconds}.second.fastest_pin
wrestlersWithFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastest_pin.pin_time_in_seconds == fastest.pin_time_in_seconds}
fastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.pin_time_pool}.first.pin_time_pool
wrestlersWithFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.pin_time_pool == fastest}
addPointsToWrestlersAhead(wrestlersWithFastestPin.first)
wrestlersWithFastestPin.each do |wr|
wr.pool_placement_tiebreaker = "Pin Time"
@@ -143,13 +153,13 @@ class PoolOrder
end
end
def teamPoints
pointsArray = []
wrestlersWithSamePoints.each do |w|
pointsArray << w.total_pool_points_for_pool_order
def teamPoints(wrestlers_with_same_points)
teamPointsArray = []
wrestlers_with_same_points.each do |w|
teamPointsArray << w.total_pool_points_for_pool_order
end
mostPoints = pointsArray.max
wrestlersSortedByTeamPoints = wrestlersWithSamePoints.select{|w| w.total_pool_points_for_pool_order == mostPoints}
mostPoints = teamPointsArray.max
wrestlersSortedByTeamPoints = wrestlers_with_same_points.select{|w| w.total_pool_points_for_pool_order == mostPoints}
addPointsToWrestlersAhead(wrestlersSortedByTeamPoints.first)
wrestlersSortedByTeamPoints.each do |wr|
wr.pool_placement_tiebreaker = "Team Points"
@@ -157,50 +167,56 @@ class PoolOrder
end
end
def mostFalls
pointsArray = []
wrestlersWithSamePoints.each do |w|
pointsArray << w.pin_wins.size
def mostFalls(wrestlers_with_same_points)
mostPins = []
wrestlers_with_same_points.each do |w|
mostPins << w.pin_wins.select{|m| m.bracket_position == "Pool"}.size
end
pinsMax = mostPins.max
wrestlersSortedByFallWins = wrestlers_with_same_points.select{|w| w.pin_wins.select{|m| m.bracket_position == "Pool"}.size == pinsMax}
if pinsMax > 0
addPointsToWrestlersAhead(wrestlersSortedByFallWins.first)
wrestlersSortedByFallWins.each do |wr|
wr.pool_placement_tiebreaker = "Most Pins"
addPoints(wr)
end
end
mostPoints = pointsArray.max
wrestlersSortedByFallWins = wrestlersWithSamePoints.select{|w| w.pin_wins.size == mostPoints}
addPointsToWrestlersAhead(wrestlersSortedByFallWins.first)
wrestlersSortedByFallWins.each do |wr|
wr.pool_placement_tiebreaker = "Most Pins"
addPoints(wr)
end
end
def mostTechs
pointsArray = []
wrestlersWithSamePoints.each do |w|
pointsArray << w.tech_wins.size
def mostTechs(wrestlers_with_same_points)
techsArray = []
wrestlers_with_same_points.each do |w|
techsArray << w.tech_wins.select{|m| m.bracket_position == "Pool"}.size
end
mostTechsWins = techsArray.max
wrestlersSortedByTechWins = wrestlers_with_same_points.select{|w| w.tech_wins.select{|m| m.bracket_position == "Pool"}.size == mostTechsWins}
if mostTechsWins > 0
addPointsToWrestlersAhead(wrestlersSortedByTechWins.first)
wrestlersSortedByTechWins.each do |wr|
wr.pool_placement_tiebreaker = "Most Techs"
addPoints(wr)
end
end
mostPoints = pointsArray.max
wrestlersSortedByTechWins = wrestlersWithSamePoints.select{|w| w.tech_wins.size == mostPoints}
addPointsToWrestlersAhead(wrestlersSortedByTechWins.first)
wrestlersSortedByTechWins.each do |wr|
wr.pool_placement_tiebreaker = "Most Techs"
addPoints(wr)
end
end
def mostMajors
pointsArray = []
wrestlersWithSamePoints.each do |w|
pointsArray << w.major_wins.size
def mostMajors(wrestlers_with_same_points)
majorsArray = []
wrestlers_with_same_points.each do |w|
majorsArray << w.major_wins.select{|m| m.bracket_position == "Pool"}.size
end
mostMajorWins = majorsArray.max
wrestlersSortedByMajorWins = wrestlers_with_same_points.select{|w| w.major_wins.select{|m| m.bracket_position == "Pool"}.size == mostMajorWins}
if mostMajorWins > 0
addPointsToWrestlersAhead(wrestlersSortedByMajorWins.first)
wrestlersSortedByMajorWins.each do |wr|
wr.pool_placement_tiebreaker = "Most Majors"
addPoints(wr)
end
end
mostPoints = pointsArray.max
wrestlersSortedByMajorWins = wrestlersWithSamePoints.select{|w| w.major_wins.size == mostPoints}
addPointsToWrestlersAhead(wrestlersSortedByMajorWins.first)
wrestlersSortedByMajorWins.each do |wr|
wr.pool_placement_tiebreaker = "Most Majors"
addPoints(wr)
end
end
def coinFlip
wrestler = wrestlersWithSamePoints.sample
def coinFlip(wrestlers_with_same_points)
wrestler = wrestlers_with_same_points.sample
wrestler.pool_placement_tiebreaker = "Coin Flip"
addPointsToWrestlersAhead(wrestler)
addPoints(wrestler)

View File

@@ -52,11 +52,13 @@ class EightManDoubleEliminationGenerateLoserNames
if match.w1 != nil
match.winner_id = match.w1
match.loser2_name = "BYE"
match.score = ""
match.save
match.advance_wrestlers
elsif match.w2 != nil
match.winner_id = match.w2
match.loser1_name = "BYE"
match.score = ""
match.save
match.advance_wrestlers
end

View File

@@ -33,12 +33,12 @@ class GenerateTournamentMatches
def generate_raw
standardStartingActions
PoolToBracketMatchGeneration.new(@tournament).generatePoolToBracketMatches if @tournament.tournament_type == "Pool to bracket"
ModifiedSixteenManMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type == "Modified 16 Man Double Elimination"
DoubleEliminationMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type == "Double Elimination 1-6"
ModifiedSixteenManMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
DoubleEliminationMatchGeneration.new(@tournament).generate_matches if @tournament.tournament_type.include? "Regular Double Elimination"
postMatchCreationActions
PoolToBracketMatchGeneration.new(@tournament).assignLoserNames if @tournament.tournament_type == "Pool to bracket"
ModifiedSixteenManGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type == "Modified 16 Man Double Elimination"
DoubleEliminationGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type == "Double Elimination 1-6"
ModifiedSixteenManGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
DoubleEliminationGenerateLoserNames.new(@tournament).assign_loser_names if @tournament.tournament_type.include? "Regular Double Elimination"
end
def standardStartingActions

View File

@@ -10,6 +10,7 @@ class ModifiedSixteenManGenerateLoserNames
conso_round_2(matches_by_weight)
conso_round_3(matches_by_weight)
third_fourth(matches_by_weight)
seventh_eighth(matches_by_weight)
save_matches(matches_by_weight)
matches_by_weight = @tournament.matches.where(weight_id: w.id).reload
advance_bye_matches_championship(matches_by_weight)
@@ -55,21 +56,29 @@ class ModifiedSixteenManGenerateLoserNames
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Semis"}.second.bout_number}"
end
end
def seventh_eighth(matches)
matches.select{|m| m.bracket_position == "7/8"}.sort_by{|m| m.bracket_position_number}.each do |match|
match.loser1_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Semis"}.first.bout_number}"
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Semis"}.second.bout_number}"
end
end
def advance_bye_matches_championship(matches)
matches.select{|m| m.round == 1 and m.bracket_position == "Bracket"}.sort_by{|m| m.bracket_position_number}.each do |match|
if match.w1 == nil or match.w2 == nil
puts match.bout_number
match.finished = 1
match.win_type = "BYE"
if match.w1 != nil
match.winner_id = match.w1
match.loser2_name = "BYE"
match.score = ""
match.save
match.advance_wrestlers
elsif match.w2 != nil
match.winner_id = match.w2
match.loser1_name = "BYE"
match.score = ""
match.save
match.advance_wrestlers
end

View File

@@ -1,6 +1,7 @@
class ModifiedSixteenManMatchGeneration
def initialize( tournament )
@tournament = tournament
@number_of_placers = @tournament.number_of_placers
end
def generate_matches
@@ -57,6 +58,9 @@ class ModifiedSixteenManMatchGeneration
create_matchup(nil,nil,"1/2",1,5,weight)
create_matchup(nil,nil,"3/4",1,5,weight)
create_matchup(nil,nil,"5/6",1,5,weight)
if @number_of_placers >= 8
create_matchup(nil,nil,"7/8",1,5,weight)
end
end
def wrestler_with_seed(seed,weight)

View File

@@ -10,6 +10,7 @@ class SixteenManDoubleEliminationGenerateLoserNames
conso_round_3(matches_by_weight)
conso_round_5(matches_by_weight)
fifth_sixth(matches_by_weight)
seventh_eighth(matches_by_weight)
save_matches(matches_by_weight)
matches_by_weight = @weight.matches.reload
advance_bye_matches_championship(matches_by_weight)
@@ -64,6 +65,13 @@ class SixteenManDoubleEliminationGenerateLoserNames
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Semis"}.second.bout_number}"
end
end
def seventh_eighth(matches)
matches.select{|m| m.bracket_position == "7/8"}.sort_by{|m| m.bracket_position_number}.each do |match|
match.loser1_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Quarter"}.first.bout_number}"
match.loser2_name = "Loser of #{matches.select{|m| m.bracket_position == "Conso Quarter"}.second.bout_number}"
end
end
def advance_bye_matches_championship(matches)
matches.select{|m| m.round == 1 and m.bracket_position == "Bracket"}.sort_by{|m| m.bracket_position_number}.each do |match|
@@ -73,11 +81,13 @@ class SixteenManDoubleEliminationGenerateLoserNames
if match.w1 != nil
match.winner_id = match.w1
match.loser2_name = "BYE"
match.score = ""
match.save
match.advance_wrestlers
elsif match.w2 != nil
match.winner_id = match.w2
match.loser1_name = "BYE"
match.score = ""
match.save
match.advance_wrestlers
end

View File

@@ -1,6 +1,7 @@
class SixteenManDoubleEliminationMatchGeneration
def initialize( weight )
@weight = weight
@number_of_placers = @weight.tournament.number_of_placers
end
def generate_matches_for_weight
@@ -57,6 +58,9 @@ class SixteenManDoubleEliminationMatchGeneration
create_matchup(nil,nil,"1/2",1,6,weight)
create_matchup(nil,nil,"3/4",1,6,weight)
create_matchup(nil,nil,"5/6",1,6,weight)
if @number_of_placers >= 8
create_matchup(nil,nil,"7/8",1,6,weight)
end
end
def wrestler_with_seed(seed,weight)

View File

@@ -82,6 +82,7 @@ class WrestlingdevImporter
def parse_wrestlers(wrestlers)
wrestlers.each do | wrestler |
puts wrestler
wrestler_array = wrestler.split(@attribute_separator,-1)
new_wrestler = Wrestler.new
new_wrestler.name = wrestler_array[0]
@@ -107,6 +108,7 @@ class WrestlingdevImporter
def parse_matches(matches)
matches.each do | match |
puts match
@tournament.reload
@tournament.mats.reload
match_array = match.split(@attribute_separator,-1)
@@ -141,12 +143,14 @@ class WrestlingdevImporter
new_match.loser1_name = match_array[13]
new_match.loser2_name = match_array[14]
# new_match.mat_id = mat_id if match_array[15].size > 0
new_match.overtime_type = match_array[16]
new_match.save
end
end
def parse_schools(schools)
schools.each do | school |
puts school
school_array = school.split(@attribute_separator,-1)
new_school = School.new
new_school.tournament_id = @tournament.id
@@ -158,6 +162,7 @@ class WrestlingdevImporter
def parse_weights(weights)
weights.each do | weight |
puts weight
weight_array = weight.split(@attribute_separator,-1)
new_weight = Weight.new
new_weight.tournament_id = @tournament.id
@@ -168,6 +173,7 @@ class WrestlingdevImporter
def parse_mats(mats)
mats.each do | mat |
puts mat
mat_array = mat.split(@attribute_separator,-1)
new_mat = Mat.new
new_mat.tournament_id = @tournament.id

View File

@@ -26,8 +26,8 @@ class CalculateWrestlerTeamScore
def placement_points
return PoolBracketPlacementPoints.new(@wrestler).calcPoints if @tournament.tournament_type == "Pool to bracket"
return ModifiedSixteenManPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type == "Modified 16 Man Double Elimination"
return DoubleEliminationPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type == "Double Elimination 1-6"
return ModifiedSixteenManPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
return DoubleEliminationPlacementPoints.new(@wrestler).calc_points if @tournament.tournament_type.include? "Regular Double Elimination"
return 0
end
@@ -44,15 +44,34 @@ class CalculateWrestlerTeamScore
end
def byePoints
points = 0
if @tournament.tournament_type == "Pool to bracket"
if @wrestler.pool_wins.size >= 1 and @wrestler.has_a_pool_bye == true
2
else
0
points += 2
end
else
0
end
if @tournament.tournament_type.include? "Regular Double Elimination"
if @wrestler.championship_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "1/2" and m.win_type != "BYE"}.size > 0
# if they have a win in the championship round or if they got a bye all the way to finals and won the finals
points += @wrestler.championship_byes.size * 2
end
if @wrestler.consolation_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "3/4" and m.win_type != "BYE"}.size > 0
# if they have a win in the consolation round or if they got a bye all the way to 3rd/4th match and won
points += @wrestler.consolation_byes.size * 1
end
end
if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
if @wrestler.championship_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "1/2" and m.win_type != "BYE"}.size > 0
# if they have a win in the championship round or if they got a bye all the way to finals and won the finals
points += @wrestler.championship_byes.size * 2
end
if @wrestler.consolation_advancement_wins.size > 0 or @wrestler.matches_won.select{|m| m.bracket_position == "5/6" and m.win_type != "BYE"}.size > 0
# if they have a win in the consolation round or if they got a bye all the way to 5th/6th match and won
# since the consolation bracket goes to 5/6 in a modified tournament
points += @wrestler.consolation_byes.size * 1
end
end
return points
end
def bonusWinPoints

View File

@@ -1,9 +1,7 @@
class DoubleEliminationPlacementPoints
def initialize(wrestler)
@wrestler = wrestler
if wrestler.tournament.tournament_type == "Double Elimination 1-6"
@number_of_placers = 6
end
@number_of_placers = @wrestler.tournament.number_of_placers
end
def calc_points
@@ -22,7 +20,7 @@ class DoubleEliminationPlacementPoints
elsif won_bracket_position_size("7/8") > 0
return PlacementPoints.new(@number_of_placers).seventhPlace
elsif bracket_position_size("Conso Quarter") > 0 and @number_of_placers >= 8
return PlacementPoints.new(@number_of_placers).eigthPlace
return PlacementPoints.new(@number_of_placers).eighthPlace
else
return 0
end

View File

@@ -1,7 +1,8 @@
class ModifiedSixteenManPlacementPoints
def initialize(wrestler)
@wrestler = wrestler
@number_of_placers = 6
@wrestler = wrestler
@number_of_placers = @wrestler.tournament.number_of_placers
end
def calc_points
@@ -17,6 +18,10 @@ class ModifiedSixteenManPlacementPoints
return PlacementPoints.new(@number_of_placers).fifthPlace
elsif bracket_position_size("5/6") > 0
return PlacementPoints.new(@number_of_placers).sixthPlace
elsif won_bracket_position_size("7/8") > 0
return PlacementPoints.new(@number_of_placers).seventhPlace
elsif bracket_position_size("Conso Semis") > 0 and @number_of_placers >= 8
return PlacementPoints.new(@number_of_placers).eighthPlace
else
return 0
end

View File

@@ -3,13 +3,13 @@ json.cache! ["api_tournament", @tournament] do
json.content(@tournament)
json.(@tournament, :id, :name, :address, :director, :director_email, :tournament_type, :created_at, :updated_at, :user_id)
json.schools @tournament.schools do |school|
json.schools @schools do |school|
json.id school.id
json.name school.name
json.score school.score
end
json.weights @tournament.weights do |weight|
json.weights @weights do |weight|
json.id weight.id
json.max weight.max
json.bracket_size weight.bracket_size
@@ -26,7 +26,7 @@ json.cache! ["api_tournament", @tournament] do
end
end
json.mats @tournament.mats do |mat|
json.mats @mats do |mat|
json.name mat.name
json.unfinished_matches mat.unfinished_matches do |match|
json.bout_number match.bout_number
@@ -35,7 +35,7 @@ json.cache! ["api_tournament", @tournament] do
end
end
json.unassignedMatches @tournament.matches.select{|m| m.mat_id == nil}.sort_by{|m| m.bout_number}[0...9] do |match|
json.unassignedMatches @matches.select{|m| m.mat_id == nil}.sort_by{|m| m.bout_number}[0...9] do |match|
json.bout_number match.bout_number
json.w1_name match.w1_name
json.w2_name match.w2_name
@@ -43,7 +43,7 @@ json.cache! ["api_tournament", @tournament] do
json.round match.round
end
json.matches @tournament.matches do |match|
json.matches @matches do |match|
json.bout_number match.bout_number
json.w1_name match.w1_name
json.w2_name match.w2_name

View File

@@ -1,9 +1 @@
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-64366913-2', 'auto');
ga('send', 'pageview');
</script>
<script defer data-api="/plausible/api/event" data-domain="wrestlingdev.com" src="/plausible/js/script.js"></script>

View File

@@ -1 +0,0 @@
<script src="//instant.page/5.1.0" type="module" integrity="sha384-by67kQnR+pyfy8yWP4kPO12fHKRLHZPfEsiSXR8u2IKcTdxD805MGUXBzVPnkLHw"></script>

View File

@@ -5,21 +5,22 @@
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><%= link_to " Tournament Home" , "/tournaments/#{@tournament.id}", class: "fas fa-home" %></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="fas fa-poll-h"> Tournament Results/Brackets</i>
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><strong>Results</strong></li>
<li><%= link_to "Team Scores" , "/tournaments/#{@tournament.id}/team_scores" %></li>
<li><strong>Brackets</strong></li>
<% @tournament.weights.sort_by{|weight| weight.max }.each do |weight| %>
<li><%= link_to "#{weight.max}" , "/tournaments/#{@tournament.id}/brackets/#{weight.id}" %></li>
<% end %>
<li><%= link_to "All Brackets (Printable)", "/tournaments/#{@tournament.id}/all_brackets?print=true", target: :_blank %></li>
</ul>
</li>
<li><%= link_to " Bout Board" , "/tournaments/#{@tournament.id}/up_matches", class: "fas fa-list-alt" %></li>
<% if can? :read, @tournament %>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="fas fa-poll-h"> Tournament Results/Brackets</i>
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><strong>Results</strong></li>
<li><%= link_to "Team Scores" , "/tournaments/#{@tournament.id}/team_scores" %></li>
<li><strong>Brackets</strong></li>
<% @tournament.weights.sort_by{|weight| weight.max }.each do |weight| %>
<li><%= link_to "#{weight.max}" , "/tournaments/#{@tournament.id}/brackets/#{weight.id}" %></li>
<% end %>
<li><%= link_to "All Brackets (Printable)", "/tournaments/#{@tournament.id}/all_brackets?print=true", target: :_blank %></li>
</ul>
</li>
<li><%= link_to " Bout Board" , "/tournaments/#{@tournament.id}/up_matches", class: "fas fa-list-alt" %></li>
<% end %>
<% if can? :manage, @tournament %>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#director"><i class="fas fa-tools"> Tournament Director Links</i>
@@ -42,9 +43,11 @@
<% end %>
<% end %>
<li><strong>Time Savers</strong></li>
<li><%= link_to "Create High School Weights (106-285)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=hs",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
<li><%= link_to "Create Boys High School Weights (106-285)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::HS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
<li><%= link_to "Create Girls High School Weights (101-235)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::HS_GIRLS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
<li><%= link_to "Create Boys Middle School Weights (80-245)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::MS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
<li><strong>Tournament Actions</strong></li>
<li><%= link_to "Calculate Team Scores" , "/tournaments/#{@tournament.id}/calculate_team_scores", method: :post %></li>
<li><%= link_to "Calculate Team Scores" , "/tournaments/#{@tournament.id}/calculate_team_scores", :method => :put %></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 "Export Data" , "/tournaments/#{@tournament.id}/export?print=true", target: :_blank %></li>
</ul>

View File

@@ -10,41 +10,25 @@
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<% end %>
<div class="afs_ads">&nbsp;</div>
<div class="alert alert-danger alert-dismissible" id="blocked_message" style="display: none;"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
<p>We've detected that you have an ad blocker enabled! Please consider disabling it for <strong>wrestlingdev.com</strong>. This site is free for users and supported by ads. Ad blockers also block performance monitoring that help us with user experience.</p>
</div>
<script>
(function() {
var message = "We've detected that you have an ad blocker enabled! Please consider disabling it for wrestlingdev.com. This site is free for users and supported by ads. Ad blockers also block performance monitoring that help us with user experience.";
// Define a function for showing the message.
// Set a timeout of 2 seconds to give adblocker
// a chance to do its thing
var tryMessage = function() {
setTimeout(function() {
if(!document.getElementsByClassName) return;
var ads = document.getElementsByClassName('afs_ads'),
ad = ads[ads.length - 1];
if(!ad
|| ad.innerHTML.length == 0
|| ad.clientHeight === 0) {
//alert(message);
document.getElementById("blocked_message").style.display = 'block';
//window.location.href = '[URL of the donate page. Remove the two slashes at the start of thsi line to enable.]';
} else {
ad.style.display = 'none';
}
}, 2000);
}
/* Attach a listener for page load ... then show the message */
if(window.addEventListener) {
window.addEventListener('load', tryMessage, false);
} else {
window.attachEvent('onload', tryMessage); //IE
}
})();
let fakeAd = document.createElement("div");
fakeAd.className = "textads banner-ads banner_ads ad-unit ad-zone ad-space adsbox"
fakeAd.style.height = "1px"
document.body.appendChild(fakeAd)
let x_width = fakeAd.offsetHeight;
let msg = document.getElementById("msg")
if(x_width){
console.log("No AdBlocker Detected")
}else{
console.log("AdBlocker detected")
document.getElementById("blocked_message").style.display = 'block';
}
</script>

View File

@@ -22,7 +22,6 @@
<%= csrf_meta_tags %>
<%= render 'layouts/cdn' %>
<%= render 'layouts/shim' %>
<%= render 'layouts/instantpage' %>
</head>
<body style="padding-top: 70px;">
<div class="container">
@@ -41,6 +40,9 @@
<% if notice %>
<p id="notice" class="alert alert-success alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><%= notice %></p>
<% end %>
<% if alert %>
<p id="alert" class="alert alert-danger alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><%= alert %></p>
<% end %>
<div id="view"><%= yield %></div>
</div>
</div>

View File

@@ -2,12 +2,12 @@
<%= form_for(@match) do |f| %>
<div class="field">
<%= f.label "Wrestler 1" %><br>
<%= f.collection_select :w1, @wrestlers, :id, :name %>
<%= f.collection_select :w1, @wrestlers, :id, :name, include_blank: true %>
</div>
<div>vs</div>
<div class="field">
<%= f.label "Wrestler 2" %><br>
<%= f.collection_select :w2, @wrestlers, :id, :name %>
<%= f.collection_select :w2, @wrestlers, :id, :name, include_blank: true %>
</div>
<div class="actions">
<%= f.submit onclick: "return confirm('Is the name of the winner ' + document.getElementById('match_winner_id').options[document.getElementById('match_winner_id').selectedIndex].text + '?')", :class=>"btn btn-success" %>

View File

@@ -15,55 +15,57 @@
<table class="table">
<thead>
<tr>
<th>Name: <%= @w1.name %> <select id="w1-color" onchange="changeW1Color(this)">
<th>Name: <%= @wrestler1_name %> <select id="w1-color" onchange="changeW1Color(this)">
<option value="green">Green</option>
<option value="red">Red</option>
</select>
<br>School: <%= @w1.school.name %>
<br>Last Match: <%= if @w1.last_match != nil then time_ago_in_words(@w1.last_match.updated_at) else "N/A" end%></th>
<th>Name: <%= @w2.name %> <select id="w2-color" onchange="changeW2Color(this)">
<br>School: <%= @wrestler1_school_name %>
<br>Last Match: <%= @wrestler1_last_match ? time_ago_in_words(@wrestler1_last_match.updated_at) : "N/A" %></th>
<th>Name: <%= @wrestler2_name %> <select id="w2-color" onchange="changeW2Color(this)">
<option value="red">Red</option>
<option value="green">Green</option>
</select>
<br>School: <%= @w2.school.name %>
<br>Last Match: <%= if @w2.last_match != nil then time_ago_in_words(@w2.last_match.updated_at) else "N/A" end%></th>
<br>School: <%= @wrestler2_school_name %>
<br>Last Match: <%= @wrestler2_last_match ? time_ago_in_words(@wrestler2_last_match.updated_at) : "N/A" %></th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @w1.name %> Stats: <br><%= f.text_area :w1_stat, cols: "30", rows: "10" %></td>
<td><%= @w2.name %> Stats: <br><%= f.text_area :w2_stat, cols: "30", rows: "10" %></td>
<td><%= @wrestler1_name %> Stats: <br><%= f.text_area :w1_stat, cols: "30", rows: "10" %></td>
<td><%= @wrestler2_name %> Stats: <br><%= f.text_area :w2_stat, cols: "30", rows: "10" %></td>
</tr>
<tr>
<td><%= @w1.name %> Scoring <br><button id="w1-takedown" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'T2')">T2</button>
<td><%= @wrestler1_name %> Scoring <br><button id="w1-takedown" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'T2')">T2</button>
<button id="w1-escape" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'E1')">E1</button>
<button id="w1-reversal" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'R2')">R2</button>
<button id="w1-nf2" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'N2')">N2 </button>
<button id="w1-nf3" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'N3')">N3</button>
<button id="w1-nf4" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'N4')">N4</button>
<button id="w1-penalty" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'P1')">P1</button></td>
<td><%= @w2.name %> Scoring <br><button id="w2-takedown" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'T2')">T2</button>
<button id="w1-penalty" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'P1')">P1</button>
<button id="w1-penalty2" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'P2')">P2</button></td>
<td><%= @wrestler2_name %> Scoring <br><button id="w2-takedown" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'T2')">T2</button>
<button id="w2-escape" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'E1')">E1</button>
<button id="w2-reversal" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'R2')">R2</button>
<button id="w2-nf2" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'N2')">N2</button>
<button id="w2-nf3" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'N3')">N3</button>
<button id="w2-nf4" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'N4')">N4</button>
<button id="w2-penalty" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'P1')">P1</button></td>
<button id="w2-penalty" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'P1')">P1</button>
<button id="w2-penalty2" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'P2')">P2</button></td>
</tr>
<tr>
<td><%= @w1.name %> Choice <br><button id="w1-top" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Top|')">Chose Top</button>
<td><%= @wrestler1_name %> Choice <br><button id="w1-top" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Top|')">Chose Top</button>
<button id="w1-bottom" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Bottom|')">Chose Bottom</button>
<button id="w1-nuetral" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Nuetral|')">Chose Nuetral</button>
<button id="w1-neutral" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Neutral|')">Chose Neutral</button>
<button id="w1-defer" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Deferred|')">Deferred</button></td>
<td><%= @w2.name %> Choice <br><button id="w2-top" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Top|')">Chose Top</button>
<td><%= @wrestler2_name %> Choice <br><button id="w2-top" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Top|')">Chose Top</button>
<button id="w2-bottom" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Bottom|')">Chose Bottom</button>
<button id="w2-nuetral" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Nuetral|')">Chose Nuetral</button>
<button id="w2-neutral" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Neutral|')">Chose Neutral</button>
<button id="w2-defer" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Deferred|')">Deferred</button></td>
</tr>
<tr>
<td><%= @w1.name %> Warnings <br><button id="w1-stalling" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'S')">Stalling</button>
<td><%= @wrestler1_name %> Warnings <br><button id="w1-stalling" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'S')">Stalling</button>
<button id="w1-caution" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'C')">Caution</button></td>
<td><%= @w2.name %> Warnings <br><button id="w2-stalling" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'S')">Stalling</button>
<td><%= @wrestler2_name %> Warnings <br><button id="w2-stalling" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'S')">Stalling</button>
<button id="w2-caution" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'C')">Caution</button></td>
</tr>
<tr>
@@ -82,12 +84,17 @@
</div>
<br>
<div class="field">
<%= f.label "Winner" %> Please choose the winner<br>
<%= f.collection_select :winner_id, @wrestlers, :id, :name %>
<%= f.label "Overtime Type" %> Leave blank if not overtime. For High School the 1st overtime is SV-1, second overtime is TB-1, third overtime is UTB.<br>
<%= f.select(:overtime_type, Match::OVERTIME_TYPES) %>
</div>
<br>
<div class="field">
<%= f.label "Final Score" %> Also put pin time here if applicable. If default or forfeit, leave blank. Example: 7-2, 17-2, or 2:34<br>
<%= f.label "Winner" %> Please choose the winner<br>
<%= f.collection_select :winner_id, @wrestlers, :id, :name, include_blank: true %>
</div>
<br>
<div class="field">
<%= f.label "Final Score" %> For decision, major, or tech fall put the score here in Number-Number format. If pin, put the accumulated pin time in the format MM:SS. If default, injury default, dq, bye, or forfeit, leave blank. Examples: 7-2, 17-2, 0:30, or 2:34.<br>
<%= f.text_field :score %>
</div>
<br>
@@ -104,6 +111,9 @@
<% end %>
<script>
// Localstorage
// https://stackoverflow.com/questions/12806198/how-do-i-save-data-on-localstorage-in-ruby-on-rails-3-2-8
//Create person object
function Person(stats){
this.stats=stats;
@@ -112,11 +122,28 @@
//Declare variables
var w1=new Person("");
var w2=new Person("");
updatejsvalues();
// Get variables
var tournament=<%= @match.tournament.id %>;
var bout=<%= @match.bout_number %>;
// if localstorage tournament id and bout number are the same and the html stat values are blank
// if the html stat values are not blank we want to honor what came from the db
if (localStorage.getItem('wrestler1') && localStorage.tournament == tournament && localStorage.bout == bout && document.getElementById("match_w1_stat").value == "" && document.getElementById("match_w2_stat").value == "") {
w1.stats = localStorage.getItem('wrestler1');
w2.stats = localStorage.getItem('wrestler2');
updatehtmlvalues();
} else {
updateLocalStorage();
}
function updatehtmlvalues(){
document.getElementById("match_w1_stat").value = w1.stats;
document.getElementById("match_w2_stat").value = w2.stats;
}
function updatejsvalues(){
w1.stats=document.getElementById("match_w1_stat").value;
w2.stats=document.getElementById("match_w2_stat").value;
@@ -130,6 +157,14 @@
updatejsvalues();
wrestler.stats = wrestler.stats + text + " ";
updatehtmlvalues();
updateLocalStorage();
}
function updateLocalStorage(){
localStorage.setItem("wrestler1",w1.stats);
localStorage.setItem("wrestler2",w2.stats);
localStorage.setItem("bout", bout);
localStorage.setItem("tournament", tournament);
}
//For Changing button colors
@@ -172,13 +207,14 @@
redColor("w1-escape");
redColor("w1-reversal");
redColor("w1-penalty");
redColor("w1-penalty2");
redColor("w1-nf4");
redColor("w1-nf3");
redColor("w1-nf2");
redColor("w1-top");
redColor("w1-bottom");
redColor("w1-nuetral");
redColor("w1-differ");
redColor("w1-neutral");
redColor("w1-defer");
redColor("w1-stalling");
redColor("w1-caution");
}
@@ -188,13 +224,14 @@
greenColor("w1-escape");
greenColor("w1-reversal");
greenColor("w1-penalty");
greenColor("w1-penalty2");
greenColor("w1-nf4");
greenColor("w1-nf3");
greenColor("w1-nf2");
greenColor("w1-top");
greenColor("w1-bottom");
greenColor("w1-nuetral");
greenColor("w1-differ");
greenColor("w1-neutral");
greenColor("w1-defer");
greenColor("w1-stalling");
greenColor("w1-caution");
}
@@ -204,13 +241,14 @@
redColor("w2-escape");
redColor("w2-reversal");
redColor("w2-penalty");
redColor("w2-penalty2");
redColor("w2-nf4");
redColor("w2-nf3");
redColor("w2-nf2");
redColor("w2-top");
redColor("w2-bottom");
redColor("w2-nuetral");
redColor("w2-differ");
redColor("w2-neutral");
redColor("w2-defer");
redColor("w2-stalling");
redColor("w2-caution");
}
@@ -220,13 +258,14 @@
greenColor("w2-escape");
greenColor("w2-reversal");
greenColor("w2-penalty");
greenColor("w2-penalty2");
greenColor("w2-nf4");
greenColor("w2-nf3");
greenColor("w2-nf2");
greenColor("w2-top");
greenColor("w2-bottom");
greenColor("w2-nuetral");
greenColor("w2-differ");
greenColor("w2-neutral");
greenColor("w2-defer");
greenColor("w2-stalling");
greenColor("w2-caution");
}

View File

@@ -1,2 +1,2 @@
<h1><%= @w1.name %> VS. <%= @w2.name %></h1>
<h1><%= @wrestler1_name %> VS. <%= @wrestler2_name %></h1>
<%= render 'matchstats' %>

View File

@@ -1,228 +0,0 @@
<%= form_for(@match) do |f| %>
<% if @match.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:</h2>
<ul>
<% @match.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<h4>Bout: <%= @match.bout_number %> </h4><h4>Round: <%= @match.round %></h4><h4>Weight: <%= @match.weight_max %> lbs</h4>
<table class="table">
<thead>
<tr>
<th><%= @w1.name %> - <%= @w1.school.name %> <select id="w1-color" onchange="changeW1Color(this)">
<option value="green">Green</option>
<option value="red">Red</option>
</select><br>Last Match: <%= if @w1.last_match != nil then time_ago_in_words(@w1.last_match.updated_at) end%></th>
<th><%= @w2.name %> - <%= @w2.school.name %> <select id="w2-color" onchange="changeW2Color(this)">
<option value="red">Red</option>
<option value="green">Green</option>
</select><br>Last Match: <%= if @w2.last_match != nil then time_ago_in_words(@w2.last_match.updated_at) end%></th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @w1.name %> Stats: <br><%= f.text_area :w1_stat, cols: "30", rows: "10" %></td>
<td><%= @w2.name %> Stats: <br><%= f.text_area :w2_stat, cols: "30", rows: "10" %></td>
</tr>
<tr>
<td><%= @w1.name %> Scoring <br><button id="w1-takedown" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'T2')">T2</button>
<button id="w1-escape" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'E1')">E1</button>
<button id="w1-reversal" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'R2')">R2</button>
<button id="w1-nf2" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'N2')">N2 </button>
<button id="w1-nf3" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'N3')">N3</button>
<button id="w1-nf4" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'N4')">N4</button>
<button id="w1-penalty" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'P1')">P1</button></td>
<td><%= @w2.name %> Scoring <br><button id="w2-takedown" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'T2')">T2</button>
<button id="w2-escape" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'E1')">E1</button>
<button id="w2-reversal" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'R2')">R2</button>
<button id="w2-nf2" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'N2')">N2</button>
<button id="w2-nf3" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'N3')">N3</button>
<button id="w2-nf4" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'N4')">N4</button>
<button id="w2-penalty" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'P1')">P1</button></td>
</tr>
<tr>
<td><%= @w1.name %> Choice <br><button id="w1-top" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Top|')">Chose Top</button>
<button id="w1-bottom" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Bottom|')">Chose Bottom</button>
<button id="w1-nuetral" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Chose Nuetral|')">Chose Nuetral</button>
<button id="w1-differ" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'|Differed|')">Differed</button></td>
<td><%= @w2.name %> Choice <br><button id="w2-top" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Top|')">Chose Top</button>
<button id="w2-bottom" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Bottom|')">Chose Bottom</button>
<button id="w2-nuetral" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Chose Nuetral|')">Chose Nuetral</button>
<button id="w2-differ" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'|Differed|')">Differed</button></td>
</tr>
<tr>
<td><%= @w1.name %> Warnings <br><button id="w1-stalling" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'S')">Stalling</button>
<button id="w1-caution" type="button" class="btn btn-success btn-sm" onclick="updateStats(w1,'C')">Caution</button></td>
<td><%= @w2.name %> Warnings <br><button id="w2-stalling" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'S')">Stalling</button>
<button id="w2-caution" type="button" class="btn btn-danger btn-sm" onclick="updateStats(w2,'C')">Caution</button></td>
</tr>
<tr>
<td>Match Options <br><button type="button" class="btn btn-primary btn-sm" onclick="updateStats(w2,'|End Period|');updateStats(w1,'|End Period|')">End Period</button></td>
</tr>
</tbody>
</table>
<br>
<br>
<br>
<h4>Match Results</h4>
<br>
<div class="field">
<%= f.label "Win Type" %><br>
<%= f.select(:win_type, Match::WIN_TYPES) %>
</div>
<br>
<div class="field">
<%= f.label "Winner" %> Please choose the winner<br>
<%= f.collection_select :winner_id, @wrestlers, :id, :name %>
</div>
<br>
<div class="field">
<%= f.label "Final Score" %> Also put pin time here if applicable. If default or forfeit, leave blank. Example: 7-2, 17-2, or 2:34<br>
<%= f.text_field :score %>
</div>
<br>
<%= f.hidden_field :finished, :value => 1 %>
<%= f.hidden_field :round, :value => @match.round %>
<br>
<div class="actions">
<%= f.submit onclick: "return confirm('Is the name of the winner ' + document.getElementById('match_winner_id').options[document.getElementById('match_winner_id').selectedIndex].text + '?')", :class=>"btn btn-success" %>
</div>
<% end %>
<script>
//Create person object
function Person(stats){
this.stats=stats;
}
//Declare variables
var w1=new Person("");
var w2=new Person("");
function updatehtmlvalues(){
document.getElementById("match_w1_stat").value = w1.stats;
document.getElementById("match_w2_stat").value = w2.stats;
}
function updatejsvalues(){
w1.stats=document.getElementById("match_w1_stat").value;
w2.stats=document.getElementById("match_w2_stat").value;
}
function takedown(wrestler){
updateStats(wrestler,"T2")
}
function updateStats(wrestler,text){
updatejsvalues();
wrestler.stats = wrestler.stats + text + " ";
updatehtmlvalues();
}
//For Changing button colors
function changeW1Color(color){
if (color.value == "red") {
w1Red();
w2Green();
document.getElementById("w2-color").value = "green";
}
if (color.value == "green") {
w1Green();
w2Red();
document.getElementById("w2-color").value = "red";
}
}
function changeW2Color(color){
if (color.value == "red") {
w2Red();
w1Green();
document.getElementById("w1-color").value = "green";
}
if (color.value == "green") {
w2Green();
w1Red();
document.getElementById("w1-color").value = "red";
}
}
function redColor(id){
document.getElementById(id).className = "btn btn-danger btn-sm";
}
function greenColor(id){
document.getElementById(id).className = "btn btn-success btn-sm";
}
function w1Red(){
redColor("w1-takedown");
redColor("w1-escape");
redColor("w1-reversal");
redColor("w1-penalty");
redColor("w1-nf4");
redColor("w1-nf3");
redColor("w1-nf2");
redColor("w1-top");
redColor("w1-bottom");
redColor("w1-nuetral");
redColor("w1-differ");
redColor("w1-stalling");
redColor("w1-caution");
}
function w1Green(){
greenColor("w1-takedown");
greenColor("w1-escape");
greenColor("w1-reversal");
greenColor("w1-penalty");
greenColor("w1-nf4");
greenColor("w1-nf3");
greenColor("w1-nf2");
greenColor("w1-top");
greenColor("w1-bottom");
greenColor("w1-nuetral");
greenColor("w1-differ");
greenColor("w1-stalling");
greenColor("w1-caution");
}
function w2Red(){
redColor("w2-takedown");
redColor("w2-escape");
redColor("w2-reversal");
redColor("w2-penalty");
redColor("w2-nf4");
redColor("w2-nf3");
redColor("w2-nf2");
redColor("w2-top");
redColor("w2-bottom");
redColor("w2-nuetral");
redColor("w2-differ");
redColor("w2-stalling");
redColor("w2-caution");
}
function w2Green(){
greenColor("w2-takedown");
greenColor("w2-escape");
greenColor("w2-reversal");
greenColor("w2-penalty");
greenColor("w2-nf4");
greenColor("w2-nf3");
greenColor("w2-nf2");
greenColor("w2-top");
greenColor("w2-bottom");
greenColor("w2-nuetral");
greenColor("w2-differ");
greenColor("w2-stalling");
greenColor("w2-caution");
}
</script>

View File

@@ -38,6 +38,7 @@
<tbody>
<% @wrestlers.sort_by{|w| w.weight.max}.each do |wrestler| %>
<% cache ["#{wrestler.id}_school_show", @school] do %>
<tr>
<td><%= link_to "#{wrestler.name}", wrestler %></td>
<td><%= wrestler.weight.max %></td>
@@ -48,7 +49,9 @@
<td><%= wrestler.total_team_points - wrestler.total_points_deducted %></td>
<td><% if wrestler.extra? == true %>
Yes
<% end %></td>
<% end %>
</td>
<% end %>
<td><%= wrestler.next_match_bout_number %> <%= wrestler.next_match_mat_name %></td>
<% if can? :manage, wrestler.school %>
<td>

View File

@@ -30,17 +30,17 @@
<tbody>
<tr>
<td><%= m.w1_bracket_name %></td>
<td><%= m.w1_bracket_name.html_safe %></td>
<td><%= m.w1_stat %></td>
</tr>
<tr>
<td><%= m.w2_bracket_name %></td>
<td><%= m.w2_bracket_name.html_safe %></td>
<td><%= m.w2_stat %></td>
</tr>
</tbody>
</table>
</td>
<td><%= wrestler.result_by_bout(m.bout_number) %>
<td><%= wrestler.result_by_id(m.id) %>
</tr>
<% end %>
<% end %>

View File

@@ -8,7 +8,8 @@
<li>Tournament Types
<ul>
<li>Pool to bracket (adhears to 5 match per day rule)</li>
<li>Double elimination 16 man and 8 man</li>
<li>Regular Double Elimination 16 man and 8 man. Options for placing 1st-6th or 1st-8th.</li>
<li>Modified 16 Man Double Elimination 1-6. Options for placing 1st-6th or 1st-8th. Adhears to 5 match per day rule.</li>
</ul>
</li>
<li>Team point calculation</li>
@@ -35,7 +36,7 @@
<li>Most wins by tech fall</li>
<li>Most wins by major</li>
<li>Most points scored in decisions</li>
<li>Quickest pin</li>
<li>Total pin time accumulation</li>
<li>Coin flip</li>
</ul>
<p>If three wrestlers are tied, they will be put through this sequence until two wrestlers are left. Once two wrestlers are left, the pool runner up will be decided by head to head.</p>
@@ -52,17 +53,31 @@
<p>See placement points below (based on the largest bracket of the tournament)</p>
<h4>Pool Types</h4>
<ul>
<li>Single pool round robin - 2-5 wrestlers, place 1-4.</li>
<li>Two Pools of 4 (3 matches each) to a semi final bracket - 6-8 wrestlers, place 1-4.</li>
<li>Single pool round robin - 2-6 wrestlers, place 1-4.</li>
<li>Two Pools of 4 (3 matches each) to a semi final bracket - 7-8 wrestlers, place 1-4.</li>
<li>Two Pools of 5 (4 matches each) to a championship and 3rd/4th match - 8-10 wrestlers, place 1-4.</li>
<li>Four pools of 3 (2 matches each) to a quarter final bracket - 9-12 wrestlers, place 1-8.</li>
<li>Four pools of 4 (3 matches each) to a semi final bracket - 13-16 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>
<br>
<h3>Double Elimination Information</h3>
<h3>Regular Double Elimination Information</h3>
<p>Right now, double elimination brackets only support 8 and 16 man brackets (4-16 wrestlers). Cross bracketing will happen every other round. 16 man in quarter finals, 8 man in semi finals.</p>
<h4>Double elimination scoring</h4>
<p>Regular Double Elimination 1-6 places 1st through 6th. Regular Double Elimination 1-8 places 1st through 8th.</p>
<h4>Regular Double Elimination scoring</h4>
<ul>
<li>Championship win: 2pt</li>
<li>Consolation win: 1pt</li>
<li>Win by major: 1pt extra</li>
<li>Win by tech: 1.5pt extra</li>
<li>Win by fall, default, dq, etc: 2pt extra</li>
<li>BYE points: 2pts if you have a bye in the championship bracket and win the next match. 1pt if you have a bye in the consolation bracket and win the next match.</li>
</ul>
<br>
<h3>Modified 16 Man Double Elimination Information</h3>
<p>Adhears to 5 match per day rule. Allows a 16 man bracket without anyone wrestling more than 5 matches. Semi Final losers wrestle for 3rd. Anyone who loses before the Semi Finals wrestle a consolation bracket for 5th.</p>
<p>Modified 16 Man Double Elimination 1-6 places 1st through 6th. Modified 16 Man Double Elimination 1-8 places 1st through 8th.</p>
<h4>Modified 16 Man Double Elimination scoring (same as Regular Double Elimination)</h4>
<ul>
<li>Championship win: 2pt</li>
<li>Consolation win: 1pt</li>
@@ -127,7 +142,7 @@
<br>
<h3>Future Plans</h3>
<br>
<p>Future development plans to support 32 and 64 man double elimination as well as modified (5 per day match rule) 16 and 32 man double elimination brackets are underway.</p>
<p>Future development plans to support 32 and 64 man regulard double elimination, modified (5 per day match rule) 32 man double elimination, and true second double elimination brackets are underway.</p>
<br>
<h3>Contact</h3>
<br>

View File

@@ -78,7 +78,7 @@ table.smallText tr td { font-size: 10px; }
}
</style>
<table class='smallText'>
<h5><strong><%= @tournament.name %> - <%= @weight.max %> lbs Bracket</strong></h5>
<h5><strong><%= @tournament.name %> - <%= @weight.max %> Bracket</strong></h5>
<tr>
<% if @tournament.tournament_type == "Pool to bracket" %>
<td valign="top" style="padding: 10px;">
@@ -106,11 +106,11 @@ table.smallText tr td { font-size: 10px; }
<%= render 'fourPoolSemiBracket' %>
<% end %>
</td>
<% elsif @tournament.tournament_type == "Modified 16 Man Double Elimination" %>
<% elsif @tournament.tournament_type.include? "Modified 16 Man Double Elimination" %>
<td valign="top" style="padding: 10px;">
<%= render 'modified_sixteen_man_double_elimination_bracket' %>
</td>
<% elsif @tournament.tournament_type == "Double Elimination 1-6" %>
<% elsif @tournament.tournament_type.include? "Regular Double Elimination" %>
<td valign="top" style="padding: 10px;">
<%= render 'double_elimination_bracket' %>
</td>

View File

@@ -35,9 +35,23 @@
<%= f.label :tournament_type %><br>
<%= f.select :tournament_type, @tournament.tournament_types %>
</div>
<br>
<div>
See About page for information on tournament types: <%= link_to "About", "/static_pages/about" %>
<p>For double elimination tournaments, 1-6 places 1st through 6th and 1-8 places 1st through 8th.</p>
</div>
<%= f.hidden_field :user_id, :value => current_user.id %>
<br>
<br>
<div class="field">
<%= f.label "Information is public" %> <br />
<%= f.check_box :is_public %> <br />
</div>
<div>
Leave this unchecked until you're ready to share seeding info, brackets, and lineups.
</div>
<br>
<br>
<div class="actions">
<%= f.submit 'Submit',:class=>"btn btn-success" %>
</div>

View File

@@ -1,131 +1,48 @@
<h4>Championship Bracket</h4>
<main id="bracket">
<ul class="round round-1">
<% @matches.select{|m|m.bracket_position == "Bracket" and m.round == 1}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_bracket_name_round_one %> <span></span></li>
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_bracket_name_round_one %><span></span></li>
<li>&nbsp;</li>
<% end %>
</ul>
<ul class="round round-2">
<% @matches.select{|m|m.bracket_position == "Quarter"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li></li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</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 %>&nbsp;</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 %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li></li>
</ul>
<ul class="round round-5">
<li></li>
<li class="bracket-winner"> <%= match.bracket_winner_name %> <span></span></li>
1st
<li></li>
</ul>
<% end %>
</main>
<div class="bracket">
<!--Round 1-->
<% @round_matches = @matches.select{|m|m.bracket_position == "Bracket" and m.round == 1} %>
<%= render 'bracket_round' %>
<!--Round 2-->
<% @round_matches = @matches.select{|m|m.bracket_position == "Quarter"} %>
<%= render 'bracket_round' %>
<!--Round 3-->
<% @round_matches = @matches.select{|m|m.bracket_position == "Semis"} %>
<%= render 'bracket_round' %>
<!--Round 4-->
<% @final_match = @matches.select{|m|m.bracket_position == "1/2"} %>
<% @winner_place = "1st" %>
<%= render 'bracket_final' %>
</div>
<h4>3/4 place match</h4>
<main id="bracket">
<ul class="round round-3">
<% @matches.select{|m|m.bracket_position == "3/4"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
</ul>
<ul class="round round-4">
<li>&nbsp;</li>
<li class="bracket-winner"> <%= match.bracket_winner_name %> <span></span></li>
3rd
<li>&nbsp;</li>
</ul>
<% end %>
</main>
<div class="bracket">
<!--Round 1-->
<% @final_match = @matches.select{|m|m.bracket_position == "3/4"} %>
<% @winner_place = "3rd" %>
<%= render 'bracket_final' %>
</div>
<h4>Consolation Bracket</h4>
<main id="bracket">
<ul class="round round-1">
<% @matches.select{|m|m.bracket_position == "Conso" and m.round == 2}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li>&nbsp;</li>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<% end %>
</ul>
<ul class="round round-2">
<% @matches.select{|m|m.bracket_position == "Conso Quarter"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
<% end %>
</ul>
<ul class="round round-3">
<% @matches.select{|m|m.bracket_position == "Conso Semis"}.sort_by{|m| m.bracket_position_number}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
<% end %>
</ul>
<ul class="round round-4">
<% @matches.select{|m|m.bracket_position == "5/6"}.each do |match| %>
<li>&nbsp;</li>
<li class="game game-top "><%= match.w1_bracket_name %> <span></span></li>
<li class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_bracket_name %><span></span></li>
<li>&nbsp;</li>
</ul>
<ul class="round round-5">
<li>&nbsp;</li>
<li class="bracket-winner"> <%= match.bracket_winner_name %> <span></span></li>
5th
<li>&nbsp;</li>
</ul>
<% end %>
</main>
<div class="bracket">
<!--Round 1-->
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso" and m.round == 2} %>
<%= render 'bracket_round' %>
<!--Round 2-->
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso Quarter"} %>
<%= render 'bracket_round' %>
<!--Round 3-->
<% @round_matches = @matches.select{|m|m.bracket_position == "Conso Semis"} %>
<%= render 'bracket_round' %>
<!--Round 4-->
<% @final_match = @matches.select{|m|m.bracket_position == "5/6"} %>
<% @winner_place = "5th" %>
<%= render 'bracket_final' %>
</div>
<% if @tournament.number_of_placers >= 8 %>
<h4>7/8 place match</h4>
<div class="bracket">
<!--Round 1-->
<% @final_match = @matches.select{|m|m.bracket_position == "7/8"} %>
<% @winner_place = "7th" %>
<%= render 'bracket_final' %>
</div>
<% end %>

View File

@@ -22,7 +22,7 @@
<% @round = 1 %>
<% until @matches.select{|m| m.round == @round}.blank? %>
<% if @round <= @pools %>
<td><%= w.bout_by_round(@round) %><br><%= w.result_by_bout(w.bout_by_round(@round)) %></td>
<td><%= w.bout_by_round(@round) %><br><%= w.result_by_id(w.match_id_by_round(@round)) %></td>
<% end %>
<% @round = @round + 1 %>
<% end %>

View File

@@ -39,4 +39,13 @@
<% @final_match = @matches.select{|m|m.bracket_position == "5/6"} %>
<% @winner_place = "5th" %>
<%= render 'bracket_final' %>
</div>
</div>
<% if @tournament.number_of_placers >= 8 %>
<h4>7/8 place match</h4>
<div class="bracket">
<!--Round 1-->
<% @final_match = @matches.select{|m|m.bracket_position == "7/8"} %>
<% @winner_place = "7th" %>
<%= render 'bracket_final' %>
</div>
<% end %>

View File

@@ -15,8 +15,8 @@
<% cache ["#{@tournament.id}_all_brackets", @tournament] do %>
<div id="exportable" >
<%= render :file => 'tournaments/team_scores' %>
<% @tournament.weights.sort_by{|w| w.max}.each do |weight| %>
<%= render :template => 'tournaments/team_scores' %>
<% @weights.sort_by{|w| w.max}.each do |weight| %>
<table class='pagebreak'>
<tr>
<% if @tournament.tournament_type == "Pool to bracket" %>
@@ -28,7 +28,7 @@
<% @weight = weight %>
<%= render 'bracket_partial' %>
</td>
<% elsif @tournament.tournament_type == "Modified 16 Man Double Elimination" or @tournament.tournament_type == "Double Elimination 1-6" %>
<% elsif @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or @tournament.tournament_type.include? "Regular Double Elimination" %>
<td valign="top" style="padding: 10px;">
<!-- Need to define what the tournaments#bracket controller defines -->
<% @matches = weight.matches %>

View File

@@ -3,6 +3,6 @@
<% end %>
<% if @tournament.tournament_type == "Pool to bracket" %>
<%= render 'pool_bracket_director_actions' %>
<% elsif @tournament.tournament_type == "Modified 16 Man Double Elimination" or @tournament.tournament_type == "Double Elimination 1-6" %>
<% elsif @tournament.tournament_type.include? "Modified 16 Man Double Elimination" or @tournament.tournament_type.include? "Regular Double Elimination" %>
<%= render 'bracket_director_actions' %>
<% end %>

View File

@@ -1,11 +1,11 @@
<% if @users %>
<h1>Search results</h1> <%= form_tag(tournament_delegate_path, :method => "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: "Search users" %>
<%= submit_tag "Search" %>
<% end %>
<p>Search by email address</p>
<p>Search by email address to delegate tournament permissions</p>
</br>
</br>
<% if @user %>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
@@ -14,32 +14,23 @@
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= user.email %></td>
<td><%= @user.email %></td>
<td>
<%= form_for TournamentDelegate.new, :url => url_for(:controller => 'tournaments', :action => 'delegate', :method => "post") do |f| %>
<%= f.hidden_field :user_id, :value => user.id %>
<%= f.hidden_field :user_id, :value => @user.id %>
<% if can? :manage, @tournament %>
<%= submit_tag "Give permissions", :class=>"btn btn-success"%>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% if @users_delegates %>
<h1>Delegated users</h1> <%= form_tag(tournament_delegate_path, :method => "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: "Search users" %>
<%= submit_tag "Search" %>
<% end %>
<p>Search by email address</p>
</br>
</br>
<h1>Delegated users</h1>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>

View File

@@ -19,4 +19,4 @@
<br>
--Wrestlers--<% @tournament.wrestlers.each do |wrestler| %><%= model_separator %><%= wrestler.name %><%= attribute_separator %><%= wrestler.school.name %><%= attribute_separator %><%= wrestler.weight.max %><%= attribute_separator %><%= wrestler.bracket_line %><%= attribute_separator %><%= wrestler.original_seed %><%= attribute_separator %><%= wrestler.season_win %><%= attribute_separator %><%= wrestler.season_loss %><%= attribute_separator %><%= wrestler.criteria %><%= attribute_separator %><%= wrestler.extra %><%= attribute_separator %><%= wrestler.offical_weight %><%= attribute_separator %><%= wrestler.pool %><%= attribute_separator %><%= wrestler.pool_placement %><%= attribute_separator %><%= wrestler.pool_placement_tiebreaker %><% end %>
<br>
--Matches--<% @tournament.matches.sort_by{|match| match.bout_number}.each do |match| %><%= model_separator %><%= Wrestler.where("id = ?",match.w1).first.name if match.w1 %><%= attribute_separator %><%= Wrestler.where("id = ?",match.w2).first.name if match.w2 %><%= attribute_separator %><%= match.w1_stat %><%= attribute_separator %><%= match.w2_stat %><%= attribute_separator %><%= Wrestler.where("id = ?",match.winner_id).first.name if match.winner_id %><%= attribute_separator %><%= match.win_type %><%= attribute_separator %><%= match.score %><%= attribute_separator %><%= match.round %><%= attribute_separator %><%= match.finished %><%= attribute_separator %><%= match.bout_number %><%= attribute_separator %><%= Weight.where("id = ?",match.weight_id).first.max if match.weight_id %><%= attribute_separator %><%= match.bracket_position %><%= attribute_separator %><%= match.bracket_position_number %><%= attribute_separator %><%= match.loser1_name %><%= attribute_separator %><%= match.loser2_name %><%= attribute_separator %><%= Mat.where("id = ?",match.mat_id).first.name if match.mat_id %><% end %>
--Matches--<% @tournament.matches.sort_by{|match| match.bout_number}.each do |match| %><%= model_separator %><%= Wrestler.where("id = ?",match.w1).first.name if match.w1 %><%= attribute_separator %><%= Wrestler.where("id = ?",match.w2).first.name if match.w2 %><%= attribute_separator %><%= match.w1_stat %><%= attribute_separator %><%= match.w2_stat %><%= attribute_separator %><%= Wrestler.where("id = ?",match.winner_id).first.name if match.winner_id %><%= attribute_separator %><%= match.win_type %><%= attribute_separator %><%= match.score %><%= attribute_separator %><%= match.round %><%= attribute_separator %><%= match.finished %><%= attribute_separator %><%= match.bout_number %><%= attribute_separator %><%= Weight.where("id = ?",match.weight_id).first.max if match.weight_id %><%= attribute_separator %><%= match.bracket_position %><%= attribute_separator %><%= match.bracket_position_number %><%= attribute_separator %><%= match.loser1_name %><%= attribute_separator %><%= match.loser2_name %><%= attribute_separator %><%= Mat.where("id = ?",match.mat_id).first.name if match.mat_id %><%= attribute_separator %><%= match.overtime_type %><% end %>

View File

@@ -24,13 +24,11 @@
<tr>
<td><%= match.bout_number %></td>
<td><%= match.bracket_position %></td>
<td><%= match.w1_bracket_name %> vs <%= match.w2_bracket_name %></td>
<td><%= match.w1_bracket_name.html_safe %> vs <%= match.w2_bracket_name.html_safe %></td>
<td><%= match.finished %></td>
<td><%= link_to 'Show', match, :class=>"btn btn-default btn-sm" %>
<%= link_to 'Edit Wrestlers', edit_match_path(match), :class=>"btn btn-primary btn-sm" %>
<% if match.w1 and match.w2 %>
<%= link_to 'Stat Match', "/matches/#{match.id}/stat", :class=>"btn btn-primary btn-sm" %>
<% end %>
</td>
</tr>
<% end %>

View File

@@ -1,11 +1,11 @@
<% if @users %>
<h1>Search results</h1> <%= form_tag(school_delegate_path, :method => "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: "Search users" %>
<%= submit_tag "Search" %>
<% end %>
<p>Search by email address</p>
<p>Search by email address to delegate a school to a user</p>
</br>
</br>
<% if @user %>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
@@ -15,34 +15,25 @@
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= user.email %></td>
<td><%= @user.email %></td>
<%= form_for SchoolDelegate.new, :url => url_for(:controller => 'tournaments', :action => 'school_delegate', :method => "post") do |f| %>
<td><%= f.collection_select :school_id, @tournament.schools, :id, :name %></td>
<td>
<%= f.hidden_field :user_id, :value => user.id %>
<%= f.hidden_field :user_id, :value => @user.id %>
<% if can? :manage, @tournament %>
<%= submit_tag "Give permissions", :class=>"btn btn-success"%>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% if @users_delegates %>
<h1>Delegated users schools</h1> <%= form_tag(school_delegate_path, :method => "get", id: "search-form") do %>
<%= text_field_tag :search, params[:search], placeholder: "Search users" %>
<%= submit_tag "Search" %>
<% end %>
<p>Search by email address</p>
</br>
</br>
<h1>Delegated users schools</h1>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>

View File

@@ -17,9 +17,18 @@
<strong>Tournament Type:</strong>
<%= @tournament.tournament_type %>
</p>
<p>
<strong>Tournament Date:</strong>
<%= @tournament.date %>
</p>
<p>
<strong>Tournament Information Is Public:</strong>
<%= @tournament.is_public %>
</p>
<% if can? :read, @tournament %><p>Brackets and team scores can be found in the white nav-bar up top.</p><% end %>
<br>
<h3>Schools</h3>
<p>Click to see lineups, bout numbers, score breakdowns, and stats. Brackets can be found in the white nav-bar up top.</p>
<p>Click to see lineups, bout numbers, score breakdowns, and stats.</p>
<br>
<table class="table table-hover table-condensed">
<thead>
@@ -31,15 +40,20 @@
<tbody>
<% @schools.each do |school| %>
<tr>
<td><%= link_to "#{school.name}", school %>
<td>
<% if can? :read, school %>
<%= link_to "#{school.name}", school %>
<% else %>
<%= "#{school.name}" %>
<% end %>
</td>
<td>
<% if can? :manage, school %>
<td><%= link_to '', edit_school_path(school), :class=>"fas fa-edit" %>
<%= link_to '', edit_school_path(school), :class=>"fas fa-edit" %>
<% if can? :manage, @tournament %>
<%= link_to '', school, method: :delete, data: { confirm: "Are you sure you want to delete #{school.name}?" }, :class=>"fas fa-trash-alt" %>
<% end %>
</td>
<% end %>
</td>
</tr>
<% end %>
@@ -60,7 +74,13 @@
<tbody>
<% @weights.each do |weight| %>
<tr>
<td><%= link_to "#{weight.max} lbs", weight %></td>
<td>
<% if can? :read, @tournament %>
<%= link_to "#{weight.max}", weight %>
<% else %>
<%= "#{weight.max}" %>
<% end %>
</td>
<td><%= weight.bracket_size %></td>
<% if can? :manage, @tournament %>
<td>
@@ -90,7 +110,8 @@
<% if can? :manage, @tournament %>
<td>
<%= link_to '', mat, method: :delete, data: { confirm: "Are you sure you want to delete Mat #{mat.name}?" }, :class=>"fas fa-trash-alt" %>
</td>
<%= link_to '', "/mats/#{mat.id}/assign_next_match", method: :post, :class=>"fas fa-solid fa-arrow-right" %>
</td>
<% end %>
</tr>
<% end %>

View File

@@ -28,10 +28,10 @@
<% @mats.each.map do |m| %>
<tr>
<td><%= m.name %></td>
<td><% if m.unfinished_matches.first %><strong><%=m.unfinished_matches.first.bout_number%></strong> - <%= m.unfinished_matches.first.weight_max %> lbs<br><%= m.unfinished_matches.first.w1_bracket_name %> vs. <%= m.unfinished_matches.first.w2_bracket_name %><% end %></td>
<td><% if m.unfinished_matches.second %><strong><%=m.unfinished_matches.second.bout_number%></strong> - <%= m.unfinished_matches.second.weight_max %> lbs<br><%= m.unfinished_matches.second.w1_bracket_name %> vs. <%= m.unfinished_matches.second.w2_bracket_name %><% end %></td>
<td><% if m.unfinished_matches.third %><strong><%=m.unfinished_matches.third.bout_number%></strong> - <%= m.unfinished_matches.third.weight_max %> lbs<br><%= m.unfinished_matches.third.w1_bracket_name %> vs. <%= m.unfinished_matches.third.w2_bracket_name %><% end %></td>
<td><% if m.unfinished_matches.fourth %><strong><%=m.unfinished_matches.fourth.bout_number%></strong> - <%= m.unfinished_matches.fourth.weight_max %> lbs<br><%= m.unfinished_matches.fourth.w1_bracket_name %> vs. <%= m.unfinished_matches.fourth.w2_bracket_name %><% end %></td>
<td><% if m.unfinished_matches.first %><strong><%=m.unfinished_matches.first.bout_number%></strong> - <%= m.unfinished_matches.first.weight_max %><br><%= m.unfinished_matches.first.w1_bracket_name %> vs. <%= m.unfinished_matches.first.w2_bracket_name %><% end %></td>
<td><% if m.unfinished_matches.second %><strong><%=m.unfinished_matches.second.bout_number%></strong> - <%= m.unfinished_matches.second.weight_max %><br><%= m.unfinished_matches.second.w1_bracket_name %> vs. <%= m.unfinished_matches.second.w2_bracket_name %><% end %></td>
<td><% if m.unfinished_matches.third %><strong><%=m.unfinished_matches.third.bout_number%></strong> - <%= m.unfinished_matches.third.weight_max %><br><%= m.unfinished_matches.third.w1_bracket_name %> vs. <%= m.unfinished_matches.third.w2_bracket_name %><% end %></td>
<td><% if m.unfinished_matches.fourth %><strong><%=m.unfinished_matches.fourth.bout_number%></strong> - <%= m.unfinished_matches.fourth.weight_max %><br><%= m.unfinished_matches.fourth.w1_bracket_name %> vs. <%= m.unfinished_matches.fourth.w2_bracket_name %><% end %></td>
</tr>
<% end %>
</tbody>
@@ -55,7 +55,7 @@
<tr>
<td>Round <%= m.round %></td>
<td><%= m.bout_number %></td>
<td><%= m.weight_max %> lbs</td>
<td><%= m.weight_max %></td>
<td><%= m.w1_bracket_name %> vs. <%= m.w2_bracket_name %></td>
</tr>
<% end %>

View File

@@ -13,7 +13,7 @@
<div class="field">
<%= f.label :max %><br>
<%= f.number_field :max %>
<%= f.number_field :max, step: :any %>
</div>
<% if @weight %>

View File

@@ -1 +1 @@
<%= @weight.max %> lbs Matches are being generated. This can take anywhere from 1-5 minutes to finish. It is recommended to delete all delegated school permissions to prevent lineup changes after the tournament has started.
<%= @weight.max %> Matches are being generated. This can take anywhere from 1-5 minutes to finish. It is recommended to delete all delegated school permissions to prevent lineup changes after the tournament has started.

View File

@@ -85,7 +85,7 @@
<td><%= m.bout_number %></td>
<td><%= m.bracket_position %></td>
<td><%= m.list_w1_stats %><br><%= m.list_w2_stats %></td>
<td><%= @wrestler.result_by_bout(m.bout_number) %>
<td><%= @wrestler.result_by_id(m.id) %>
</tr>
<% end %>
</tbody>

View File

@@ -11,5 +11,5 @@ if [ $# != 1 ]; then
fi
docker build -t $1 -f ${project_dir}/deploy/rails-dev-Dockerfile ${project_dir}
docker run -it -p 3000:3000 -v ${project_dir}:/rails $1 /bin/bash
sudo chown -R ${USER}:${USER} ${project_dir}
docker run --rm -it -p 3000:3000 -v ${project_dir}:/rails $1 /bin/bash
sudo chown -R ${USER_ID}:${USER_ID} ${project_dir}

View File

@@ -4,5 +4,5 @@ project_dir="$(dirname $( dirname $(readlink -f ${BASH_SOURCE[0]})))"
cd ${project_dir}
bundle exec rake db:migrate RAILS_ENV=test
CI=true brakeman
bundle exec hakiri gemfile:scan --force
bundle exec bundle-audit check --update
bundle exec rake test

View File

@@ -2,4 +2,4 @@
project_dir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/.."
docker build -f ${project_dir}/deploy/rails-prod-Dockerfile -t wrestlingdevtests ${project_dir}/.
docker run -it wrestlingdevtests bash /rails/bin/run-all-tests.sh
docker run --rm -it wrestlingdevtests bash /rails/bin/run-all-tests.sh

View File

@@ -33,8 +33,6 @@ module Wrestling
DeviseController.respond_to :html, :json
end
config.active_record.sqlite3.represent_boolean_as_integer = true
config.autoload_paths += %W(#{config.root}/app/services/tournament_services)
config.autoload_paths += %W(#{config.root}/app/services/wrestler_services)
config.autoload_paths += %W(#{config.root}/app/services/weight_services)

View File

@@ -1,6 +1,9 @@
Wrestling::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# allow all hostnames
config.hosts.clear
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
@@ -32,9 +35,5 @@ Wrestling::Application.configure do
#Bullet.alert = true
#Bullet.console = true
#Bullet.bullet_logger = true
end
end

View File

@@ -54,7 +54,7 @@ Wrestling::Application.configure do
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
config.cache_store = :dalli_store,
config.cache_store = :mem_cache_store,
(ENV["MEMCACHIER_SERVERS"] || "").split(","),
{:username => ENV["MEMCACHIER_USERNAME"],
:password => ENV["MEMCACHIER_PASSWORD"],

View File

@@ -0,0 +1,47 @@
if ENV['WRESTLINGDEV_INFLUXDB_HOST']
InfluxDB::Rails.configure do |config|
## The only setting you actually need to update is the name of the
## database within the InfluxDB server instance. Don't forget to
## create this database as well.
config.client.database = "#{ENV['WRESTLINGDEV_INFLUXDB_DATABASE']}"
config.client.hosts = ["#{ENV['WRESTLINGDEV_INFLUXDB_HOST']}"]
config.client.port = ENV['WRESTLINGDEV_INFLUXDB_PORT']
## If you've setup user authentication (and activated it in the server
## config), you need to configure the credentials here.
config.client.username = "#{ENV['WRESTLINGDEV_INFLUXDB_USERNAME']}"
config.client.password = "#{ENV['WRESTLINGDEV_INFLUXDB_PASSWORD']}"
## If your InfluxDB service requires an HTTPS connection then you can
## enable it here.
# config.client.use_ssl = true
## Various other client and connection options. These are used to create
## an `InfluxDB::Client` instance (i.e. `InfluxDB::Rails.client`).
##
## See docs for the influxdb gem for the canonical list of options:
## https://github.com/influxdata/influxdb-ruby#list-of-configuration-options
##
## These defaults for the influxdb-rails gem deviate from the default
## for the influxdb gem:
# config.client.async = true # false
# config.client.read_timeout = 30 # 300
# config.client.max_delay = 300 # 30
# config.client.time_precision = "ms" # "s"
## Prior to 1.0.0, this gem has written all data points in different
## measurements (the config options were named `series_name_for_*`).
## Since 1.0.0.beta3, we're now using a single measurements
# config.measurement_name = "rails"
## Disable rails framework hooks.
# config.ignored_hooks = ['sql.active_record', 'render_template.action_view']
# Modify tags on the fly.
# config.tags_middleware = ->(tags) { tags }
## Set the application name to something meaningful, by default we
## infer the app name from the Rails.application class name.
# config.application_name = Rails.application.class.parent_name
end
end

View File

@@ -1,5 +1,6 @@
Wrestling::Application.routes.draw do
resources :mats
post "mats/:id/assign_next_match" => "mats#assign_next_match", :as => :assign_next_match
resources :matches
@@ -54,7 +55,7 @@ Wrestling::Application.routes.draw do
get 'tournaments/:id/export' => "tournaments#export"
post "/tournaments/:id/import" => "tournaments#import", :as => :import
get "/tournaments/:id/brackets" => "tournaments#show"
post "/tournaments/:id/calculate_team_scores" => "tournaments#calculate_team_scores"
put "/tournaments/:id/calculate_team_scores", :to => "tournaments#calculate_team_scores"
post 'weights/:id/re_gen' => 'weights#re_gen', :as => :regen_weight
post "/wrestlers/update_pool" => "wrestlers#update_pool"

0
config/storage.yml Normal file
View File

4
cypress-tests/Dockerfile Normal file
View File

@@ -0,0 +1,4 @@
FROM cypress/included:12.4.0
COPY cypress.config.js /
COPY ./tests/* /cypress/e2e/

View File

@@ -0,0 +1,13 @@
const { defineConfig } = require('cypress')
module.exports = defineConfig({
e2e: {
baseUrl: 'http://wrestlingdev-test.wimer.house',
supportFile: false,
video: false,
},
env: {
CYPRESS_PASSWORD: 'password',
CYPRESS_USERNAME: 'test@test.com',
},
})

View File

@@ -0,0 +1,13 @@
#!/bin/bash
#!/bin/bash
project_dir="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/.."
cd ${project_dir}/cypress-tests
# include ruby, mysql, memcached, and cypress in dockerfile to emulate prod?
# then cypress points to localhost within the docker
docker build -t wrestlingdev-cypress .
docker run -it --rm wrestlingdev-cypress

View File

@@ -0,0 +1,27 @@
describe('Testing Log In', () => {
it('Gets Log In Page and Logs In', () => {
cy.visit('/')
cy.contains('Log In').click()
// Should be on a new URL which
// includes '/commands/actions'
cy.url().should('include', '/users/sign_in')
// Get an input, type into it
cy.get('[id=user_email]').type(Cypress.env('CYPRESS_USERNAME'))
// Verify that the value has been updated
cy.get('[id=user_email]').should('have.value', Cypress.env('CYPRESS_USERNAME'))
// Get an input, type into it
cy.get('[id=user_password]').type(Cypress.env('CYPRESS_PASSWORD'))
// Verify that the value has been updated
cy.get('[id=user_password]').should('have.value', Cypress.env('CYPRESS_PASSWORD'))
cy.get('input[type=submit]').click()
cy.contains('Signed in successfully')
})
})

View File

@@ -0,0 +1,5 @@
class AddScaleToTeamScoreDecimal < ActiveRecord::Migration[6.1]
def change
change_column :schools, :score, :decimal, precision: 15, scale: 1
end
end

View File

@@ -0,0 +1,6 @@
class IndexesMatchesWeightidWrestlersSchoolid < ActiveRecord::Migration[6.1]
def change
add_index :matches, :weight_id
add_index :wrestlers, :school_id
end
end

View File

@@ -0,0 +1,5 @@
class AddOvertimeToMatch < ActiveRecord::Migration[6.1]
def change
add_column :matches, :overtime_type, :string
end
end

View File

@@ -0,0 +1,5 @@
class AddIsPublicToTournaments < ActiveRecord::Migration[6.1]
def change
add_column :tournaments, :is_public, :boolean
end
end

View File

@@ -0,0 +1,9 @@
class SetAllExistingTournamentsAsPublic < ActiveRecord::Migration[6.1]
def up
Tournament.update_all(is_public: true)
end
def down
Tournament.update_all(is_public: nil)
end
end

View File

@@ -0,0 +1,5 @@
class ChangeWeightToFloat < ActiveRecord::Migration[6.1]
def change
change_column :weights, :max, :decimal, precision: 15, scale: 1
end
end

View File

@@ -2,15 +2,15 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `rails
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_11_26_174257) do
ActiveRecord::Schema.define(version: 2023_02_02_130918) do
create_table "delayed_jobs", force: :cascade do |t|
t.integer "priority", default: 0, null: false
@@ -49,9 +49,11 @@ ActiveRecord::Schema.define(version: 2019_11_26_174257) do
t.string "loser1_name"
t.string "loser2_name"
t.integer "mat_id"
t.string "overtime_type"
t.index ["mat_id"], name: "index_matches_on_mat_id"
t.index ["tournament_id"], name: "index_matches_on_tournament_id"
t.index ["w1", "w2"], name: "index_matches_on_w1_and_w2"
t.index ["weight_id"], name: "index_matches_on_weight_id"
end
create_table "mats", force: :cascade do |t|
@@ -74,7 +76,7 @@ ActiveRecord::Schema.define(version: 2019_11_26_174257) do
t.datetime "created_at"
t.datetime "updated_at"
t.integer "tournament_id"
t.decimal "score"
t.decimal "score", precision: 15, scale: 1
t.index ["tournament_id"], name: "index_schools_on_tournament_id"
end
@@ -106,6 +108,7 @@ ActiveRecord::Schema.define(version: 2019_11_26_174257) do
t.integer "user_id"
t.integer "curently_generating_matches"
t.date "date"
t.boolean "is_public"
t.index ["user_id"], name: "index_tournaments_on_user_id"
end
@@ -127,7 +130,7 @@ ActiveRecord::Schema.define(version: 2019_11_26_174257) do
end
create_table "weights", force: :cascade do |t|
t.integer "max"
t.decimal "max", precision: 15, scale: 1
t.datetime "created_at"
t.datetime "updated_at"
t.integer "tournament_id"
@@ -150,6 +153,7 @@ ActiveRecord::Schema.define(version: 2019_11_26_174257) do
t.integer "pool"
t.integer "pool_placement"
t.string "pool_placement_tiebreaker"
t.index ["school_id"], name: "index_wrestlers_on_school_id"
t.index ["weight_id"], name: "index_wrestlers_on_weight_id"
end

View File

@@ -6,103 +6,88 @@
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
#if Rails.env.development?
def create_schools(tournament, number_of_schools)
for number in (1..number_of_schools) do
school = School.new
school.name = "School#{number}"
school.tournament_id = tournament.id
school.save
end
end
def create_wrestlers_for_weight(weight, tournament, number_of_wrestlers, naming_start_number)
naming_number = naming_start_number
for number in (1..number_of_wrestlers) do
wrestler = Wrestler.new
wrestler.name = "Wrestler#{naming_number}"
wrestler.school_id = tournament.schools.select{|s|s.name == "School#{number}"}.first.id
wrestler.weight_id = weight.id
wrestler.original_seed = number
wrestler.save
naming_number = naming_number + 1
end
end
User.create(id: 1, email: 'test@test.com', password: 'password', password_confirmation: 'password')
Tournament.create(id: 200, name: 'test', address: 'some place', director: 'some guy', director_email: 'hismail@email.com', tournament_type: 'Pool to bracket', user_id: 1, date: Date.today)
School.create(id: 200, name: 'Central Crossing', tournament_id: 200)
School.create(id: 201, name: 'Turd Town', tournament_id: 200)
School.create(id: 202, name: 'Shit Show', tournament_id: 200)
School.create(id: 203, name: 'Westland', tournament_id: 200)
School.create(id: 204, name: 'Grove City', tournament_id: 200)
School.create(id: 205, name: 'Franklin Heights', tournament_id: 200)
Weight.create(id: 200, max: 132, tournament_id: 200 )
Weight.create(id: 201, max: 106, tournament_id: 200 )
Weight.create(id: 202, max: 113, tournament_id: 200 )
Weight.create(id: 203, max: 120, tournament_id: 200 )
Weight.create(id: 204, max: 126, tournament_id: 200 )
Weight.create(id: 205, max: 138, tournament_id: 200 )
Mat.create(id: 200, name: "1", tournament_id: 200 )
Mat.create(id: 201, name: "2", tournament_id: 200 )
Mat.create(id: 202, name: "3", tournament_id: 200 )
Mat.create(id: 203, name: "4", tournament_id: 200 )
Wrestler.create(name: 'Guy 1', school_id: 200, weight_id: 200, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 2', school_id: 201, weight_id: 200, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 3', school_id: 202, weight_id: 200, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 4', school_id: 203, weight_id: 200, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 5', school_id: 204, weight_id: 200, original_seed: 5, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 6', school_id: 200, weight_id: 200, original_seed: 6, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 7', school_id: 200, weight_id: 200, original_seed: 7, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 8', school_id: 200, weight_id: 200, original_seed: 8, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 9', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 10', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 11', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 12', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 13', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 14', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 15', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 16', school_id: 200, weight_id: 200, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 17', school_id: 200, weight_id: 201, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 18', school_id: 201, weight_id: 201, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 19', school_id: 202, weight_id: 201, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 20', school_id: 203, weight_id: 201, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 21', school_id: 204, weight_id: 201, original_seed: 5, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 22', school_id: 200, weight_id: 201, original_seed: 6, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 23', school_id: 200, weight_id: 201, original_seed: 7, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 24', school_id: 200, weight_id: 201, original_seed: 8, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 25', school_id: 200, weight_id: 201, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 26', school_id: 201, weight_id: 201, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 27', school_id: 202, weight_id: 201, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 30', school_id: 204, weight_id: 202, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 31', school_id: 204, weight_id: 202, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 32', school_id: 204, weight_id: 202, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 33', school_id: 204, weight_id: 202, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 34', school_id: 204, weight_id: 202, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 35', school_id: 204, weight_id: 203, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 36', school_id: 204, weight_id: 203, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 37', school_id: 204, weight_id: 203, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 38', school_id: 204, weight_id: 203, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 39', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 40', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 41', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 42', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 43', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 44', school_id: 204, weight_id: 203, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
# Pool to bracket
tournament = Tournament.create(id: 200, name: 'Test1', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Pool to bracket', user_id: 1, date: Date.today, is_public: true)
create_schools(tournament, 16)
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
tournament.create_pre_defined_weights(weight_classes)
wrestler_name_number = 1
tournament.weights.each do |weight|
create_wrestlers_for_weight(weight, tournament, 16, wrestler_name_number)
wrestler_name_number += 16
end
Wrestler.create(name: 'Guy 45', school_id: 204, weight_id: 204, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 46', school_id: 204, weight_id: 204, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 47', school_id: 204, weight_id: 204, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 48', school_id: 204, weight_id: 204, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 49', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 50', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 51', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 52', school_id: 204, weight_id: 204, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
# Modified 16 Man Double Elimination 1-6
tournament = Tournament.create(id: 201, name: 'Test2', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Modified 16 Man Double Elimination 1-6', user_id: 1, date: Date.today, is_public: true)
create_schools(tournament, 16)
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
tournament.create_pre_defined_weights(weight_classes)
wrestler_name_number = 1
tournament.weights.each do |weight|
create_wrestlers_for_weight(weight, tournament, 16, wrestler_name_number)
wrestler_name_number += 16
end
Wrestler.create(name: 'Guy 53', school_id: 204, weight_id: 205, original_seed: 1, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 54', school_id: 204, weight_id: 205, original_seed: 2, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 55', school_id: 204, weight_id: 205, original_seed: 3, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 56', school_id: 204, weight_id: 205, original_seed: 4, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 57', school_id: 204, weight_id: 205, original_seed: 5, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 58', school_id: 204, weight_id: 205, original_seed: 6, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 59', school_id: 204, weight_id: 205, original_seed: 7, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 60', school_id: 204, weight_id: 205, original_seed: 8, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 61', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 62', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 63', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 64', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 65', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 66', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 67', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 68', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 69', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 70', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 71', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 72', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 73', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 74', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 75', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
Wrestler.create(name: 'Guy 76', school_id: 204, weight_id: 205, original_seed: nil, season_win: 0, season_loss: 0, criteria: 'N/A')
# Modified 16 Man Double Elimination 1-8
tournament = Tournament.create(id: 202, name: 'Test3', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Modified 16 Man Double Elimination 1-8', user_id: 1, date: Date.today, is_public: true)
create_schools(tournament, 16)
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
tournament.create_pre_defined_weights(weight_classes)
wrestler_name_number = 1
tournament.weights.each do |weight|
create_wrestlers_for_weight(weight, tournament, 16, wrestler_name_number)
wrestler_name_number += 16
end
# Regular Double Elimination 1-6
tournament = Tournament.create(id: 203, name: 'Test4', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Regular Double Elimination 1-6', user_id: 1, date: Date.today, is_public: true)
create_schools(tournament, 16)
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
tournament.create_pre_defined_weights(weight_classes)
wrestler_name_number = 1
tournament.weights.each do |weight|
create_wrestlers_for_weight(weight, tournament, 16, wrestler_name_number)
wrestler_name_number += 16
end
# Regular Double Elimination 1-8
tournament = Tournament.create(id: 204, name: 'Test5', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Regular Double Elimination 1-8', user_id: 1, date: Date.today, is_public: true)
create_schools(tournament, 16)
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
tournament.create_pre_defined_weights(weight_classes)
wrestler_name_number = 1
tournament.weights.each do |weight|
create_wrestlers_for_weight(weight, tournament, 16, wrestler_name_number)
wrestler_name_number += 16
end
#end

View File

@@ -1,12 +1,19 @@
#!/bin/bash
project_dir="$(dirname $( dirname $(readlink -f ${BASH_SOURCE[0]})))"
RAM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}')
RAM_MB=$(expr $RAM_KB / 1024)
RAM_GB=$(expr $RAM_MB / 1024)
RAM_WITHOUT_OTHER_SERVICES=$(expr $RAM_MB - 1024) # other services use ~1024MB of RAM
PASSENGER_POOL_FACTOR=$(expr $RAM_WITHOUT_OTHER_SERVICES / 256) # 1 pool worker uses ~256MB of RAM
export PASSENGER_POOL_SIZE=$(expr $PASSENGER_POOL_FACTOR '*' 1)
#docker build -t wrestlingdev:test -f ${project_dir}/deploy/rails-prod-Dockerfile ${project_dir}
docker-compose -f ${project_dir}/deploy/docker-compose-test.yml kill
docker-compose -f ${project_dir}/deploy/docker-compose-test.yml build
docker-compose -f ${project_dir}/deploy/docker-compose-test.yml up -d
# echo Make sure your local mysql database has a wrestlingtourney db
docker exec -it deploy_app_1 rake db:create
docker exec -it deploy_app_1 rake db:migrate
echo To seed data run:
echo docker exec -it deploy_app_1 rake db:seed
docker exec -i deploy_app_1 rake db:create
docker exec -i deploy_app_1 rake db:migrate
echo Resetting the db with seed data
docker exec -i deploy_app_1 bash -c "DISABLE_DATABASE_ENVIRONMENT_CHECK=1 rake db:reset"

View File

@@ -2,9 +2,11 @@ version: "2.2"
networks:
database:
caching:
metrics:
volumes:
mysql:
influxdb:
services:
app:
@@ -23,9 +25,14 @@ services:
- MEMCACHIER_PASSWORD=
- WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa
- WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2
- WRESTLINGDEV_INFLUXDB_DATABASE=wrestlingdev
- WRESTLINGDEV_INFLUXDB_HOST=influxdb
- WRESTLINGDEV_INFLUXDB_PORT=8086
- PASSENGER_POOL_SIZE=${PASSENGER_POOL_SIZE}
networks:
database:
caching:
metrics:
restart: always
ports:
- "80:80"
@@ -58,16 +65,31 @@ services:
- MEMCACHIER_PASSWORD=
- WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa
- WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2
- WRESTLINGDEV_INFLUXDB_DATABASE=wrestlingdev
- WRESTLINGDEV_INFLUXDB_HOST=influxdb
- WRESTLINGDEV_INFLUXDB_PORT=8086
- PASSENGER_POOL_SIZE=${PASSENGER_POOL_SIZE}
networks:
database:
caching:
metrics:
restart: always
command: bundle exec bin/delayed_job -n 1 run
influxdb:
image: influxdb:1.8-alpine
environment:
- INFLUXDB_DB=wrestlingdev
ports:
- "8086:8086"
networks:
metrics:
volumes:
- influxdb:/var/lib/influxdb
memcached:
image: memcached:1.5
mem_limit: 64000000
mem_limit: "64000000"
restart: always
networks:
caching:
caching:

View File

@@ -11,10 +11,10 @@
4. Run `kubectl apply -f deploy/kubernetes/manifests/`
## What do I get?
1. Wrestlingdev deployed with 2 replicas. Autoscaling is turned on up to 4 replcias.
2. A standalone mariadb.
3. A standalone memcahced.
4. A single job runner to run wrestlingdev background jobs.
1. Wrestlingdev deployed with 2 replicas.
2. Two workers are deployed to run background jobs
3. A standalone mariadb that can back up to S3 compatable storage if you set the values in `deploy/kubernetes/secrets/secrets.yaml` and prometheus ready metrics
4. A standalone memcahced.
## How do I update the app?
First, be sure your secrets.yaml has all envs up to date. Then, make sure you get all manifest changes
@@ -23,12 +23,17 @@ First, be sure your secrets.yaml has all envs up to date. Then, make sure you ge
Each push to master updates the docker `prod` tag and also pushes a tag with the git hash. You will want to update to those tags.
1. Set the git hash as a variable `TAG=$(git rev-parse --verify HEAD)`
2. Update the wrestlingdev deployment tag `kubectl --record deployment.apps/wrestlingdev-app-deployment set image deployment.v1.apps/wrestlingdev-app-deployment wrestlingdev-app=jcwimer/wrestlingdev:${TAG}`
3. Update the wrestlingdev job runner tag `kubectl --record deployment.apps/wrestlingdev-worker-deployment set image deployment.v1.apps/wrestlingdev-worker-deployment wrestlingdev-worker=jcwimer/wrestlingdev:${TAG}`
3. Update the wrestlingdev job runner tag `kubectl --record statefulset.apps/wrestlingdev-worker set image statefulset.v1.apps/wrestlingdev-worker wrestlingdev-worker=jcwimer/wrestlingdev:${TAG}`
Finally, run db-migrations
1. Delete the db migrations job so you can re-run it `kubectl delete job wrestlingdev-db-create-migrate`
2. Re-run the db migrations job `kubectl apply -f https://raw.githubusercontent.com/jcwimer/wrestlingApp/master/deploy/kubernetes/manifests/db-migration.yaml`
## How do I see logs?
For workers: `kubectl logs -f --tail=100 -l app=wrestlingdev -l tier=worker`
For app logs: `kubectl logs -f --tail=100 -l app=wrestlingdev -l tier=app`
## I'm a pro. What's bad about this?
Right now, mariadb's root password comes from the secrets.yaml and wrestlingdev uses the root password to run. Ideally, you'd create another secret for mariadb's root password and you'd create a user specifically for wrestlingdev.
From a mysql shell> `CREATE USER ${username} IDENTIFIED BY '${password}'; GRANT ALL PRIVILEGES ON ${database}.* TO ${username}; FLUSH PRIVILEGES;` $database would be wrestlingdev. I'll do this automatically later.
@@ -36,4 +41,4 @@ From a mysql shell> `CREATE USER ${username} IDENTIFIED BY '${password}'; GRANT
Right now, we're also only using gmail for email.
## Recommended cloud machines
In production, this runs on GKE. I have two node pools. The first is 2 x `n2-high-cpu-2` ($12.63/month preemptible). That pool can run 1 "copy" of the application. That means 2 x app pods, 1 x worker, 1 x memcached, and 1 x mariadb. The second node pool is an autoscale from 0-10 and is of the machine type `n1-standard-1` ($7.30/ month preemptible). This pool is scritly for scaling the app pods and the worker pods.
In production, this runs on GKE. I have two node pools. The first is 2 x `n2-high-cpu-2` ($12.63/month preemptible). That pool can run 1 "copy" of the application. That means 2 x app pods, 1 x worker, 1 x memcached, and 1 x mariadb. The second node pool is an autoscale from 0-10 and is of the machine type `n1-standard-1` ($7.30/ month preemptible). This pool is strictly for scaling the app pods and the worker pods.

View File

@@ -0,0 +1,73 @@
---
apiVersion: v1
kind: Service
metadata:
name: wrestlingdev-influxdb
labels:
app: wrestlingdev
tier: metrics
spec:
ports:
- port: 8086
selector:
app: wrestlingdev
tier: metrics
clusterIP: None
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: wrestlingdev-influxdb
labels:
app: wrestlingdev
tier: metrics
spec:
replicas: 1
selector:
matchLabels:
app: wrestlingdev
template:
metadata:
labels:
app: wrestlingdev
tier: metrics
spec:
containers:
- name: wrestlingdev-influxdb
image: influxdb:1.8-alpine
ports:
- containerPort: 8086
env:
- name: INFLUXDB_DB
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: influxdb_database
volumeMounts:
- name: wrestlingdev-influxdb-persistent-storage
mountPath: /var/lib/influxdb
# resources:
# limits:
# memory: "512Mi"
# requests:
# memory: "128Mi"
# cpu: "0.5"
volumes:
- name: wrestlingdev-influxdb-persistent-storage
persistentVolumeClaim:
claimName: wrestlingdev-influxdb-pv-claim
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wrestlingdev-influxdb-pv-claim
labels:
app: wrestlingdev
tier: metrics
spec:
# storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi

View File

@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: wrestlingdev-app-ingress-external
@@ -11,9 +11,12 @@ spec:
http:
paths:
- path: /
pathType: Prefix
backend:
serviceName: wrestlingdev-app
servicePort: 80
service:
name: wrestlingdev-app
port:
number: 80
tls:
- hosts:
- wrestlingdev.com

View File

@@ -19,20 +19,23 @@ metadata:
labels:
app: wrestlingdev
spec:
storageClassName: standard
# storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: wrestlingdev-mariadb
labels:
app: wrestlingdev
spec:
selector:
matchLabels:
app: wrestlingdev
strategy:
type: Recreate
template:
@@ -40,12 +43,15 @@ spec:
labels:
app: wrestlingdev
tier: mariadb
annotations:
prometheus.io/port: "9125"
prometheus.io/scrape: "true"
spec:
containers:
- image: mariadb:10.3
name: mariadb
env:
- name: MYSQL_ROOT_PASSWORD
- name: MARIADB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
@@ -56,14 +62,145 @@ spec:
volumeMounts:
- name: wrestlingdev-mariadb-persistent-storage
mountPath: /var/lib/mysql
resources:
limits:
cpu: "0.5"
memory: "512Mi"
requests:
memory: "256Mi"
cpu: "0.2"
- name: mysettings-config-volume
mountPath: /etc/mysql/mariadb.conf.d
# resources:
# limits:
# memory: "512Mi"
# requests:
# memory: "256Mi"
# cpu: "0.2"
- image: jcwimer/mariadb-rclone-backup-docker:10.3
name: mariadb-backup
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: dbpassword
- name: CRON_SCHEDULE
value: "*/5 * * * *" # every 5 minutes
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: dbusername
- name: DB_HOST
value: "127.0.0.1"
- name: DAYS_TO_KEEP
value: "7"
- name: RCLONE_TYPE
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: rclone_type
- name: S3_ACCESS_ID
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: s3_access_id
- name: S3_ACCESS_KEY
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: s3_access_key
- name: S3_ENDPOINT
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: s3_endpoint
- name: S3_REGION
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: s3_region
- name: RCLONE_EXTRA_ARGS
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: rclone_extra_args
- name: RCLONE_PATH
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: rclone_path
volumeMounts:
- name: wrestlingdev-mariadb-persistent-storage
mountPath: /var/lib/mysql
# resources:
# limits:
# memory: "100Mi"
# requests:
# memory: "50Mi"
# cpu: "0.1"
- image: prom/mysqld-exporter:v0.11.0
name: mariadb-exporter
ports:
- containerPort: 9125
name: "http"
args:
- --web.listen-address=0.0.0.0:9125
- --web.telemetry-path=/metrics
- --collect.heartbeat
- --collect.heartbeat.database=sys_operator
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: dbpassword
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: dbusername
- name: DB_HOST
value: "127.0.0.1:3306"
- name: DATA_SOURCE_NAME
value: $(DB_USERNAME):$(DB_PASSWORD)@($(DB_HOST))/
- name: DAYS_TO_KEEP
value: "7"
# resources:
# limits:
# memory: "128Mi"
# requests:
# memory: "32Mi"
# cpu: "10m"
livenessProbe:
httpGet:
path: /metrics
port: 9125
initialDelaySeconds: 30
periodSeconds: 30
timeoutSeconds: 30
volumes:
- name: wrestlingdev-mariadb-persistent-storage
persistentVolumeClaim:
claimName: wrestlingdev-mariadb-pv-claim
- name: mysettings-config-volume
configMap:
name: mariadb-mysettings
---
apiVersion: v1
kind: ConfigMap
metadata:
name: mariadb-mysettings
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: EnsureExists
data:
70-mysettings.cnf: |
[mariadb]
# Slow log
slow_query_log=1
#slow_query_log_file=/var/log/mariadb/slow.log
slow_query_log_file=/var/lib/mysql/slow.log
long_query_time=0.2
# mysqltunner recommendations
tmp_table_size=32M
max_heap_table_size=32M
performance_schema=ON
innodb_log_file_size=32M
table_open_cache=4000
# /etc/mysql/mariadb.conf.d/70-mysettings.cnf

View File

@@ -36,8 +36,7 @@ spec:
- containerPort: 11211
resources:
limits:
cpu: "0.2"
memory: "64Mi"
requests:
memory: "64Mi"
cpu: "0.1"
# requests:
# memory: "64Mi"
# cpu: "0.1"

View File

@@ -34,12 +34,17 @@ spec:
image: jcwimer/wrestlingdev:prod
imagePullPolicy: Always
command: ["bundle"]
args: ["exec", "passenger", "start", "-p", "80", "--max-pool-size", "3","--environment", "production"]
args: ["exec", "passenger", "start", "-p", "80", "--max-pool-size", "2","--environment", "production"]
ports:
- containerPort: 80
env:
- name: RAILS_ENV
value: production
- name: PASSENGER_POOL_SIZE
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: passenger_pool_size
- name: WRESTLINGDEV_DB_NAME
value: wrestlingdev
- name: WRESTLINGDEV_DB_USR
@@ -81,13 +86,27 @@ spec:
secretKeyRef:
name: wrestlingdev-secrets
key: gmailemail
resources:
limits:
cpu: "0.5"
memory: "768Mi"
requests:
memory: "300Mi"
cpu: "0.3"
- name: WRESTLINGDEV_INFLUXDB_DATABASE
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: influxdb_database
- name: WRESTLINGDEV_INFLUXDB_HOST
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: influxdb_hostname
- name: WRESTLINGDEV_INFLUXDB_PORT
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: influxdb_port
# resources:
# limits:
# memory: "768Mi"
# requests:
# memory: "300Mi"
# cpu: "0.3"
livenessProbe:
httpGet:
path: /
@@ -95,39 +114,40 @@ spec:
initialDelaySeconds: 180
periodSeconds: 20
timeoutSeconds: 10
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: wrestlingdev-app-deployment-autoscale
spec:
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: wrestlingdev-app-deployment
minReplicas: 2
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 75
# ---
# apiVersion: autoscaling/v2beta1
# kind: HorizontalPodAutoscaler
# metadata:
# name: wrestlingdev-app-deployment-autoscale
# spec:
# scaleTargetRef:
# apiVersion: apps/v1
# kind: Deployment
# name: wrestlingdev-app-deployment
# minReplicas: 2
# maxReplicas: 5
# metrics:
# - type: Resource
# resource:
# name: cpu
# targetAverageUtilization: 75
# - type: Resource
# resource:
# name: memory
# targetAverageValue: 100Mi
---
apiVersion: apps/v1
kind: Deployment
kind: StatefulSet
metadata:
name: wrestlingdev-worker-deployment
name: wrestlingdev-worker
labels:
app: wrestlingdev
spec:
replicas: 1
replicas: 2
selector:
matchLabels:
app: wrestlingdev
serviceName: wrestlingdev-worker
template:
metadata:
labels:
@@ -172,11 +192,6 @@ spec:
secretKeyRef:
name: wrestlingdev-secrets
key: railssecretkey
- name: WRESTLINGDEV_SECRET_KEY_BASE
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: railssecretkey
- name: WRESTLINGDEV_EMAIL_PWD
valueFrom:
secretKeyRef:
@@ -187,13 +202,27 @@ spec:
secretKeyRef:
name: wrestlingdev-secrets
key: gmailemail
- name: WRESTLINGDEV_INFLUXDB_DATABASE
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: influxdb_database
- name: WRESTLINGDEV_INFLUXDB_HOST
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: influxdb_hostname
- name: WRESTLINGDEV_INFLUXDB_PORT
valueFrom:
secretKeyRef:
name: wrestlingdev-secrets
key: influxdb_port
command: ["bundle"]
args: ["exec", "bin/delayed_job", "-n", "1", "run"]
resources:
limits:
cpu: "0.5"
memory: "512Mi"
requests:
memory: "200Mi"
cpu: "0.2"
# resources:
# limits:
# memory: "512Mi"
# requests:
# memory: "200Mi"
# cpu: "0.2"

View File

@@ -5,10 +5,25 @@ metadata:
type: Opaque
#data:
stringData:
dbusername: root
dbpassword: PUT_SECRET_HERE
dbhost: wrestlingdev-mariadb (if using the mariadb-standalone from this repo, otherwise use your hostname for your database)
devisesecretkey: PUT_SECRET_HERE get from running rails secret
railssecretkey: PUT_SECRET_HERE get from running rails secret
emailpassword: PUT_EMAIL_PASSWORD_HERE
gmailemail: PUT EMAIL ADDRESS HERE
# REQUIRED
dbusername: root # if using the mariadb-standalone from this repo, otherwise use your username for your database
dbpassword: PUT_SECRET_HERE # db password
dbhost: wrestlingdev-mariadb # if using the mariadb-standalone from this repo, otherwise use your hostname for your database
devisesecretkey: PUT_SECRET_HERE # get from running rails secret
railssecretkey: PUT_SECRET_HERE # get from running rails secret
gmailpassword: PUT_EMAIL_PASSWORD_HERE # gmail password
gmailemail: PUT EMAIL ADDRESS HERE
passenger_pool_size: "2"
# OPTIONAL
# DELETE THESE LINES IF YOU'RE NOT USING THEM
influxdb_database: PUT INFLUXDB DATABASE NAME HERE
influxdb_hostname: PUT INFLUXDB HOSTNAME OR IP HERE
influxdb_port: PUT INFLUXDB PORT HERE
rclone_type: s3
rclone_extra_args: # example --no-check-certificate for self signed ssl minio certs
rclone_path: # path to put the backup, for example this would be the bucket name for s3
# required if rclone_type is s3
s3_access_id:
s3_access_key:
s3_endpoint:
s3_region:

View File

@@ -1,4 +1,4 @@
FROM ruby:2.6.5
FROM ruby:3.0.4
RUN apt-get -qq update \
&& apt-get -qq install -y \
@@ -22,7 +22,8 @@ RUN gem install bundler
RUN gem update --system
ADD Gemfile* /tmp/
WORKDIR /tmp
RUN bundle install --jobs 4 --without production
RUN bundle config set without 'production'
RUN bundle install --jobs 4
RUN mkdir /rails
WORKDIR /rails

View File

@@ -1,4 +1,4 @@
FROM ruby:2.6.5-slim
FROM ruby:3.0.4-slim
#HEALTHCHECK --start-period=60s CMD curl http://127.0.0.1/
@@ -17,6 +17,7 @@ RUN apt-get -qq update \
default-libmysqlclient-dev \
nodejs \
tzdata \
git \
&& apt-get -qq clean \
&& apt-get autoremove -y \
&& rm -rf \
@@ -51,7 +52,7 @@ EXPOSE 443
# Tini solves the zombie PID problem
ENTRYPOINT ["/tini", "--"]
CMD bundle exec passenger start --max-pool-size 2 --min-instances 2 --environment production -p 80
CMD bundle exec passenger start --max-pool-size ${PASSENGER_POOL_SIZE} --min-instances ${PASSENGER_POOL_SIZE} --environment production -p 80
# Higher max pool uses more ram
# Followed recommendation from: https://blog.phusion.nl/2015/11/10/heroku-and-passenger-focus-on-the-app-performance/

View File

@@ -1,19 +0,0 @@
task :finish_seed_tournament => :environment do
@tournament = Tournament.where(:id => 200).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first
GenerateTournamentMatches.new(@tournament).generate
(1..@tournament.reload.total_rounds).each do |round|
@tournament.reload.matches_by_round(round).select{|m| m.finished != 1}.each do |match|
match.reload
if match.wrestler1.bracket_line < match.wrestler2.bracket_line and match.w1
match.winner_id = match.w1
elsif match.w2
match.winner_id = match.w2
end
if match.winner_id
match.finished = 1
match.score = "2-1"
match.save
end
end
end
end

View File

@@ -0,0 +1,28 @@
task :finish_seed_tournaments => :environment do
finish_tournament(tournament_id)
@tournament = Tournament.where(:id => tournament_id).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first
GenerateTournamentMatches.new(@tournament).generate
(1..@tournament.reload.total_rounds).each do |round|
@tournament.reload.matches_by_round(round).select{|m| m.finished != 1}.each do |match|
match.reload
if match.wrestler1.bracket_line < match.wrestler2.bracket_line and match.w1
match.winner_id = match.w1
elsif match.w2
match.winner_id = match.w2
end
if match.winner_id
match.finished = 1
match.win_type = "Decision"
match.score = "2-1"
match.save
end
end
end
finish_tournament(200)
finish_tournament(201)
finish_tournament(202)
finish_tournament(203)
finish_tournament(204)
end

View File

@@ -14,6 +14,10 @@ class MatsControllerTest < ActionController::TestCase
post :create, params: { mat: {name: 'Mat100', tournament_id: 1} }
end
def post_assign_next_match
post :assign_next_match, params: { id: @mat.id }
end
def new
get :new, params: { tournament: @tournament.id }
end
@@ -224,4 +228,34 @@ class MatsControllerTest < ActionController::TestCase
show
no_matches
end
# Assign Next Match Permissions
test "logged in tournament owner should post assign_next_match mat page" do
sign_in_owner
post_assign_next_match
assert_redirected_to "/tournaments/#{@mat.tournament_id}"
end
test "logged in tournament delegate should post assign_next_match mat page" do
sign_in_tournament_delegate
post_assign_next_match
assert_redirected_to "/tournaments/#{@mat.tournament_id}"
end
test "logged in user should not get post assign_next_match page if not owner" do
sign_in_non_owner
post_assign_next_match
redirect
end
test "logged school delegate should not post assign_next_match mat page if not owner" do
sign_in_school_delegate
post_assign_next_match
redirect
end
test "non logged in user should not post assign_next_match mat page" do
post_assign_next_match
redirect
end
end

View File

@@ -17,6 +17,10 @@ class SchoolsControllerTest < ActionController::TestCase
get :new, params: { tournament: @tournament.id }
end
def get_show
get :show, params: { id: @school.id }
end
def post_update
patch :update, params: { id: @school.id, school: {name: @school.name, tournament_id: @school.tournament_id} }
end
@@ -205,4 +209,85 @@ Some Guy
redirect
end
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
test "logged in school delegate can get show page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_school_delegate
get_show
success
end
test "logged in user cannot get show page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_non_owner
get_show
redirect
end
test "logged in tournament delegate can get show page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_tournament_delegate
get_show
success
end
test "logged in tournament owner can get show page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_owner
get_show
success
end
test "non logged in user cannot get show page when tournament is not public" do
@tournament.is_public = false
@tournament.save
get_show
redirect
end
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
test "logged in school delegate can get show page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_school_delegate
get_show
success
end
test "logged in user can get show page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_non_owner
get_show
success
end
test "logged in tournament delegate can get show page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_tournament_delegate
get_show
success
end
test "logged in tournament owner can get show page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_owner
get_show
success
end
test "non logged in user can get show page when tournament is public" do
@tournament.is_public = true
@tournament.save
get_show
success
end
# END SHOW PAGE PERMISSIONS
end

View File

@@ -14,6 +14,18 @@ class TournamentsControllerTest < ActionController::TestCase
def post_update
patch :update, params: { id: 1, tournament: {name: @tournament.name} }
end
def get_bracket
get :up_matches, params: { id: 1 }
end
def get_all_brackets
get :all_brackets, params: { id: 1 }
end
def get_up_matches
get :up_matches, params: { id: 1 }
end
def get_edit
get :edit, params: { id: 1 }
@@ -211,6 +223,248 @@ class TournamentsControllerTest < ActionController::TestCase
redirect
end
# BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
test "logged in school delegate cannot get bracket page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_school_delegate
get_bracket
redirect
end
test "logged in user cannot get bracket page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_non_owner
get_bracket
redirect
end
test "logged in tournament delegate can get bracket page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_delegate
get_bracket
success
end
test "logged in tournament owner can get bracket page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_owner
get_bracket
success
end
test "non logged in user cannot get bracket page when tournament is not public" do
@tournament.is_public = false
@tournament.save
get_bracket
redirect
end
# BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
test "logged in school delegate can get bracket page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_school_delegate
get_bracket
success
end
test "logged in user can get bracket page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_non_owner
get_bracket
success
end
test "logged in tournament delegate can get bracket page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_delegate
get_bracket
success
end
test "logged in tournament owner can get bracket page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_owner
get_bracket
success
end
test "non logged in user can get bracket page when tournament is public" do
@tournament.is_public = true
@tournament.save
get_bracket
success
end
# END BRACKETS PAGE PERMISSIONS
# ALL BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
test "logged in school delegate cannot get all brackets page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_school_delegate
get_all_brackets
redirect
end
test "logged in user cannot get all brackets page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_non_owner
get_all_brackets
redirect
end
test "logged in tournament delegate can get all brackets page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_delegate
get_all_brackets
success
end
test "logged in tournament owner can get all brackets page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_owner
get_all_brackets
success
end
test "non logged in user cannot get all brackets page when tournament is not public" do
@tournament.is_public = false
@tournament.save
get_all_brackets
redirect
end
# ALL BRACKETS PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
test "logged in school delegate can get all brackets page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_school_delegate
get_all_brackets
success
end
test "logged in user can get all brackets page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_non_owner
get_all_brackets
success
end
test "logged in tournament delegate can get all brackets page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_delegate
get_all_brackets
success
end
test "logged in tournament owner can get all brackets page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_owner
get_all_brackets
success
end
test "non logged in user can get all brackets page when tournament is public" do
@tournament.is_public = true
@tournament.save
get_all_brackets
success
end
# END ALL BRACKETS PAGE PERMISSIONS
# UP MATCHES PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
test "logged in school delegate cannot get up matches page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_school_delegate
get_up_matches
redirect
end
test "logged in user cannot get up matches page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_non_owner
get_up_matches
redirect
end
test "logged in tournament delegate can get up matches page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_delegate
get_up_matches
success
end
test "logged in tournament owner can get up matches page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_owner
get_up_matches
success
end
test "non logged in user cannot get up matches page when tournament is not public" do
@tournament.is_public = false
@tournament.save
get_up_matches
redirect
end
# UP MATCHES PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
test "logged in school delegate can get up matches page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_school_delegate
get_up_matches
success
end
test "logged in user can get up matches page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_non_owner
get_up_matches
success
end
test "logged in tournament delegate can get up matches page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_delegate
get_up_matches
success
end
test "logged in tournament owner can get up matches page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_owner
get_up_matches
success
end
test "non logged in user can get up matches page when tournament is public" do
@tournament.is_public = true
@tournament.save
get_up_matches
success
end
# END UP MATCHES PAGE PERMISSIONS
#TESTS THAT NEED MATCHES PUT ABOVE THIS
test "redirect up_matches if no matches" do

View File

@@ -30,6 +30,10 @@ class WeightsControllerTest < ActionController::TestCase
get :edit, params: { id: @weight.id }
end
def get_show
get :show, params: { id: @weight.id }
end
def get_pool_order
post :pool_order, params: {pool_to_order: 1, id: @weight.id}
end
@@ -210,6 +214,87 @@ class WeightsControllerTest < ActionController::TestCase
redirect
end
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS NOT PUBLIC
test "logged in school delegate cannot get show page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_school_delegate
get_show
redirect
end
test "logged in user cannot get show page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_non_owner
get_show
redirect
end
test "logged in tournament delegate can get show page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_tournament_delegate
get_show
success
end
test "logged in tournament owner can get show page when tournament is not public" do
@tournament.is_public = false
@tournament.save
sign_in_owner
get_show
success
end
test "non logged in user cannot get show page when tournament is not public" do
@tournament.is_public = false
@tournament.save
get_show
redirect
end
# SHOW PAGE PERMISSIONS WHEN TOURNAMENT IS PUBLIC
test "logged in school delegate can get show page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_school_delegate
get_show
success
end
test "logged in user can get show page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_non_owner
get_show
success
end
test "logged in tournament delegate can get show page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_tournament_delegate
get_show
success
end
test "logged in tournament owner can get show page when tournament is public" do
@tournament.is_public = true
@tournament.save
sign_in_owner
get_show
success
end
test "non logged in user can get show page when tournament is public" do
@tournament.is_public = true
@tournament.save
get_show
success
end
# END SHOW PAGE PERMISSIONS
test "view wegiht" do
get :show, params: { id: 1 }
success

Some files were not shown because too many files have changed in this diff Show More