mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Compare commits
49 Commits
64man
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3fb68a932 | ||
| d359be3ea1 | |||
| e97aa0d680 | |||
| ae8d995b2c | |||
| d57aaac09d | |||
| fcc8a9b9a9 | |||
| b51866e9d8 | |||
| 07d43e7720 | |||
| d8b6cfa8ac | |||
| 5d674f894f | |||
| 25df2a7280 | |||
| 2767274066 | |||
| a2f8c7bced | |||
| 9c2a9d62ad | |||
| 556090c16b | |||
| 86f9c03991 | |||
| c8764c149b | |||
| fe9a9c628c | |||
| 7e4b6d8fc8 | |||
| 940f7b1d00 | |||
| 52df73d14f | |||
| 8b03a74b1e | |||
| b4bca8f10a | |||
| af1f8df4b6 | |||
| 3576445a1c | |||
| 8c2ddf55ed | |||
| cfd3e7aecd | |||
| 608999cb51 | |||
| 6b5308360e | |||
| 9ca6572d9b | |||
| 61dc5e3cdd | |||
| af2fc3feba | |||
| 793a9e3ecc | |||
| f73e9bfc4e | |||
| 92bd06fe3c | |||
| 6e9554be55 | |||
| 34f1783031 | |||
| bbd2bd9b44 | |||
| 6ecebba70d | |||
| e64751e471 | |||
| d0f19e855f | |||
| 3e1ae22b6b | |||
| 15f85e439c | |||
| c5b9783853 | |||
| cd77268070 | |||
| d61ed80287 | |||
| dd5ce9bd60 | |||
| 9a4e6f6597 | |||
| 782baedcfe |
@@ -4,7 +4,8 @@
|
|||||||
- Do not add unnecessary comments to the code where you remove things.
|
- Do not add unnecessary comments to the code where you remove things.
|
||||||
- Cypress tests are created for js tests. They can be found in cypress-tests/cypress
|
- Cypress tests are created for js tests. They can be found in cypress-tests/cypress
|
||||||
- Cypress tests can be run with docker: bash cypress-tests/run-cypress-tests.sh
|
- Cypress tests can be run with docker: bash cypress-tests/run-cypress-tests.sh
|
||||||
|
- Rails tests can be run with docker: docker run -it -v $(pwd):/rails wrestlingdev-dev rake test
|
||||||
- Write as little code as possible. I do not want crazy non standard rails implementations.
|
- Write as little code as possible. I do not want crazy non standard rails implementations.
|
||||||
- This project is using propshaft and importmap.
|
- This project is using propshaft and importmap.
|
||||||
- Stimulus is used for javascript.
|
- Stimulus is used for javascript.
|
||||||
- Use the context7 mcp server for context.
|
- use context7
|
||||||
|
|||||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -27,4 +27,10 @@ frontend/node_modules
|
|||||||
cypress-tests/cypress/screenshots
|
cypress-tests/cypress/screenshots
|
||||||
cypress-tests/cypress/videos
|
cypress-tests/cypress/videos
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# generated with npx repomix
|
||||||
|
# repomix-output.xml
|
||||||
|
|
||||||
|
# generated by cine mcp settings
|
||||||
|
~/
|
||||||
@@ -1 +1 @@
|
|||||||
wrestlingdev
|
wrestlingdev
|
||||||
@@ -1 +1 @@
|
|||||||
ruby-3.2.0
|
ruby-4.0.1
|
||||||
17
Gemfile
17
Gemfile
@@ -1,8 +1,8 @@
|
|||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
ruby '3.2.0'
|
ruby '4.0.1'
|
||||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||||
gem 'rails', '8.0.2'
|
gem 'rails', '8.1.2'
|
||||||
|
|
||||||
# Added in rails 7.1
|
# Added in rails 7.1
|
||||||
gem 'rails-html-sanitizer'
|
gem 'rails-html-sanitizer'
|
||||||
@@ -40,7 +40,7 @@ gem 'sdoc', :group => :doc
|
|||||||
gem 'spring', :group => :development
|
gem 'spring', :group => :development
|
||||||
|
|
||||||
# Use ActiveModel has_secure_password
|
# Use ActiveModel has_secure_password
|
||||||
gem 'bcrypt', '~> 3.1.7'
|
gem 'bcrypt', '~> 3.1.22'
|
||||||
|
|
||||||
# Use unicorn as the app server
|
# Use unicorn as the app server
|
||||||
# gem 'unicorn'
|
# gem 'unicorn'
|
||||||
@@ -67,6 +67,7 @@ gem 'influxdb-rails'
|
|||||||
gem 'cancancan'
|
gem 'cancancan'
|
||||||
gem 'round_robin_tournament'
|
gem 'round_robin_tournament'
|
||||||
gem 'rb-readline'
|
gem 'rb-readline'
|
||||||
|
gem 'rqrcode'
|
||||||
# Replacing Delayed Job with Solid Queue
|
# Replacing Delayed Job with Solid Queue
|
||||||
# gem 'delayed_job_active_record'
|
# gem 'delayed_job_active_record'
|
||||||
gem 'solid_queue'
|
gem 'solid_queue'
|
||||||
@@ -74,17 +75,16 @@ gem 'solid_cable'
|
|||||||
gem 'puma'
|
gem 'puma'
|
||||||
gem 'tzinfo-data'
|
gem 'tzinfo-data'
|
||||||
gem 'daemons'
|
gem 'daemons'
|
||||||
# Interface for viewing and managing background jobs
|
# Solid Queue UI
|
||||||
# gem 'delayed_job_web'
|
gem "mission_control-jobs"
|
||||||
# Note: solid_queue-ui is not compatible with Rails 8.0 yet
|
|
||||||
# We'll create a custom UI or wait for compatibility updates
|
|
||||||
# gem 'solid_queue_ui', '~> 0.1.1'
|
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
# gem 'rubocop'
|
# gem 'rubocop'
|
||||||
gem 'bullet'
|
gem 'bullet'
|
||||||
gem 'brakeman'
|
gem 'brakeman'
|
||||||
gem 'bundler-audit'
|
gem 'bundler-audit'
|
||||||
|
gem 'rubocop'
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
@@ -92,4 +92,3 @@ group :development, :test do
|
|||||||
# rails-controller-testing is needed for assert_template
|
# rails-controller-testing is needed for assert_template
|
||||||
gem 'rails-controller-testing'
|
gem 'rails-controller-testing'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
325
Gemfile.lock
325
Gemfile.lock
@@ -1,29 +1,31 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
actioncable (8.0.2)
|
action_text-trix (2.1.16)
|
||||||
actionpack (= 8.0.2)
|
railties
|
||||||
activesupport (= 8.0.2)
|
actioncable (8.1.2)
|
||||||
|
actionpack (= 8.1.2)
|
||||||
|
activesupport (= 8.1.2)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
websocket-driver (>= 0.6.1)
|
websocket-driver (>= 0.6.1)
|
||||||
zeitwerk (~> 2.6)
|
zeitwerk (~> 2.6)
|
||||||
actionmailbox (8.0.2)
|
actionmailbox (8.1.2)
|
||||||
actionpack (= 8.0.2)
|
actionpack (= 8.1.2)
|
||||||
activejob (= 8.0.2)
|
activejob (= 8.1.2)
|
||||||
activerecord (= 8.0.2)
|
activerecord (= 8.1.2)
|
||||||
activestorage (= 8.0.2)
|
activestorage (= 8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activesupport (= 8.1.2)
|
||||||
mail (>= 2.8.0)
|
mail (>= 2.8.0)
|
||||||
actionmailer (8.0.2)
|
actionmailer (8.1.2)
|
||||||
actionpack (= 8.0.2)
|
actionpack (= 8.1.2)
|
||||||
actionview (= 8.0.2)
|
actionview (= 8.1.2)
|
||||||
activejob (= 8.0.2)
|
activejob (= 8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activesupport (= 8.1.2)
|
||||||
mail (>= 2.8.0)
|
mail (>= 2.8.0)
|
||||||
rails-dom-testing (~> 2.2)
|
rails-dom-testing (~> 2.2)
|
||||||
actionpack (8.0.2)
|
actionpack (8.1.2)
|
||||||
actionview (= 8.0.2)
|
actionview (= 8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activesupport (= 8.1.2)
|
||||||
nokogiri (>= 1.8.5)
|
nokogiri (>= 1.8.5)
|
||||||
rack (>= 2.2.4)
|
rack (>= 2.2.4)
|
||||||
rack-session (>= 1.0.1)
|
rack-session (>= 1.0.1)
|
||||||
@@ -31,80 +33,83 @@ GEM
|
|||||||
rails-dom-testing (~> 2.2)
|
rails-dom-testing (~> 2.2)
|
||||||
rails-html-sanitizer (~> 1.6)
|
rails-html-sanitizer (~> 1.6)
|
||||||
useragent (~> 0.16)
|
useragent (~> 0.16)
|
||||||
actiontext (8.0.2)
|
actiontext (8.1.2)
|
||||||
actionpack (= 8.0.2)
|
action_text-trix (~> 2.1.15)
|
||||||
activerecord (= 8.0.2)
|
actionpack (= 8.1.2)
|
||||||
activestorage (= 8.0.2)
|
activerecord (= 8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activestorage (= 8.1.2)
|
||||||
|
activesupport (= 8.1.2)
|
||||||
globalid (>= 0.6.0)
|
globalid (>= 0.6.0)
|
||||||
nokogiri (>= 1.8.5)
|
nokogiri (>= 1.8.5)
|
||||||
actionview (8.0.2)
|
actionview (8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activesupport (= 8.1.2)
|
||||||
builder (~> 3.1)
|
builder (~> 3.1)
|
||||||
erubi (~> 1.11)
|
erubi (~> 1.11)
|
||||||
rails-dom-testing (~> 2.2)
|
rails-dom-testing (~> 2.2)
|
||||||
rails-html-sanitizer (~> 1.6)
|
rails-html-sanitizer (~> 1.6)
|
||||||
activejob (8.0.2)
|
activejob (8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activesupport (= 8.1.2)
|
||||||
globalid (>= 0.3.6)
|
globalid (>= 0.3.6)
|
||||||
activemodel (8.0.2)
|
activemodel (8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activesupport (= 8.1.2)
|
||||||
activerecord (8.0.2)
|
activerecord (8.1.2)
|
||||||
activemodel (= 8.0.2)
|
activemodel (= 8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activesupport (= 8.1.2)
|
||||||
timeout (>= 0.4.0)
|
timeout (>= 0.4.0)
|
||||||
activestorage (8.0.2)
|
activestorage (8.1.2)
|
||||||
actionpack (= 8.0.2)
|
actionpack (= 8.1.2)
|
||||||
activejob (= 8.0.2)
|
activejob (= 8.1.2)
|
||||||
activerecord (= 8.0.2)
|
activerecord (= 8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activesupport (= 8.1.2)
|
||||||
marcel (~> 1.0)
|
marcel (~> 1.0)
|
||||||
activesupport (8.0.2)
|
activesupport (8.1.2)
|
||||||
base64
|
base64
|
||||||
benchmark (>= 0.3)
|
|
||||||
bigdecimal
|
bigdecimal
|
||||||
concurrent-ruby (~> 1.0, >= 1.3.1)
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
||||||
connection_pool (>= 2.2.5)
|
connection_pool (>= 2.2.5)
|
||||||
drb
|
drb
|
||||||
i18n (>= 1.6, < 2)
|
i18n (>= 1.6, < 2)
|
||||||
|
json
|
||||||
logger (>= 1.4.2)
|
logger (>= 1.4.2)
|
||||||
minitest (>= 5.1)
|
minitest (>= 5.1)
|
||||||
securerandom (>= 0.3)
|
securerandom (>= 0.3)
|
||||||
tzinfo (~> 2.0, >= 2.0.5)
|
tzinfo (~> 2.0, >= 2.0.5)
|
||||||
uri (>= 0.13.1)
|
uri (>= 0.13.1)
|
||||||
base64 (0.2.0)
|
ast (2.4.3)
|
||||||
bcrypt (3.1.20)
|
base64 (0.3.0)
|
||||||
benchmark (0.4.0)
|
bcrypt (3.1.22)
|
||||||
bigdecimal (3.1.9)
|
bigdecimal (4.0.1)
|
||||||
bootsnap (1.18.6)
|
bootsnap (1.23.0)
|
||||||
msgpack (~> 1.2)
|
msgpack (~> 1.2)
|
||||||
brakeman (7.0.2)
|
brakeman (8.0.2)
|
||||||
racc
|
racc
|
||||||
builder (3.3.0)
|
builder (3.3.0)
|
||||||
bullet (8.0.7)
|
bullet (8.1.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
uniform_notifier (~> 1.11)
|
uniform_notifier (~> 1.11)
|
||||||
bundler-audit (0.9.2)
|
bundler-audit (0.9.3)
|
||||||
bundler (>= 1.2.0, < 3)
|
bundler (>= 1.2.0)
|
||||||
thor (~> 1.0)
|
thor (~> 1.0)
|
||||||
cancancan (3.6.1)
|
cancancan (3.6.1)
|
||||||
concurrent-ruby (1.3.5)
|
chunky_png (1.4.0)
|
||||||
connection_pool (2.5.3)
|
concurrent-ruby (1.3.6)
|
||||||
|
connection_pool (3.0.2)
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
daemons (1.4.1)
|
daemons (1.4.1)
|
||||||
date (3.4.1)
|
date (3.5.1)
|
||||||
drb (2.2.1)
|
drb (2.2.3)
|
||||||
|
erb (6.0.1)
|
||||||
erubi (1.13.1)
|
erubi (1.13.1)
|
||||||
et-orbi (1.2.11)
|
et-orbi (1.4.0)
|
||||||
tzinfo
|
tzinfo
|
||||||
fugit (1.11.1)
|
fugit (1.12.1)
|
||||||
et-orbi (~> 1, >= 1.2.11)
|
et-orbi (~> 1.4)
|
||||||
raabro (~> 1.4)
|
raabro (~> 1.4)
|
||||||
globalid (1.2.1)
|
globalid (1.3.0)
|
||||||
activesupport (>= 6.1)
|
activesupport (>= 6.1)
|
||||||
i18n (1.14.7)
|
i18n (1.14.8)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
importmap-rails (2.1.0)
|
importmap-rails (2.2.3)
|
||||||
actionpack (>= 6.0.0)
|
actionpack (>= 6.0.0)
|
||||||
activesupport (>= 6.0.0)
|
activesupport (>= 6.0.0)
|
||||||
railties (>= 6.0.0)
|
railties (>= 6.0.0)
|
||||||
@@ -112,35 +117,52 @@ GEM
|
|||||||
influxdb-rails (1.0.3)
|
influxdb-rails (1.0.3)
|
||||||
influxdb (~> 0.6, >= 0.6.4)
|
influxdb (~> 0.6, >= 0.6.4)
|
||||||
railties (>= 5.0)
|
railties (>= 5.0)
|
||||||
io-console (0.8.0)
|
io-console (0.8.2)
|
||||||
irb (1.15.2)
|
irb (1.17.0)
|
||||||
pp (>= 0.6.0)
|
pp (>= 0.6.0)
|
||||||
|
prism (>= 1.3.0)
|
||||||
rdoc (>= 4.0.0)
|
rdoc (>= 4.0.0)
|
||||||
reline (>= 0.4.2)
|
reline (>= 0.4.2)
|
||||||
jbuilder (2.13.0)
|
jbuilder (2.14.1)
|
||||||
actionview (>= 5.0.0)
|
actionview (>= 7.0.0)
|
||||||
activesupport (>= 5.0.0)
|
activesupport (>= 7.0.0)
|
||||||
jquery-rails (4.6.0)
|
jquery-rails (4.6.1)
|
||||||
rails-dom-testing (>= 1, < 3)
|
rails-dom-testing (>= 1, < 3)
|
||||||
railties (>= 4.2.0)
|
railties (>= 4.2.0)
|
||||||
thor (>= 0.14, < 2.0)
|
thor (>= 0.14, < 2.0)
|
||||||
|
json (2.18.1)
|
||||||
|
language_server-protocol (3.17.0.5)
|
||||||
|
lint_roller (1.1.0)
|
||||||
logger (1.7.0)
|
logger (1.7.0)
|
||||||
loofah (2.24.1)
|
loofah (2.25.0)
|
||||||
crass (~> 1.0.2)
|
crass (~> 1.0.2)
|
||||||
nokogiri (>= 1.12.0)
|
nokogiri (>= 1.12.0)
|
||||||
mail (2.8.1)
|
mail (2.9.0)
|
||||||
|
logger
|
||||||
mini_mime (>= 0.1.1)
|
mini_mime (>= 0.1.1)
|
||||||
net-imap
|
net-imap
|
||||||
net-pop
|
net-pop
|
||||||
net-smtp
|
net-smtp
|
||||||
marcel (1.0.4)
|
marcel (1.1.0)
|
||||||
mini_mime (1.1.5)
|
mini_mime (1.1.5)
|
||||||
minitest (5.25.5)
|
minitest (6.0.1)
|
||||||
mocha (2.7.1)
|
prism (~> 1.5)
|
||||||
|
mission_control-jobs (1.1.0)
|
||||||
|
actioncable (>= 7.1)
|
||||||
|
actionpack (>= 7.1)
|
||||||
|
activejob (>= 7.1)
|
||||||
|
activerecord (>= 7.1)
|
||||||
|
importmap-rails (>= 1.2.1)
|
||||||
|
irb (~> 1.13)
|
||||||
|
railties (>= 7.1)
|
||||||
|
stimulus-rails
|
||||||
|
turbo-rails
|
||||||
|
mocha (3.0.2)
|
||||||
ruby2_keywords (>= 0.0.5)
|
ruby2_keywords (>= 0.0.5)
|
||||||
msgpack (1.8.0)
|
msgpack (1.8.0)
|
||||||
mysql2 (0.5.6)
|
mysql2 (0.5.7)
|
||||||
net-imap (0.5.8)
|
bigdecimal
|
||||||
|
net-imap (0.6.3)
|
||||||
date
|
date
|
||||||
net-protocol
|
net-protocol
|
||||||
net-pop (0.1.2)
|
net-pop (0.1.2)
|
||||||
@@ -149,65 +171,69 @@ GEM
|
|||||||
timeout
|
timeout
|
||||||
net-smtp (0.5.1)
|
net-smtp (0.5.1)
|
||||||
net-protocol
|
net-protocol
|
||||||
nio4r (2.7.4)
|
nio4r (2.7.5)
|
||||||
nokogiri (1.18.8-aarch64-linux-gnu)
|
nokogiri (1.19.0-aarch64-linux-gnu)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.18.8-aarch64-linux-musl)
|
nokogiri (1.19.0-aarch64-linux-musl)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.18.8-arm-linux-gnu)
|
nokogiri (1.19.0-arm-linux-gnu)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.18.8-arm-linux-musl)
|
nokogiri (1.19.0-arm-linux-musl)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.18.8-arm64-darwin)
|
nokogiri (1.19.0-arm64-darwin)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.18.8-x86_64-darwin)
|
nokogiri (1.19.0-x86_64-darwin)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.18.8-x86_64-linux-gnu)
|
nokogiri (1.19.0-x86_64-linux-gnu)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
nokogiri (1.18.8-x86_64-linux-musl)
|
nokogiri (1.19.0-x86_64-linux-musl)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
pp (0.6.2)
|
parallel (1.27.0)
|
||||||
|
parser (3.3.10.1)
|
||||||
|
ast (~> 2.4.1)
|
||||||
|
racc
|
||||||
|
pp (0.6.3)
|
||||||
prettyprint
|
prettyprint
|
||||||
prettyprint (0.2.0)
|
prettyprint (0.2.0)
|
||||||
propshaft (1.1.0)
|
prism (1.9.0)
|
||||||
|
propshaft (1.3.1)
|
||||||
actionpack (>= 7.0.0)
|
actionpack (>= 7.0.0)
|
||||||
activesupport (>= 7.0.0)
|
activesupport (>= 7.0.0)
|
||||||
rack
|
rack
|
||||||
railties (>= 7.0.0)
|
psych (5.3.1)
|
||||||
psych (5.2.6)
|
|
||||||
date
|
date
|
||||||
stringio
|
stringio
|
||||||
puma (6.6.0)
|
puma (7.2.0)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
raabro (1.4.0)
|
raabro (1.4.0)
|
||||||
racc (1.8.1)
|
racc (1.8.1)
|
||||||
rack (3.1.14)
|
rack (3.2.4)
|
||||||
rack-session (2.1.1)
|
rack-session (2.1.1)
|
||||||
base64 (>= 0.1.0)
|
base64 (>= 0.1.0)
|
||||||
rack (>= 3.0.0)
|
rack (>= 3.0.0)
|
||||||
rack-test (2.2.0)
|
rack-test (2.2.0)
|
||||||
rack (>= 1.3)
|
rack (>= 1.3)
|
||||||
rackup (2.2.1)
|
rackup (2.3.1)
|
||||||
rack (>= 3)
|
rack (>= 3)
|
||||||
rails (8.0.2)
|
rails (8.1.2)
|
||||||
actioncable (= 8.0.2)
|
actioncable (= 8.1.2)
|
||||||
actionmailbox (= 8.0.2)
|
actionmailbox (= 8.1.2)
|
||||||
actionmailer (= 8.0.2)
|
actionmailer (= 8.1.2)
|
||||||
actionpack (= 8.0.2)
|
actionpack (= 8.1.2)
|
||||||
actiontext (= 8.0.2)
|
actiontext (= 8.1.2)
|
||||||
actionview (= 8.0.2)
|
actionview (= 8.1.2)
|
||||||
activejob (= 8.0.2)
|
activejob (= 8.1.2)
|
||||||
activemodel (= 8.0.2)
|
activemodel (= 8.1.2)
|
||||||
activerecord (= 8.0.2)
|
activerecord (= 8.1.2)
|
||||||
activestorage (= 8.0.2)
|
activestorage (= 8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activesupport (= 8.1.2)
|
||||||
bundler (>= 1.15.0)
|
bundler (>= 1.15.0)
|
||||||
railties (= 8.0.2)
|
railties (= 8.1.2)
|
||||||
rails-controller-testing (1.0.5)
|
rails-controller-testing (1.0.5)
|
||||||
actionpack (>= 5.0.1.rc1)
|
actionpack (>= 5.0.1.rc1)
|
||||||
actionview (>= 5.0.1.rc1)
|
actionview (>= 5.0.1.rc1)
|
||||||
activesupport (>= 5.0.1.rc1)
|
activesupport (>= 5.0.1.rc1)
|
||||||
rails-dom-testing (2.2.0)
|
rails-dom-testing (2.3.0)
|
||||||
activesupport (>= 5.0.0)
|
activesupport (>= 5.0.0)
|
||||||
minitest
|
minitest
|
||||||
nokogiri (>= 1.6)
|
nokogiri (>= 1.6)
|
||||||
@@ -219,70 +245,98 @@ GEM
|
|||||||
rails_stdout_logging
|
rails_stdout_logging
|
||||||
rails_serve_static_assets (0.0.5)
|
rails_serve_static_assets (0.0.5)
|
||||||
rails_stdout_logging (0.0.5)
|
rails_stdout_logging (0.0.5)
|
||||||
railties (8.0.2)
|
railties (8.1.2)
|
||||||
actionpack (= 8.0.2)
|
actionpack (= 8.1.2)
|
||||||
activesupport (= 8.0.2)
|
activesupport (= 8.1.2)
|
||||||
irb (~> 1.13)
|
irb (~> 1.13)
|
||||||
rackup (>= 1.0.0)
|
rackup (>= 1.0.0)
|
||||||
rake (>= 12.2)
|
rake (>= 12.2)
|
||||||
thor (~> 1.0, >= 1.2.2)
|
thor (~> 1.0, >= 1.2.2)
|
||||||
|
tsort (>= 0.2)
|
||||||
zeitwerk (~> 2.6)
|
zeitwerk (~> 2.6)
|
||||||
rake (13.2.1)
|
rainbow (3.1.1)
|
||||||
|
rake (13.3.1)
|
||||||
rb-readline (0.5.5)
|
rb-readline (0.5.5)
|
||||||
rdoc (6.13.1)
|
rdoc (7.2.0)
|
||||||
|
erb
|
||||||
psych (>= 4.0.0)
|
psych (>= 4.0.0)
|
||||||
reline (0.6.1)
|
tsort
|
||||||
|
regexp_parser (2.11.3)
|
||||||
|
reline (0.6.3)
|
||||||
io-console (~> 0.5)
|
io-console (~> 0.5)
|
||||||
round_robin_tournament (0.1.2)
|
round_robin_tournament (0.1.2)
|
||||||
|
rqrcode (3.2.0)
|
||||||
|
chunky_png (~> 1.0)
|
||||||
|
rqrcode_core (~> 2.0)
|
||||||
|
rqrcode_core (2.1.0)
|
||||||
|
rubocop (1.84.2)
|
||||||
|
json (~> 2.3)
|
||||||
|
language_server-protocol (~> 3.17.0.2)
|
||||||
|
lint_roller (~> 1.1.0)
|
||||||
|
parallel (~> 1.10)
|
||||||
|
parser (>= 3.3.0.2)
|
||||||
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
|
regexp_parser (>= 2.9.3, < 3.0)
|
||||||
|
rubocop-ast (>= 1.49.0, < 2.0)
|
||||||
|
ruby-progressbar (~> 1.7)
|
||||||
|
unicode-display_width (>= 2.4.0, < 4.0)
|
||||||
|
rubocop-ast (1.49.0)
|
||||||
|
parser (>= 3.3.7.2)
|
||||||
|
prism (~> 1.7)
|
||||||
|
ruby-progressbar (1.13.0)
|
||||||
ruby2_keywords (0.0.5)
|
ruby2_keywords (0.0.5)
|
||||||
sdoc (2.6.1)
|
sdoc (2.6.5)
|
||||||
rdoc (>= 5.0)
|
rdoc (>= 5.0)
|
||||||
securerandom (0.4.1)
|
securerandom (0.4.1)
|
||||||
solid_cable (3.0.8)
|
solid_cable (3.0.12)
|
||||||
actioncable (>= 7.2)
|
actioncable (>= 7.2)
|
||||||
activejob (>= 7.2)
|
activejob (>= 7.2)
|
||||||
activerecord (>= 7.2)
|
activerecord (>= 7.2)
|
||||||
railties (>= 7.2)
|
railties (>= 7.2)
|
||||||
solid_cache (1.0.7)
|
solid_cache (1.0.10)
|
||||||
activejob (>= 7.2)
|
activejob (>= 7.2)
|
||||||
activerecord (>= 7.2)
|
activerecord (>= 7.2)
|
||||||
railties (>= 7.2)
|
railties (>= 7.2)
|
||||||
solid_queue (1.1.5)
|
solid_queue (1.3.1)
|
||||||
activejob (>= 7.1)
|
activejob (>= 7.1)
|
||||||
activerecord (>= 7.1)
|
activerecord (>= 7.1)
|
||||||
concurrent-ruby (>= 1.3.1)
|
concurrent-ruby (>= 1.3.1)
|
||||||
fugit (~> 1.11.0)
|
fugit (~> 1.11)
|
||||||
railties (>= 7.1)
|
railties (>= 7.1)
|
||||||
thor (~> 1.3.1)
|
thor (>= 1.3.1)
|
||||||
spring (4.3.0)
|
spring (4.4.2)
|
||||||
sqlite3 (2.6.0-aarch64-linux-gnu)
|
sqlite3 (2.9.0-aarch64-linux-gnu)
|
||||||
sqlite3 (2.6.0-aarch64-linux-musl)
|
sqlite3 (2.9.0-aarch64-linux-musl)
|
||||||
sqlite3 (2.6.0-arm-linux-gnu)
|
sqlite3 (2.9.0-arm-linux-gnu)
|
||||||
sqlite3 (2.6.0-arm-linux-musl)
|
sqlite3 (2.9.0-arm-linux-musl)
|
||||||
sqlite3 (2.6.0-arm64-darwin)
|
sqlite3 (2.9.0-arm64-darwin)
|
||||||
sqlite3 (2.6.0-x86_64-darwin)
|
sqlite3 (2.9.0-x86_64-darwin)
|
||||||
sqlite3 (2.6.0-x86_64-linux-gnu)
|
sqlite3 (2.9.0-x86_64-linux-gnu)
|
||||||
sqlite3 (2.6.0-x86_64-linux-musl)
|
sqlite3 (2.9.0-x86_64-linux-musl)
|
||||||
stimulus-rails (1.3.4)
|
stimulus-rails (1.3.4)
|
||||||
railties (>= 6.0.0)
|
railties (>= 6.0.0)
|
||||||
stringio (3.1.7)
|
stringio (3.2.0)
|
||||||
thor (1.3.2)
|
thor (1.5.0)
|
||||||
timeout (0.4.3)
|
timeout (0.6.0)
|
||||||
turbo-rails (2.0.13)
|
tsort (0.2.0)
|
||||||
|
turbo-rails (2.0.23)
|
||||||
actionpack (>= 7.1.0)
|
actionpack (>= 7.1.0)
|
||||||
railties (>= 7.1.0)
|
railties (>= 7.1.0)
|
||||||
tzinfo (2.0.6)
|
tzinfo (2.0.6)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
tzinfo-data (1.2025.2)
|
tzinfo-data (1.2025.3)
|
||||||
tzinfo (>= 1.0.0)
|
tzinfo (>= 1.0.0)
|
||||||
uniform_notifier (1.17.0)
|
unicode-display_width (3.2.0)
|
||||||
uri (1.0.3)
|
unicode-emoji (~> 4.1)
|
||||||
|
unicode-emoji (4.2.0)
|
||||||
|
uniform_notifier (1.18.0)
|
||||||
|
uri (1.1.1)
|
||||||
useragent (0.16.11)
|
useragent (0.16.11)
|
||||||
websocket-driver (0.7.7)
|
websocket-driver (0.8.0)
|
||||||
base64
|
base64
|
||||||
websocket-extensions (>= 0.1.0)
|
websocket-extensions (>= 0.1.0)
|
||||||
websocket-extensions (0.1.5)
|
websocket-extensions (0.1.5)
|
||||||
zeitwerk (2.7.2)
|
zeitwerk (2.7.4)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
aarch64-linux-gnu
|
aarch64-linux-gnu
|
||||||
@@ -295,7 +349,7 @@ PLATFORMS
|
|||||||
x86_64-linux-musl
|
x86_64-linux-musl
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
bcrypt (~> 3.1.7)
|
bcrypt (~> 3.1.22)
|
||||||
bootsnap
|
bootsnap
|
||||||
brakeman
|
brakeman
|
||||||
bullet
|
bullet
|
||||||
@@ -306,16 +360,19 @@ DEPENDENCIES
|
|||||||
influxdb-rails
|
influxdb-rails
|
||||||
jbuilder
|
jbuilder
|
||||||
jquery-rails
|
jquery-rails
|
||||||
|
mission_control-jobs
|
||||||
mocha
|
mocha
|
||||||
mysql2
|
mysql2
|
||||||
propshaft
|
propshaft
|
||||||
puma
|
puma
|
||||||
rails (= 8.0.2)
|
rails (= 8.1.2)
|
||||||
rails-controller-testing
|
rails-controller-testing
|
||||||
rails-html-sanitizer
|
rails-html-sanitizer
|
||||||
rails_12factor
|
rails_12factor
|
||||||
rb-readline
|
rb-readline
|
||||||
round_robin_tournament
|
round_robin_tournament
|
||||||
|
rqrcode
|
||||||
|
rubocop
|
||||||
sdoc
|
sdoc
|
||||||
solid_cable
|
solid_cable
|
||||||
solid_cache
|
solid_cache
|
||||||
@@ -327,7 +384,7 @@ DEPENDENCIES
|
|||||||
tzinfo-data
|
tzinfo-data
|
||||||
|
|
||||||
RUBY VERSION
|
RUBY VERSION
|
||||||
ruby 3.2.0p0
|
ruby 4.0.1p0
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.6.9
|
4.0.3
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -7,8 +7,8 @@ This application is being created to run a wrestling tournament.
|
|||||||
**Public Production Url:** [https://wrestlingdev.com](https://wrestlingdev.com)
|
**Public Production Url:** [https://wrestlingdev.com](https://wrestlingdev.com)
|
||||||
|
|
||||||
**App Info**
|
**App Info**
|
||||||
* Ruby 3.2.0
|
* Ruby 4.0.1
|
||||||
* Rails 8.0.2
|
* Rails 8.1.2
|
||||||
* DB MySQL/MariaDB
|
* DB MySQL/MariaDB
|
||||||
* Solid Cache -> MySQL/MariaDB for html partial caching
|
* Solid Cache -> MySQL/MariaDB for html partial caching
|
||||||
* Solid Queue -> MySQL/MariaDB for background job processing
|
* Solid Queue -> MySQL/MariaDB for background job processing
|
||||||
@@ -34,11 +34,14 @@ In development environments, background jobs run inline (synchronously) by defau
|
|||||||
|
|
||||||
To run a single test file:
|
To run a single test file:
|
||||||
1. Get a shell with ruby and rails: `bash bin/rails-dev-run.sh wrestlingdev-development`
|
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`
|
2. `rake test TEST=test/models/match_test.rb` OR `rails test test/models/match_test.rb`
|
||||||
|
|
||||||
To run a single test inside a file:
|
To run a single test inside a file:
|
||||||
1. Get a shell with ruby and rails: `bash bin/rails-dev-run.sh wrestlingdev-development`
|
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/'"`
|
2. `rake test TEST=test/models/match_test.rb TESTOPTS="--name='/test_Match_should_not_be_valid_if_an_incorrect_win_type_is_given/'"` OR `rails test test/models/match_test.rb --name=/test_Match_should_not_be_valid_if_an_incorrect_win_type_is_given/`
|
||||||
|
|
||||||
|
To run tests in verbose mode (outputs the time for each test file and the test file name)
|
||||||
|
`rails test -v`
|
||||||
|
|
||||||
## Develop with rvm
|
## Develop with rvm
|
||||||
With rvm installed, run `rvm install ruby-3.2.0`
|
With rvm installed, run `rvm install ruby-3.2.0`
|
||||||
@@ -148,6 +151,9 @@ Available system resources: X CPU(s), YMMMB RAM
|
|||||||
SolidQueue plugin enabled in Puma
|
SolidQueue plugin enabled in Puma
|
||||||
```
|
```
|
||||||
|
|
||||||
|
I have deployed Mission Control as a UI for SolidQueue. The uri for mission control is `/jobs`.
|
||||||
|
For the development environment, the user/password is dev/secret. For the production environment, it is defined by environment variables WRESTLINGDEV_MISSION_CONTROL_USER/WRESTLINGDEV_MISSION_CONTROL_PASSWORD. You can see this in `config/environments/production.rb` and `config/environments/development.rb`.
|
||||||
|
|
||||||
## Environment Variables
|
## Environment Variables
|
||||||
|
|
||||||
### Required Environment Variables
|
### Required Environment Variables
|
||||||
@@ -160,6 +166,8 @@ SolidQueue plugin enabled in Puma
|
|||||||
* `WRESTLINGDEV_SECRET_KEY_BASE` - Rails application secret key (can be generated with `rake secret`)
|
* `WRESTLINGDEV_SECRET_KEY_BASE` - Rails application secret key (can be generated with `rake secret`)
|
||||||
* `WRESTLINGDEV_EMAIL` - Email address (currently must be a Gmail account)
|
* `WRESTLINGDEV_EMAIL` - Email address (currently must be a Gmail account)
|
||||||
* `WRESTLINGDEV_EMAIL_PWD` - Email password
|
* `WRESTLINGDEV_EMAIL_PWD` - Email password
|
||||||
|
* `WRESTLINGDEV_MISSION_CONTROL_USER` - mission control username
|
||||||
|
* `WRESTLINGDEV_MISSION_CONTROL_PASSWORD` - mission control password
|
||||||
|
|
||||||
### Optional Environment Variables
|
### Optional Environment Variables
|
||||||
* `SOLID_QUEUE_IN_PUMA` - Set to "true" to run Solid Queue workers inside Puma (default in development)
|
* `SOLID_QUEUE_IN_PUMA` - Set to "true" to run Solid Queue workers inside Puma (default in development)
|
||||||
@@ -206,4 +214,7 @@ The application has been migrated from using vanilla JavaScript to Hotwired Stim
|
|||||||
- `app/assets/javascripts/controllers/` - Contains all Stimulus controllers
|
- `app/assets/javascripts/controllers/` - Contains all Stimulus controllers
|
||||||
- `app/assets/javascripts/application.js` - Registers and loads all controllers
|
- `app/assets/javascripts/application.js` - Registers and loads all controllers
|
||||||
|
|
||||||
The importmap configuration in `config/importmap.rb` handles the loading of all JavaScript dependencies including Stimulus controllers.
|
The importmap configuration in `config/importmap.rb` handles the loading of all JavaScript dependencies including Stimulus controllers.
|
||||||
|
|
||||||
|
# Using Repomix with LLMs
|
||||||
|
`npx repomix app test`
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ export default class extends Controller {
|
|||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
console.log("Match data controller connected")
|
console.log("Match data controller connected")
|
||||||
|
this.isConnected = false
|
||||||
|
this.pendingLocalSync = { w1: false, w2: false }
|
||||||
|
|
||||||
this.w1 = {
|
this.w1 = {
|
||||||
name: "w1",
|
name: "w1",
|
||||||
@@ -69,6 +71,7 @@ export default class extends Controller {
|
|||||||
wrestler.updated_at = new Date().toISOString()
|
wrestler.updated_at = new Date().toISOString()
|
||||||
this.updateHtmlValues()
|
this.updateHtmlValues()
|
||||||
this.saveToLocalStorage(wrestler)
|
this.saveToLocalStorage(wrestler)
|
||||||
|
if (!this.isConnected) this.pendingLocalSync[wrestler.name] = true
|
||||||
|
|
||||||
// Send the update via Action Cable if subscribed
|
// Send the update via Action Cable if subscribed
|
||||||
if (this.matchSubscription) {
|
if (this.matchSubscription) {
|
||||||
@@ -109,6 +112,7 @@ export default class extends Controller {
|
|||||||
// Update the internal JS object
|
// Update the internal JS object
|
||||||
wrestler.stats = newValue
|
wrestler.stats = newValue
|
||||||
wrestler.updated_at = new Date().toISOString()
|
wrestler.updated_at = new Date().toISOString()
|
||||||
|
if (!this.isConnected) this.pendingLocalSync[wrestler.name] = true
|
||||||
|
|
||||||
// Save to localStorage
|
// Save to localStorage
|
||||||
this.saveToLocalStorage(wrestler)
|
this.saveToLocalStorage(wrestler)
|
||||||
@@ -334,15 +338,18 @@ export default class extends Controller {
|
|||||||
{
|
{
|
||||||
connected: () => {
|
connected: () => {
|
||||||
console.log(`[Stats AC] Connected to MatchStatsChannel for match ID: ${matchId}`)
|
console.log(`[Stats AC] Connected to MatchStatsChannel for match ID: ${matchId}`)
|
||||||
|
this.isConnected = true
|
||||||
if (this.statusIndicatorTarget) {
|
if (this.statusIndicatorTarget) {
|
||||||
this.statusIndicatorTarget.innerText = "Connected: Stats will update in real-time."
|
this.statusIndicatorTarget.innerText = "Connected: Stats will update in real-time."
|
||||||
this.statusIndicatorTarget.classList.remove('alert-info', 'alert-warning', 'alert-danger')
|
this.statusIndicatorTarget.classList.remove('alert-info', 'alert-warning', 'alert-danger')
|
||||||
this.statusIndicatorTarget.classList.add('alert-success')
|
this.statusIndicatorTarget.classList.add('alert-success')
|
||||||
}
|
}
|
||||||
|
this.sendCurrentStatsOnReconnect()
|
||||||
},
|
},
|
||||||
|
|
||||||
disconnected: () => {
|
disconnected: () => {
|
||||||
console.log(`[Stats AC] Disconnected from MatchStatsChannel`)
|
console.log(`[Stats AC] Disconnected from MatchStatsChannel`)
|
||||||
|
this.isConnected = false
|
||||||
if (this.statusIndicatorTarget) {
|
if (this.statusIndicatorTarget) {
|
||||||
this.statusIndicatorTarget.innerText = "Disconnected: Stats updates paused."
|
this.statusIndicatorTarget.innerText = "Disconnected: Stats updates paused."
|
||||||
this.statusIndicatorTarget.classList.remove('alert-info', 'alert-success', 'alert-danger')
|
this.statusIndicatorTarget.classList.remove('alert-info', 'alert-success', 'alert-danger')
|
||||||
@@ -356,15 +363,25 @@ export default class extends Controller {
|
|||||||
// Update w1 stats
|
// Update w1 stats
|
||||||
if (data.w1_stat !== undefined && this.w1StatTarget) {
|
if (data.w1_stat !== undefined && this.w1StatTarget) {
|
||||||
console.log(`[Stats AC] Updating w1_stat: ${data.w1_stat.substring(0, 30)}...`)
|
console.log(`[Stats AC] Updating w1_stat: ${data.w1_stat.substring(0, 30)}...`)
|
||||||
this.w1.stats = data.w1_stat
|
if (!this.pendingLocalSync.w1 || data.w1_stat === this.w1.stats) {
|
||||||
this.w1StatTarget.value = data.w1_stat
|
this.w1.stats = data.w1_stat
|
||||||
|
this.w1StatTarget.value = data.w1_stat
|
||||||
|
this.pendingLocalSync.w1 = false
|
||||||
|
} else {
|
||||||
|
console.log('[Stats AC] Skipping w1_stat overwrite due to pending local changes.')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update w2 stats
|
// Update w2 stats
|
||||||
if (data.w2_stat !== undefined && this.w2StatTarget) {
|
if (data.w2_stat !== undefined && this.w2StatTarget) {
|
||||||
console.log(`[Stats AC] Updating w2_stat: ${data.w2_stat.substring(0, 30)}...`)
|
console.log(`[Stats AC] Updating w2_stat: ${data.w2_stat.substring(0, 30)}...`)
|
||||||
this.w2.stats = data.w2_stat
|
if (!this.pendingLocalSync.w2 || data.w2_stat === this.w2.stats) {
|
||||||
this.w2StatTarget.value = data.w2_stat
|
this.w2.stats = data.w2_stat
|
||||||
|
this.w2StatTarget.value = data.w2_stat
|
||||||
|
this.pendingLocalSync.w2 = false
|
||||||
|
} else {
|
||||||
|
console.log('[Stats AC] Skipping w2_stat overwrite due to pending local changes.')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -381,4 +398,23 @@ export default class extends Controller {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
sendCurrentStatsOnReconnect() {
|
||||||
|
if (!this.matchSubscription) return
|
||||||
|
const payload = {}
|
||||||
|
if (typeof this.w1?.stats === 'string' && this.w1.stats.length > 0) {
|
||||||
|
payload.new_w1_stat = this.w1.stats
|
||||||
|
this.pendingLocalSync.w1 = true
|
||||||
|
}
|
||||||
|
if (typeof this.w2?.stats === 'string' && this.w2.stats.length > 0) {
|
||||||
|
payload.new_w2_stat = this.w2.stats
|
||||||
|
this.pendingLocalSync.w2 = true
|
||||||
|
}
|
||||||
|
if (Object.keys(payload).length > 0) {
|
||||||
|
console.log('[ActionCable] Reconnect sync: sending current stats payload:', payload)
|
||||||
|
this.matchSubscription.perform('send_stat', payload)
|
||||||
|
} else {
|
||||||
|
console.log('[ActionCable] Reconnect sync: no local stats to send.')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -76,6 +76,11 @@ export default class extends Controller {
|
|||||||
this.statusIndicatorTarget.classList.remove('alert-danger', 'alert-secondary', 'text-danger', 'text-dark')
|
this.statusIndicatorTarget.classList.remove('alert-danger', 'alert-secondary', 'text-danger', 'text-dark')
|
||||||
this.statusIndicatorTarget.classList.add('alert-success')
|
this.statusIndicatorTarget.classList.add('alert-success')
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
this.matchSubscription.perform('request_sync')
|
||||||
|
} catch (e) {
|
||||||
|
console.error('[Spectator AC] request_sync perform failed:', e)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
disconnected: () => {
|
disconnected: () => {
|
||||||
console.log(`[Spectator AC Callback] Disconnected: ${matchId}`)
|
console.log(`[Spectator AC Callback] Disconnected: ${matchId}`)
|
||||||
@@ -131,4 +136,4 @@ export default class extends Controller {
|
|||||||
this.finishedTarget.textContent = data.finished ? 'Yes' : 'No'
|
this.finishedTarget.textContent = data.finished ? 'Yes' : 'No'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,4 +60,29 @@ class MatchChannel < ApplicationCable::Channel
|
|||||||
Rails.logger.info "[MatchChannel] No new stat data provided in send_stat for match #{@match.id}, not updating DB or broadcasting."
|
Rails.logger.info "[MatchChannel] No new stat data provided in send_stat for match #{@match.id}, not updating DB or broadcasting."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Called when client wants the latest stats immediately after reconnect
|
||||||
|
def request_sync
|
||||||
|
unless @match
|
||||||
|
Rails.logger.error "[MatchChannel] Error: request_sync called but @match is nil. Client params on sub: #{params[:match_id]}"
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
w1_stat: @match.w1_stat,
|
||||||
|
w2_stat: @match.w2_stat,
|
||||||
|
score: @match.score,
|
||||||
|
win_type: @match.win_type,
|
||||||
|
winner_name: @match.winner&.name,
|
||||||
|
winner_id: @match.winner_id,
|
||||||
|
finished: @match.finished
|
||||||
|
}.compact
|
||||||
|
|
||||||
|
if payload.present?
|
||||||
|
Rails.logger.info "[MatchChannel] request_sync transmit for match #{@match.id} with payload: #{payload.inspect}"
|
||||||
|
transmit(payload)
|
||||||
|
else
|
||||||
|
Rails.logger.info "[MatchChannel] request_sync payload empty for match #{@match.id}, not transmitting."
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class MatchesController < ApplicationController
|
class MatchesController < ApplicationController
|
||||||
before_action :set_match, only: [:show, :edit, :update, :stat, :spectate]
|
before_action :set_match, only: [:show, :edit, :update, :stat, :spectate, :edit_assignment, :update_assignment]
|
||||||
before_action :check_access, only: [:edit,:update, :stat]
|
before_action :check_access, only: [:edit, :update, :stat, :edit_assignment, :update_assignment]
|
||||||
|
|
||||||
# GET /matches/1
|
# GET /matches/1
|
||||||
# GET /matches/1.json
|
# GET /matches/1.json
|
||||||
@@ -21,7 +21,7 @@ class MatchesController < ApplicationController
|
|||||||
session[:return_path] = "/tournaments/#{@match.tournament.id}/matches"
|
session[:return_path] = "/tournaments/#{@match.tournament.id}/matches"
|
||||||
end
|
end
|
||||||
|
|
||||||
def stat
|
def stat
|
||||||
# @show_next_bout_button = false
|
# @show_next_bout_button = false
|
||||||
if params[:match]
|
if params[:match]
|
||||||
@match = Match.where(:id => params[:match]).includes(:wrestlers).first
|
@match = Match.where(:id => params[:match]).includes(:wrestlers).first
|
||||||
@@ -50,8 +50,21 @@ class MatchesController < ApplicationController
|
|||||||
end
|
end
|
||||||
@tournament = @match.tournament
|
@tournament = @match.tournament
|
||||||
end
|
end
|
||||||
session[:return_path] = "/tournaments/#{@tournament.id}/matches"
|
if @match&.mat
|
||||||
session[:error_return_path] = "/matches/#{@match.id}/stat"
|
@mat = @match.mat
|
||||||
|
queue_position = @mat.queue_position_for_match(@match)
|
||||||
|
@next_match = queue_position == 1 ? @mat.queue2_match : nil
|
||||||
|
@show_next_bout_button = queue_position == 1
|
||||||
|
if request.referer&.include?("/tournaments/#{@tournament.id}/matches")
|
||||||
|
session[:return_path] = "/tournaments/#{@tournament.id}/matches"
|
||||||
|
else
|
||||||
|
session[:return_path] = mat_path(@mat)
|
||||||
|
end
|
||||||
|
session[:error_return_path] = "/matches/#{@match.id}/stat"
|
||||||
|
else
|
||||||
|
session[:return_path] = "/tournaments/#{@tournament.id}/matches"
|
||||||
|
session[:error_return_path] = "/matches/#{@match.id}/stat"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /matches/:id/spectate
|
# GET /matches/:id/spectate
|
||||||
@@ -71,6 +84,49 @@ class MatchesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# GET /matches/1/edit_assignment
|
||||||
|
def edit_assignment
|
||||||
|
@tournament = @match.tournament
|
||||||
|
@mats = @tournament.mats.sort_by(&:name)
|
||||||
|
@current_mat = @match.mat
|
||||||
|
@current_queue_position = @current_mat&.queue_position_for_match(@match)
|
||||||
|
session[:return_path] = "/tournaments/#{@tournament.id}/matches"
|
||||||
|
end
|
||||||
|
|
||||||
|
# PATCH /matches/1/update_assignment
|
||||||
|
def update_assignment
|
||||||
|
@tournament = @match.tournament
|
||||||
|
mat_id = params.dig(:match, :mat_id)
|
||||||
|
queue_position = params.dig(:match, :queue_position)
|
||||||
|
|
||||||
|
if mat_id.blank?
|
||||||
|
Mat.where("queue1 = :match_id OR queue2 = :match_id OR queue3 = :match_id OR queue4 = :match_id", match_id: @match.id)
|
||||||
|
.find_each { |mat| mat.remove_match_from_queue_and_collapse!(@match.id) }
|
||||||
|
@match.update(mat_id: nil)
|
||||||
|
redirect_to session.delete(:return_path) || "/tournaments/#{@tournament.id}/matches", notice: "Match assignment cleared."
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if queue_position.blank?
|
||||||
|
redirect_to edit_assignment_match_path(@match), alert: "Queue position is required when selecting a mat."
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
unless %w[1 2 3 4].include?(queue_position.to_s)
|
||||||
|
redirect_to edit_assignment_match_path(@match), alert: "Queue position must be between 1 and 4."
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
mat = @tournament.mats.find_by(id: mat_id)
|
||||||
|
unless mat
|
||||||
|
redirect_to edit_assignment_match_path(@match), alert: "Selected mat was not found."
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
mat.assign_match_to_queue!(@match, queue_position)
|
||||||
|
redirect_to session.delete(:return_path) || "/tournaments/#{@tournament.id}/matches", notice: "Match assignment updated."
|
||||||
|
end
|
||||||
|
|
||||||
# PATCH/PUT /matches/1
|
# PATCH/PUT /matches/1
|
||||||
# PATCH/PUT /matches/1.json
|
# PATCH/PUT /matches/1.json
|
||||||
def update
|
def update
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ class MatsController < ApplicationController
|
|||||||
|
|
||||||
if bout_number_param
|
if bout_number_param
|
||||||
@show_next_bout_button = false
|
@show_next_bout_button = false
|
||||||
@match = @mat.unfinished_matches.find { |m| m.bout_number == bout_number_param.to_i }
|
@match = @mat.queue_matches.compact.find { |m| m.bout_number == bout_number_param.to_i }
|
||||||
else
|
else
|
||||||
@show_next_bout_button = true
|
@show_next_bout_button = true
|
||||||
@match = @mat.unfinished_matches.first
|
@match = @mat.queue1_match
|
||||||
end
|
end
|
||||||
|
|
||||||
@next_match = @mat.unfinished_matches.second # Second unfinished match on the mat
|
@next_match = @mat.queue2_match # Second match on the mat
|
||||||
|
|
||||||
@wrestlers = []
|
@wrestlers = []
|
||||||
if @match
|
if @match
|
||||||
@@ -82,8 +82,8 @@ class MatsController < ApplicationController
|
|||||||
def assign_next_match
|
def assign_next_match
|
||||||
@tournament = @mat.tournament_id
|
@tournament = @mat.tournament_id
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @mat.assign_next_match
|
if @mat.advance_queue!
|
||||||
format.html { redirect_to "/tournaments/#{@mat.tournament.id}", notice: "Next Match on Mat #{@mat.name} successfully completed." }
|
format.html { redirect_to "/tournaments/#{@mat.tournament.id}", notice: "Mat #{@mat.name} queue advanced." }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
else
|
else
|
||||||
format.html { redirect_to "/tournaments/#{@mat.tournament.id}", alert: "There was an error." }
|
format.html { redirect_to "/tournaments/#{@mat.tournament.id}", alert: "There was an error." }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class TournamentsController < ApplicationController
|
class TournamentsController < ApplicationController
|
||||||
before_action :set_tournament, only: [:all_results, :delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:bout_sheets,:swap,:weigh_in_sheet,:error,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:generate_matches,:bracket,:all_brackets]
|
before_action :set_tournament, only: [:all_results, :delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:bout_sheets,:swap,:weigh_in_sheet,:error,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:remove_delegate,:school_delegate,:delegate,:matches,:weigh_in,:weigh_in_weight,:create_custom_weights,:show,:edit,:update,:destroy,:up_matches,:no_matches,:team_scores,:generate_matches,:bracket,:all_brackets,:qrcode]
|
||||||
before_action :check_access_manage, only: [:delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:swap,:weigh_in_sheet,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches]
|
before_action :check_access_manage, only: [:delete_school_keys, :generate_school_keys,:reset_bout_board,:calculate_team_scores,:swap,:weigh_in_sheet,:teampointadjust,:remove_teampointadjust,:remove_school_delegate,:school_delegate,:weigh_in,:weigh_in_weight,:create_custom_weights,:update,:edit,:generate_matches,:matches,:qrcode]
|
||||||
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
|
before_action :check_access_destroy, only: [:destroy,:delegate,:remove_delegate]
|
||||||
before_action :check_tournament_errors, only: [:generate_matches]
|
before_action :check_tournament_errors, only: [:generate_matches]
|
||||||
before_action :check_for_matches, only: [:all_results,:up_matches,:bracket,:all_brackets]
|
before_action :check_for_matches, only: [:all_results,:up_matches,:bracket,:all_brackets]
|
||||||
@@ -196,6 +196,11 @@ class TournamentsController < ApplicationController
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def qrcode
|
||||||
|
@tournament_url = tournament_url(@tournament)
|
||||||
|
@qrcode = RQRCode::QRCode.new(@tournament_url)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def up_matches
|
def up_matches
|
||||||
# .where.not(loser1_name: 'BYE') won't return matches with NULL loser1_name
|
# .where.not(loser1_name: 'BYE') won't return matches with NULL loser1_name
|
||||||
@@ -221,12 +226,26 @@ class TournamentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
if params[:search]
|
# Simple manual pagination to avoid introducing a gem.
|
||||||
# @tournaments = Tournament.limit(200).search(params[:search]).order("date DESC")
|
per_page = 20
|
||||||
@tournaments = Tournament.limit(200).search_date_name(params[:search]).order("date DESC")
|
page = params[:page].to_i > 0 ? params[:page].to_i : 1
|
||||||
|
offset = (page - 1) * per_page
|
||||||
|
|
||||||
|
if params[:search].present?
|
||||||
|
tournaments = Tournament.search_date_name(params[:search]).to_a
|
||||||
else
|
else
|
||||||
@tournaments = Tournament.all.sort_by{|t| t.days_until_start}.first(20)
|
tournaments = Tournament.all.to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Sort by distance from today (closest first)
|
||||||
|
today = Date.today
|
||||||
|
tournaments.sort_by! { |t| (t.date - today).abs }
|
||||||
|
|
||||||
|
@total_count = tournaments.size
|
||||||
|
@total_pages = (@total_count / per_page.to_f).ceil
|
||||||
|
@page = page
|
||||||
|
@per_page = per_page
|
||||||
|
@tournaments = tournaments.slice(offset, per_page) || []
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@@ -286,7 +305,7 @@ class TournamentsController < ApplicationController
|
|||||||
|
|
||||||
def reset_bout_board
|
def reset_bout_board
|
||||||
@tournament.reset_and_fill_bout_board
|
@tournament.reset_and_fill_bout_board
|
||||||
redirect_to tournament_path(@tournament), notice: "Successfully reset the bout board."
|
redirect_to tournament_path(@tournament), notice: "Successfully reset the bout board. Please have all mat table workers refresh their page."
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_school_keys
|
def generate_school_keys
|
||||||
|
|||||||
@@ -1,4 +1,20 @@
|
|||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
|
def hide_ads?
|
||||||
|
case controller_name
|
||||||
|
when "schools"
|
||||||
|
action_name == "show" && (user_signed_in? || school_permission_key_present?)
|
||||||
|
when "wrestlers"
|
||||||
|
%w[new edit].include?(action_name) && (user_signed_in? || school_permission_key_present?)
|
||||||
|
when "mats"
|
||||||
|
action_name == "show" && user_signed_in?
|
||||||
|
else
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def school_permission_key_present?
|
||||||
|
@school_permission_key.present? ||
|
||||||
|
params[:school_permission_key].present? ||
|
||||||
|
params.dig(:school, :school_permission_key).present?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
class AdvanceWrestlerJob < ApplicationJob
|
class AdvanceWrestlerJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
# associations are not available here so we had to pass tournament_id when creating the job
|
||||||
|
limits_concurrency to: 1, key: ->(_wrestler, _match, tournament_id) { "tournament:#{tournament_id}" }
|
||||||
|
|
||||||
def perform(wrestler, match)
|
def perform(wrestler, match, tournament_id)
|
||||||
# Add a small delay to increase chance of transaction commit
|
|
||||||
# without this some matches were getting a deserialization error when running the rake task
|
|
||||||
# to finish tournaments
|
|
||||||
sleep(0.5) unless Rails.env.test?
|
|
||||||
|
|
||||||
# Get tournament from wrestler
|
# Get tournament from wrestler
|
||||||
tournament = wrestler.tournament
|
tournament = wrestler.tournament
|
||||||
|
|
||||||
@@ -34,4 +31,4 @@ class AdvanceWrestlerJob < ApplicationJob
|
|||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class CalculateSchoolScoreJob < ApplicationJob
|
class CalculateSchoolScoreJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
limits_concurrency to: 1, key: ->(school) { "tournament:#{school.tournament_id}" }
|
||||||
|
|
||||||
# Need for TournamentJobStatusIntegrationTest
|
# Need for TournamentJobStatusIntegrationTest
|
||||||
def self.perform_sync(school)
|
def self.perform_sync(school)
|
||||||
@@ -35,4 +36,4 @@ class CalculateSchoolScoreJob < ApplicationJob
|
|||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class GenerateTournamentMatchesJob < ApplicationJob
|
class GenerateTournamentMatchesJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
limits_concurrency to: 1, key: ->(tournament) { "tournament:#{tournament.id}" }
|
||||||
|
|
||||||
def perform(tournament)
|
def perform(tournament)
|
||||||
# Log information about the job
|
# Log information about the job
|
||||||
@@ -17,4 +18,4 @@ class GenerateTournamentMatchesJob < ApplicationJob
|
|||||||
raise # Re-raise the error so it's properly recorded
|
raise # Re-raise the error so it's properly recorded
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class TournamentBackupJob < ApplicationJob
|
class TournamentBackupJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
limits_concurrency to: 1, key: ->(tournament, *) { "tournament:#{tournament.id}" }
|
||||||
|
|
||||||
def perform(tournament, reason = nil)
|
def perform(tournament, reason = nil)
|
||||||
# Log information about the job
|
# Log information about the job
|
||||||
@@ -29,4 +30,4 @@ class TournamentBackupJob < ApplicationJob
|
|||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ class TournamentCleanupJob < ApplicationJob
|
|||||||
has_real_matches = tournament.matches.where(finished: 1).where.not(win_type: 'BYE').exists?
|
has_real_matches = tournament.matches.where(finished: 1).where.not(win_type: 'BYE').exists?
|
||||||
|
|
||||||
if has_real_matches
|
if has_real_matches
|
||||||
|
tournament.tournament_backups.destroy_all
|
||||||
|
|
||||||
# 1. Remove all school delegates
|
# 1. Remove all school delegates
|
||||||
tournament.schools.each do |school|
|
tournament.schools.each do |school|
|
||||||
school.delegates.destroy_all
|
school.delegates.destroy_all
|
||||||
@@ -33,4 +34,4 @@ class TournamentCleanupJob < ApplicationJob
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class WrestlingdevImportJob < ApplicationJob
|
class WrestlingdevImportJob < ApplicationJob
|
||||||
queue_as :default
|
queue_as :default
|
||||||
|
limits_concurrency to: 1, key: ->(tournament, *) { "tournament:#{tournament.id}" }
|
||||||
|
|
||||||
def perform(tournament, import_data = nil)
|
def perform(tournament, import_data = nil)
|
||||||
# Log information about the job
|
# Log information about the job
|
||||||
@@ -30,4 +31,4 @@ class WrestlingdevImportJob < ApplicationJob
|
|||||||
raise e
|
raise e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,20 @@
|
|||||||
class Ability
|
class Ability
|
||||||
include CanCan::Ability
|
include CanCan::Ability
|
||||||
|
|
||||||
|
def school_permission_key_check(school_permission_key)
|
||||||
|
# Can read school if tournament is public or a valid school permission key is provided
|
||||||
|
can :read, School do |school|
|
||||||
|
school.tournament.is_public ||
|
||||||
|
(school_permission_key.present? && school.permission_key == school_permission_key)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Can manage school if a valid school permission key is provided
|
||||||
|
# school_permission_key comes from app/controllers/application_controller.rb
|
||||||
|
can :manage, School do |school|
|
||||||
|
(school_permission_key.present? && school.permission_key == school_permission_key)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def initialize(user, school_permission_key = nil)
|
def initialize(user, school_permission_key = nil)
|
||||||
if user
|
if user
|
||||||
# LOGGED IN USER PERMISSIONS
|
# LOGGED IN USER PERMISSIONS
|
||||||
@@ -46,6 +60,8 @@ class Ability
|
|||||||
school.tournament.delegates.map(&:user_id).include?(user.id) ||
|
school.tournament.delegates.map(&:user_id).include?(user.id) ||
|
||||||
school.tournament.user_id == user.id
|
school.tournament.user_id == user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
school_permission_key_check(school_permission_key)
|
||||||
else
|
else
|
||||||
# NON LOGGED IN USER PERMISSIONS
|
# NON LOGGED IN USER PERMISSIONS
|
||||||
|
|
||||||
@@ -58,18 +74,7 @@ class Ability
|
|||||||
|
|
||||||
# SCHOOL PERMISSIONS
|
# SCHOOL PERMISSIONS
|
||||||
# wrestler permissions are included with school permissions
|
# wrestler permissions are included with school permissions
|
||||||
|
school_permission_key_check(school_permission_key)
|
||||||
# Can read school if tournament is public or a valid school permission key is provided
|
|
||||||
can :read, School do |school|
|
|
||||||
school.tournament.is_public ||
|
|
||||||
(school_permission_key.present? && school.permission_key == school_permission_key)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Can read school if a valid school permission key is provided
|
|
||||||
# school_permission_key comes from app/controllers/application_controller.rb
|
|
||||||
can :manage, School do |school|
|
|
||||||
(school_permission_key.present? && school.permission_key == school_permission_key)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,53 +1,52 @@
|
|||||||
class Mat < ApplicationRecord
|
class Mat < ApplicationRecord
|
||||||
|
include ActionView::RecordIdentifier
|
||||||
belongs_to :tournament
|
belongs_to :tournament
|
||||||
has_many :matches, dependent: :destroy
|
has_many :matches, dependent: :nullify
|
||||||
has_many :mat_assignment_rules, dependent: :destroy
|
has_many :mat_assignment_rules, dependent: :destroy
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|
||||||
before_destroy do
|
QUEUE_SLOTS = %w[queue1 queue2 queue3 queue4].freeze
|
||||||
if tournament.matches.size > 0
|
|
||||||
tournament.reset_mats
|
|
||||||
matsToAssign = tournament.mats.select{|m| m.id != self.id}
|
|
||||||
tournament.assign_mats(matsToAssign)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
after_create do
|
after_save :clear_queue_matches_cache
|
||||||
if tournament.matches.size > 0
|
|
||||||
tournament.reset_mats
|
|
||||||
matsToAssign = tournament.mats
|
|
||||||
tournament.assign_mats(matsToAssign)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def assign_next_match
|
def assign_next_match
|
||||||
|
slot = first_empty_queue_slot
|
||||||
|
return true unless slot
|
||||||
|
|
||||||
match = next_eligible_match
|
match = next_eligible_match
|
||||||
self.matches.reload
|
return false unless match
|
||||||
if match and self.unfinished_matches.size < 4
|
|
||||||
match.mat_id = self.id
|
place_match_in_empty_slot!(match, slot)
|
||||||
if match.save
|
true
|
||||||
# Invalidate any wrestler caches
|
end
|
||||||
if match.w1
|
|
||||||
match.wrestler1.touch
|
def advance_queue!(finished_match = nil)
|
||||||
match.wrestler1.school.touch
|
self.class.transaction do
|
||||||
|
if finished_match
|
||||||
|
position = queue_position_for_match(finished_match)
|
||||||
|
if position == 1
|
||||||
|
shift_queue_forward!
|
||||||
|
fill_queue_slots!
|
||||||
|
elsif position
|
||||||
|
remove_match_from_queue_and_collapse!(finished_match.id)
|
||||||
|
else
|
||||||
|
fill_queue_slots!
|
||||||
end
|
end
|
||||||
if match.w2
|
|
||||||
match.wrestler2.touch
|
|
||||||
match.wrestler2.school.touch
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
return false
|
if queue1_match&.finished == 1
|
||||||
|
shift_queue_forward!
|
||||||
|
end
|
||||||
|
fill_queue_slots!
|
||||||
end
|
end
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
broadcast_current_match
|
||||||
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_eligible_match
|
def next_eligible_match
|
||||||
# Start with all matches that are either unfinished (nil or 0), have a bout number, and are ordered by bout_number
|
# Start with all matches that are either unfinished (nil or 0), have a bout number, and are ordered by bout_number
|
||||||
filtered_matches = tournament.matches
|
filtered_matches = Match.where(tournament_id: tournament_id)
|
||||||
.where(finished: [nil, 0]) # finished is nil or 0
|
.where(finished: [nil, 0]) # finished is nil or 0
|
||||||
.where(mat_id: nil) # mat_id is nil
|
.where(mat_id: nil) # mat_id is nil
|
||||||
.where.not(bout_number: nil) # bout_number is not nil
|
.where.not(bout_number: nil) # bout_number is not nil
|
||||||
@@ -57,6 +56,11 @@ class Mat < ApplicationRecord
|
|||||||
filtered_matches = filtered_matches
|
filtered_matches = filtered_matches
|
||||||
.where("loser1_name != ? OR loser1_name IS NULL", "BYE")
|
.where("loser1_name != ? OR loser1_name IS NULL", "BYE")
|
||||||
.where("loser2_name != ? OR loser2_name IS NULL", "BYE")
|
.where("loser2_name != ? OR loser2_name IS NULL", "BYE")
|
||||||
|
|
||||||
|
# Filter out matches without a wrestlers
|
||||||
|
filtered_matches = filtered_matches
|
||||||
|
.where("w1 IS NOT NULL")
|
||||||
|
.where("w2 IS NOT NULL")
|
||||||
|
|
||||||
# Apply mat assignment rules
|
# Apply mat assignment rules
|
||||||
mat_assignment_rules.each do |rule|
|
mat_assignment_rules.each do |rule|
|
||||||
@@ -80,9 +84,194 @@ class Mat < ApplicationRecord
|
|||||||
filtered_matches.first
|
filtered_matches.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def queue_match_ids
|
||||||
|
QUEUE_SLOTS.map { |slot| public_send(slot) }
|
||||||
|
end
|
||||||
|
|
||||||
|
# used to prevent N+1 query on each mat
|
||||||
|
def queue_matches
|
||||||
|
slot_ids = queue_match_ids
|
||||||
|
if @queue_matches.nil? || @queue_match_slot_ids != slot_ids
|
||||||
|
ids = slot_ids.compact
|
||||||
|
@queue_matches = if ids.empty?
|
||||||
|
[nil, nil, nil, nil]
|
||||||
|
else
|
||||||
|
matches_by_id = Match.where(id: ids).index_by(&:id)
|
||||||
|
slot_ids.map { |match_id| match_id ? matches_by_id[match_id] : nil }
|
||||||
|
end
|
||||||
|
@queue_match_slot_ids = slot_ids
|
||||||
|
end
|
||||||
|
@queue_matches
|
||||||
|
end
|
||||||
|
|
||||||
|
def queue1_match
|
||||||
|
queue_match_at(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
def queue2_match
|
||||||
|
queue_match_at(2)
|
||||||
|
end
|
||||||
|
|
||||||
|
def queue3_match
|
||||||
|
queue_match_at(3)
|
||||||
|
end
|
||||||
|
|
||||||
|
def queue4_match
|
||||||
|
queue_match_at(4)
|
||||||
|
end
|
||||||
|
|
||||||
|
def queue_position_for_match(match)
|
||||||
|
return nil unless match
|
||||||
|
return 1 if queue1 == match.id
|
||||||
|
return 2 if queue2 == match.id
|
||||||
|
return 3 if queue3 == match.id
|
||||||
|
return 4 if queue4 == match.id
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_match_from_queue_and_collapse!(match_id)
|
||||||
|
queue_ids = queue_match_ids
|
||||||
|
return if queue_ids.none? { |id| id == match_id }
|
||||||
|
|
||||||
|
queue_ids.map! { |id| id == match_id ? nil : id }
|
||||||
|
queue_ids = queue_ids.compact
|
||||||
|
queue_ids += [nil] * (4 - queue_ids.size)
|
||||||
|
|
||||||
|
update!(
|
||||||
|
queue1: queue_ids[0],
|
||||||
|
queue2: queue_ids[1],
|
||||||
|
queue3: queue_ids[2],
|
||||||
|
queue4: queue_ids[3]
|
||||||
|
)
|
||||||
|
|
||||||
|
fill_queue_slots!
|
||||||
|
broadcast_current_match
|
||||||
|
end
|
||||||
|
|
||||||
|
def assign_match_to_queue!(match, position)
|
||||||
|
position = position.to_i
|
||||||
|
raise ArgumentError, "Queue position must be 1-4" unless (1..4).cover?(position)
|
||||||
|
|
||||||
|
self.class.transaction do
|
||||||
|
match.update!(mat_id: id)
|
||||||
|
remove_match_from_other_mats!(match.id)
|
||||||
|
|
||||||
|
queue_ids = queue_match_ids.map { |id| id == match.id ? nil : id }
|
||||||
|
queue_ids = queue_ids.compact
|
||||||
|
|
||||||
|
queue_ids.insert(position - 1, match.id)
|
||||||
|
bumped_match_id = queue_ids.length > 4 ? queue_ids.pop : nil
|
||||||
|
|
||||||
|
queue_ids += [nil] * (4 - queue_ids.length)
|
||||||
|
|
||||||
|
update!(
|
||||||
|
queue1: queue_ids[0],
|
||||||
|
queue2: queue_ids[1],
|
||||||
|
queue3: queue_ids[2],
|
||||||
|
queue4: queue_ids[3]
|
||||||
|
)
|
||||||
|
|
||||||
|
bumped_match = Match.find_by(id: bumped_match_id)
|
||||||
|
if bumped_match && bumped_match.finished != 1
|
||||||
|
bumped_match.update!(mat_id: nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
broadcast_current_match
|
||||||
|
end
|
||||||
|
|
||||||
|
def clear_queue!
|
||||||
|
update!(queue1: nil, queue2: nil, queue3: nil, queue4: nil)
|
||||||
|
end
|
||||||
|
|
||||||
def unfinished_matches
|
def unfinished_matches
|
||||||
matches.select{|m| m.finished != 1}.sort_by{|m| m.bout_number}
|
matches.select{|m| m.finished != 1}.sort_by{|m| m.bout_number}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def clear_queue_matches_cache
|
||||||
|
@queue_matches = nil
|
||||||
|
@queue_match_slot_ids = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def queue_match_at(position)
|
||||||
|
queue_matches[position - 1]
|
||||||
|
end
|
||||||
|
|
||||||
|
def first_empty_queue_slot
|
||||||
|
QUEUE_SLOTS.each_with_index do |slot, index|
|
||||||
|
return index + 1 if public_send(slot).nil?
|
||||||
|
end
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def shift_queue_forward!
|
||||||
|
update!(
|
||||||
|
queue1: queue2,
|
||||||
|
queue2: queue3,
|
||||||
|
queue3: queue4,
|
||||||
|
queue4: nil
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fill_queue_slots!
|
||||||
|
queue_ids = queue_match_ids
|
||||||
|
updated = false
|
||||||
|
|
||||||
|
QUEUE_SLOTS.each_with_index do |_slot, index|
|
||||||
|
next if queue_ids[index].present?
|
||||||
|
|
||||||
|
match = next_eligible_match
|
||||||
|
break unless match
|
||||||
|
|
||||||
|
queue_ids[index] = match.id
|
||||||
|
match.update!(mat_id: id)
|
||||||
|
updated = true
|
||||||
|
end
|
||||||
|
|
||||||
|
if updated
|
||||||
|
update!(
|
||||||
|
queue1: queue_ids[0],
|
||||||
|
queue2: queue_ids[1],
|
||||||
|
queue3: queue_ids[2],
|
||||||
|
queue4: queue_ids[3]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_match_from_other_mats!(match_id)
|
||||||
|
self.class.where.not(id: id)
|
||||||
|
.where("queue1 = :match_id OR queue2 = :match_id OR queue3 = :match_id OR queue4 = :match_id", match_id: match_id)
|
||||||
|
.find_each do |mat|
|
||||||
|
mat.remove_match_from_queue_and_collapse!(match_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def place_match_in_empty_slot!(match, slot)
|
||||||
|
self.class.transaction do
|
||||||
|
match.update!(mat_id: id)
|
||||||
|
remove_match_from_other_mats!(match.id)
|
||||||
|
update!(slot_key(slot) => match.id)
|
||||||
|
end
|
||||||
|
broadcast_current_match
|
||||||
|
end
|
||||||
|
|
||||||
|
def slot_key(slot)
|
||||||
|
"queue#{slot}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def broadcast_current_match
|
||||||
|
Turbo::StreamsChannel.broadcast_update_to(
|
||||||
|
self,
|
||||||
|
target: dom_id(self, :current_match),
|
||||||
|
partial: "mats/current_match",
|
||||||
|
locals: {
|
||||||
|
mat: self,
|
||||||
|
match: queue1_match,
|
||||||
|
next_match: queue2_match,
|
||||||
|
show_next_bout_button: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class Match < ApplicationRecord
|
class Match < ApplicationRecord
|
||||||
|
include ActionView::RecordIdentifier
|
||||||
|
|
||||||
belongs_to :tournament, touch: true
|
belongs_to :tournament, touch: true
|
||||||
belongs_to :weight, touch: true
|
belongs_to :weight, touch: true
|
||||||
belongs_to :mat, touch: true, optional: true
|
belongs_to :mat, touch: true, optional: true
|
||||||
@@ -10,12 +12,21 @@ class Match < ApplicationRecord
|
|||||||
# Callback to update finished_at when a match is finished
|
# Callback to update finished_at when a match is finished
|
||||||
before_save :update_finished_at
|
before_save :update_finished_at
|
||||||
|
|
||||||
after_update :after_finished_actions, if: -> {
|
# update mat show with correct match if bout board is reset
|
||||||
saved_change_to_finished? ||
|
# this is done with a turbo stream
|
||||||
saved_change_to_winner_id? ||
|
after_commit :broadcast_mat_assignment_change, if: :saved_change_to_mat_id?, on: [:create, :update]
|
||||||
saved_change_to_win_type? ||
|
|
||||||
saved_change_to_score? ||
|
# Enqueue advancement and related actions after the DB transaction has committed.
|
||||||
saved_change_to_overtime_type?
|
# Using after_commit ensures any background jobs enqueued inside these callbacks
|
||||||
|
# will see the committed state of the match (e.g. finished == 1). Enqueuing
|
||||||
|
# jobs from after_update can cause jobs to run before the transaction commits,
|
||||||
|
# which leads to jobs observing stale data and not performing advancement.
|
||||||
|
after_commit :after_finished_actions, on: :update, if: -> {
|
||||||
|
saved_change_to_finished? ||
|
||||||
|
saved_change_to_winner_id? ||
|
||||||
|
saved_change_to_win_type? ||
|
||||||
|
saved_change_to_score? ||
|
||||||
|
saved_change_to_overtime_type?
|
||||||
}
|
}
|
||||||
|
|
||||||
def after_finished_actions
|
def after_finished_actions
|
||||||
@@ -26,11 +37,14 @@ class Match < ApplicationRecord
|
|||||||
wrestler2.touch
|
wrestler2.touch
|
||||||
end
|
end
|
||||||
if self.finished == 1 && self.winner_id != nil
|
if self.finished == 1 && self.winner_id != nil
|
||||||
if self.mat
|
|
||||||
self.mat.assign_next_match
|
|
||||||
end
|
|
||||||
advance_wrestlers
|
advance_wrestlers
|
||||||
calculate_school_points
|
if self.mat
|
||||||
|
self.mat.advance_queue!(self)
|
||||||
|
end
|
||||||
|
self.tournament.refill_open_bout_board_queues
|
||||||
|
# School point calculation has move to the end of advance wrestler
|
||||||
|
# calculate_school_points
|
||||||
|
self.update(mat_id: nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -44,7 +58,7 @@ class Match < ApplicationRecord
|
|||||||
errors.add(:winner_id, "cannot be blank")
|
errors.add(:winner_id, "cannot be blank")
|
||||||
end
|
end
|
||||||
if win_type == "Pin" and ! score.match(/^[0-5]?[0-9]:[0-5][0-9]/)
|
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")
|
errors.add(:score, "needs to be in time format MM:SS when win type is Pin example: 2:23, 0:25, 10:03")
|
||||||
end
|
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]/)
|
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")
|
errors.add(:score, "needs to be in Number-Number format when win type is Decision, Tech Fall, and Major example: 10-2")
|
||||||
@@ -189,6 +203,7 @@ class Match < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def w1_bracket_name
|
def w1_bracket_name
|
||||||
|
first_round = self.weight.matches.sort_by{|m| m.round}.first.round
|
||||||
return_string = ""
|
return_string = ""
|
||||||
return_string_ending = ""
|
return_string_ending = ""
|
||||||
if self.w1 and self.winner_id == self.w1
|
if self.w1 and self.winner_id == self.w1
|
||||||
@@ -196,7 +211,7 @@ class Match < ApplicationRecord
|
|||||||
return_string_ending = return_string_ending + "</strong>"
|
return_string_ending = return_string_ending + "</strong>"
|
||||||
end
|
end
|
||||||
if self.w1 != nil
|
if self.w1 != nil
|
||||||
if self.round == 1
|
if self.round == first_round
|
||||||
return_string = return_string + "#{wrestler1.long_bracket_name}"
|
return_string = return_string + "#{wrestler1.long_bracket_name}"
|
||||||
else
|
else
|
||||||
return_string = return_string + "#{wrestler1.short_bracket_name}"
|
return_string = return_string + "#{wrestler1.short_bracket_name}"
|
||||||
@@ -208,6 +223,7 @@ class Match < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def w2_bracket_name
|
def w2_bracket_name
|
||||||
|
first_round = self.weight.matches.sort_by{|m| m.round}.first.round
|
||||||
return_string = ""
|
return_string = ""
|
||||||
return_string_ending = ""
|
return_string_ending = ""
|
||||||
if self.w2 and self.winner_id == self.w2
|
if self.w2 and self.winner_id == self.w2
|
||||||
@@ -215,7 +231,7 @@ class Match < ApplicationRecord
|
|||||||
return_string_ending = return_string_ending + "</strong>"
|
return_string_ending = return_string_ending + "</strong>"
|
||||||
end
|
end
|
||||||
if self.w2 != nil
|
if self.w2 != nil
|
||||||
if self.round == 1
|
if self.round == first_round
|
||||||
return_string = return_string + "#{wrestler2.long_bracket_name}"
|
return_string = return_string + "#{wrestler2.long_bracket_name}"
|
||||||
else
|
else
|
||||||
return_string = return_string + "#{wrestler2.short_bracket_name}"
|
return_string = return_string + "#{wrestler2.short_bracket_name}"
|
||||||
@@ -328,4 +344,26 @@ class Match < ApplicationRecord
|
|||||||
self.finished_at = Time.current.utc
|
self.finished_at = Time.current.utc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def broadcast_mat_assignment_change
|
||||||
|
old_mat_id, new_mat_id = saved_change_to_mat_id || previous_changes["mat_id"]
|
||||||
|
return unless old_mat_id || new_mat_id
|
||||||
|
|
||||||
|
[old_mat_id, new_mat_id].compact.uniq.each do |mat_id|
|
||||||
|
mat = Mat.find_by(id: mat_id)
|
||||||
|
next unless mat
|
||||||
|
|
||||||
|
Turbo::StreamsChannel.broadcast_update_to(
|
||||||
|
mat,
|
||||||
|
target: dom_id(mat, :current_match),
|
||||||
|
partial: "mats/current_match",
|
||||||
|
locals: {
|
||||||
|
mat: mat,
|
||||||
|
match: mat.queue1_match,
|
||||||
|
next_match: mat.queue2_match,
|
||||||
|
show_next_bout_button: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -82,23 +82,18 @@ class Tournament < ApplicationRecord
|
|||||||
matches.maximum(:round) || 0 # Return 0 if no matches or max round is nil
|
matches.maximum(:round) || 0 # Return 0 if no matches or max round is nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def assign_mats(mats_to_assign)
|
|
||||||
if mats_to_assign.count > 0
|
|
||||||
until mats_to_assign.sort_by{|m| m.id}.last.matches.count == 4
|
|
||||||
mats_to_assign.sort_by{|m| m.id}.each do |m|
|
|
||||||
m.assign_next_match
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def reset_mats
|
def reset_mats
|
||||||
|
matches.reload
|
||||||
|
mats.reload
|
||||||
matches_to_reset = matches.select{|m| m.mat_id != nil}
|
matches_to_reset = matches.select{|m| m.mat_id != nil}
|
||||||
# matches_to_reset.update_all( {:mat_id => nil } )
|
# matches_to_reset.update_all( {:mat_id => nil } )
|
||||||
matches_to_reset.each do |m|
|
matches_to_reset.each do |m|
|
||||||
m.mat_id = nil
|
m.mat_id = nil
|
||||||
m.save
|
m.save
|
||||||
end
|
end
|
||||||
|
mats.each do |mat|
|
||||||
|
mat.clear_queue!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pointAdjustments
|
def pointAdjustments
|
||||||
@@ -156,14 +151,14 @@ class Tournament < ApplicationRecord
|
|||||||
|
|
||||||
def double_elim_number_of_wrestlers_error
|
def double_elim_number_of_wrestlers_error
|
||||||
error_string = ""
|
error_string = ""
|
||||||
if self.tournament_type == "Double Elimination 1-6" or self.tournament_type == "Double Elimination 1-8"
|
if self.tournament_type == "Regular Double Elimination 1-6" or self.tournament_type == "Regular Double Elimination 1-8"
|
||||||
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 32}
|
weights_with_too_many_wrestlers = weights.select{|w| w.wrestlers.size > 64}
|
||||||
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 4}
|
weight_with_too_few_wrestlers = weights.select{|w| w.wrestlers.size < 2}
|
||||||
weights_with_too_many_wrestlers.each do |weight|
|
weights_with_too_many_wrestlers.each do |weight|
|
||||||
error_string = error_string + " The weight class #{weight.max} has more than 16 wrestlers."
|
error_string = error_string + " The weight class #{weight.max} has more than 64 wrestlers."
|
||||||
end
|
end
|
||||||
weight_with_too_few_wrestlers.each do |weight|
|
weight_with_too_few_wrestlers.each do |weight|
|
||||||
error_string = error_string + " The weight class #{weight.max} has less than 4 wrestlers."
|
error_string = error_string + " The weight class #{weight.max} has less than 2 wrestlers."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return error_string
|
return error_string
|
||||||
@@ -228,19 +223,24 @@ class Tournament < ApplicationRecord
|
|||||||
|
|
||||||
def reset_and_fill_bout_board
|
def reset_and_fill_bout_board
|
||||||
reset_mats
|
reset_mats
|
||||||
|
matches.reload
|
||||||
if mats.any?
|
refill_open_bout_board_queues
|
||||||
4.times do
|
end
|
||||||
# Iterate over each mat and assign the next available match
|
|
||||||
mats.each do |mat|
|
def refill_open_bout_board_queues
|
||||||
match_assigned = mat.assign_next_match
|
return unless mats.any?
|
||||||
# If no more matches are available, exit early
|
|
||||||
unless match_assigned
|
loop do
|
||||||
puts "No more eligible matches to assign."
|
assigned_any = false
|
||||||
return
|
# Fill in round-robin order by queue depth:
|
||||||
end
|
# all mats queue1 first, then queue2, then queue3, then queue4.
|
||||||
|
(1..4).each do |slot|
|
||||||
|
mats.reload.each do |mat|
|
||||||
|
next unless mat.public_send("queue#{slot}").nil?
|
||||||
|
assigned_any ||= mat.assign_next_match
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
break unless assigned_any
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -279,4 +279,4 @@ class Tournament < ApplicationRecord
|
|||||||
def connection_adapter
|
def connection_adapter
|
||||||
ActiveRecord::Base.connection.adapter_name
|
ActiveRecord::Base.connection.adapter_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,9 +2,13 @@ class Wrestler < ApplicationRecord
|
|||||||
belongs_to :school, touch: true
|
belongs_to :school, touch: true
|
||||||
belongs_to :weight, touch: true
|
belongs_to :weight, touch: true
|
||||||
has_one :tournament, through: :weight
|
has_one :tournament, through: :weight
|
||||||
|
has_many :deductedPoints, class_name: "Teampointadjust", dependent: :destroy
|
||||||
|
## Matches association
|
||||||
|
# Rails associations expect only a single column so we cannot do a w1 OR w2
|
||||||
|
# So we have to create two associations and combine them with the all_matches method
|
||||||
has_many :matches_as_w1, ->(wrestler){ where(weight_id: wrestler.weight_id) }, class_name: 'Match', foreign_key: 'w1'
|
has_many :matches_as_w1, ->(wrestler){ where(weight_id: wrestler.weight_id) }, class_name: 'Match', foreign_key: 'w1'
|
||||||
has_many :matches_as_w2, ->(wrestler){ where(weight_id: wrestler.weight_id) }, class_name: 'Match', foreign_key: 'w2'
|
has_many :matches_as_w2, ->(wrestler){ where(weight_id: wrestler.weight_id) }, class_name: 'Match', foreign_key: 'w2'
|
||||||
has_many :deductedPoints, class_name: "Teampointadjust", dependent: :destroy
|
##
|
||||||
attr_accessor :poolAdvancePoints, :originalId, :swapId
|
attr_accessor :poolAdvancePoints, :originalId, :swapId
|
||||||
|
|
||||||
validates :name, :weight_id, :school_id, presence: true
|
validates :name, :weight_id, :school_id, presence: true
|
||||||
|
|||||||
@@ -8,16 +8,18 @@ class AdvanceWrestler
|
|||||||
def advance
|
def advance
|
||||||
# Use perform_later which will execute based on centralized adapter config
|
# Use perform_later which will execute based on centralized adapter config
|
||||||
# This will be converted to inline execution in test environment by ActiveJob
|
# This will be converted to inline execution in test environment by ActiveJob
|
||||||
AdvanceWrestlerJob.perform_later(@wrestler, @last_match)
|
AdvanceWrestlerJob.perform_later(@wrestler, @last_match, @tournament.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def advance_raw
|
def advance_raw
|
||||||
|
@last_match.reload
|
||||||
|
@wrestler.reload
|
||||||
if @last_match && @last_match.finished?
|
if @last_match && @last_match.finished?
|
||||||
pool_to_bracket_advancement if @tournament.tournament_type == "Pool to bracket"
|
pool_to_bracket_advancement if @tournament.tournament_type == "Pool to bracket"
|
||||||
ModifiedDoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
|
ModifiedDoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type.include? "Modified 16 Man Double Elimination"
|
||||||
DoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type.include? "Regular Double Elimination"
|
DoubleEliminationAdvance.new(@wrestler, @last_match).bracket_advancement if @tournament.tournament_type.include? "Regular Double Elimination"
|
||||||
end
|
end
|
||||||
|
@wrestler.school.calculate_score
|
||||||
end
|
end
|
||||||
|
|
||||||
def pool_to_bracket_advancement
|
def pool_to_bracket_advancement
|
||||||
@@ -27,4 +29,4 @@ class AdvanceWrestler
|
|||||||
PoolAdvance.new(@wrestler).advanceWrestler
|
PoolAdvance.new(@wrestler).advanceWrestler
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,130 +3,206 @@ class DoubleEliminationGenerateLoserNames
|
|||||||
@tournament = tournament
|
@tournament = tournament
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Entry point: assign loser placeholders and advance any byes
|
||||||
def assign_loser_names
|
def assign_loser_names
|
||||||
@tournament.weights.each do |weight|
|
@tournament.weights.each do |weight|
|
||||||
assign_loser_names_for_weight(weight)
|
# only assign loser names if there's conso matches to be had
|
||||||
advance_bye_matches_championship(weight.matches.reload)
|
if weight.calculate_bracket_size > 2
|
||||||
|
assign_loser_names_for_weight(weight)
|
||||||
|
advance_bye_matches_championship(weight)
|
||||||
|
advance_bye_matches_consolation(weight)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def define_losername_championship_mappings(bracket_size)
|
private
|
||||||
# Use hashes instead of arrays for mappings
|
|
||||||
case bracket_size
|
|
||||||
when 4
|
|
||||||
[
|
|
||||||
{ conso_bracket_position: "3/4", championship_bracket_position: "Semis", cross_bracket: false, both_wrestlers: true }
|
|
||||||
]
|
|
||||||
when 8
|
|
||||||
[
|
|
||||||
{ conso_bracket_position: "Conso Quarter", championship_bracket_position: "Quarter", cross_bracket: false, both_wrestlers: true },
|
|
||||||
{ conso_bracket_position: "Conso Semis", championship_bracket_position: "Semis", cross_bracket: true, both_wrestlers: false }
|
|
||||||
]
|
|
||||||
when 16
|
|
||||||
[
|
|
||||||
{ conso_bracket_position: "Conso Round of 8.1", championship_bracket_position: "Bracket Round of 16", cross_bracket: false, both_wrestlers: true },
|
|
||||||
{ conso_bracket_position: "Conso Round of 8.2", championship_bracket_position: "Quarter", cross_bracket: true, both_wrestlers: false },
|
|
||||||
{ conso_bracket_position: "Conso Semis", championship_bracket_position: "Semis", cross_bracket: false, both_wrestlers: false }
|
|
||||||
]
|
|
||||||
when 32
|
|
||||||
[
|
|
||||||
{ conso_bracket_position: "Conso Round of 16.1", championship_bracket_position: "Bracket Round of 32", cross_bracket: false, both_wrestlers: true },
|
|
||||||
{ conso_bracket_position: "Conso Round of 16.2", championship_bracket_position: "Bracket Round of 16", cross_bracket: true, both_wrestlers: false },
|
|
||||||
{ conso_bracket_position: "Conso Round of 8.2", championship_bracket_position: "Quarter", cross_bracket: false, both_wrestlers: false },
|
|
||||||
{ conso_bracket_position: "Conso Semis", championship_bracket_position: "Semis", cross_bracket: true, both_wrestlers: false },
|
|
||||||
|
|
||||||
]
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
# Assign loser names for a single weight bracket
|
||||||
def assign_loser_names_for_weight(weight)
|
def assign_loser_names_for_weight(weight)
|
||||||
number_of_placers = @tournament.number_of_placers
|
|
||||||
bracket_size = weight.calculate_bracket_size
|
bracket_size = weight.calculate_bracket_size
|
||||||
matches_by_weight = weight.matches.reload
|
matches = weight.matches.reload
|
||||||
|
num_placers = @tournament.number_of_placers
|
||||||
|
|
||||||
loser_name_championship_mappings = define_losername_championship_mappings(bracket_size)
|
# Build dynamic round definitions
|
||||||
|
champ_rounds = dynamic_championship_rounds(bracket_size)
|
||||||
|
conso_rounds = dynamic_consolation_rounds(bracket_size)
|
||||||
|
first_round = { bracket_position: first_round_label(bracket_size) }
|
||||||
|
champ_full = [first_round] + champ_rounds
|
||||||
|
|
||||||
loser_name_championship_mappings.each do |mapping|
|
# Map championship losers into consolation slots
|
||||||
conso_bracket_position = mapping[:conso_bracket_position]
|
mappings = []
|
||||||
championship_bracket_position = mapping[:championship_bracket_position]
|
champ_full[0...-1].each_with_index do |champ_info, i|
|
||||||
cross_bracket = mapping[:cross_bracket]
|
map_idx = i.zero? ? 0 : (2 * i - 1)
|
||||||
both_wrestlers = mapping[:both_wrestlers]
|
next if map_idx < 0 || map_idx >= conso_rounds.size
|
||||||
|
|
||||||
conso_matches = matches_by_weight.select do |match|
|
mappings << {
|
||||||
match.bracket_position == conso_bracket_position && match.bracket_position == conso_bracket_position
|
championship_bracket_position: champ_info[:bracket_position],
|
||||||
end.sort_by(&:bracket_position_number)
|
consolation_bracket_position: conso_rounds[map_idx][:bracket_position],
|
||||||
|
both_wrestlers: i.zero?,
|
||||||
|
champ_round_index: i
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
championship_matches = matches_by_weight.select do |match|
|
# Apply loser-name mappings
|
||||||
match.bracket_position == championship_bracket_position && match.bracket_position == championship_bracket_position
|
mappings.each do |map|
|
||||||
end.sort_by(&:bracket_position_number)
|
champ = matches.select { |m| m.bracket_position == map[:championship_bracket_position] }
|
||||||
|
.sort_by(&:bracket_position_number)
|
||||||
|
conso = matches.select { |m| m.bracket_position == map[:consolation_bracket_position] }
|
||||||
|
.sort_by(&:bracket_position_number)
|
||||||
|
|
||||||
|
current_champ_round_index = map[:champ_round_index]
|
||||||
|
if current_champ_round_index.odd?
|
||||||
|
conso.reverse!
|
||||||
|
end
|
||||||
|
|
||||||
conso_matches.reverse! if cross_bracket
|
idx = 0
|
||||||
|
# Determine if this mapping is for losers from the first championship round
|
||||||
|
is_first_champ_round_feed = map[:champ_round_index].zero?
|
||||||
|
|
||||||
championship_bracket_position_number = 1
|
conso.each do |cm|
|
||||||
conso_matches.each do |match|
|
champ_match1 = champ[idx]
|
||||||
bout_number1 = championship_matches.find do |bout_match|
|
if champ_match1
|
||||||
bout_match.bracket_position_number == championship_bracket_position_number
|
if is_first_champ_round_feed && ((champ_match1.w1 && champ_match1.w2.nil?) || (champ_match1.w1.nil? && champ_match1.w2))
|
||||||
end.bout_number
|
cm.loser1_name = "BYE"
|
||||||
|
else
|
||||||
match.loser1_name = "Loser of #{bout_number1}"
|
cm.loser1_name = "Loser of #{champ_match1.bout_number}"
|
||||||
if both_wrestlers
|
end
|
||||||
championship_bracket_position_number += 1
|
else
|
||||||
bout_number2 = championship_matches.find do |bout_match|
|
cm.loser1_name = nil # Should not happen if bracket generation is correct
|
||||||
bout_match.bracket_position_number == championship_bracket_position_number
|
|
||||||
end.bout_number
|
|
||||||
match.loser2_name = "Loser of #{bout_number2}"
|
|
||||||
end
|
end
|
||||||
championship_bracket_position_number += 1
|
|
||||||
|
if map[:both_wrestlers] # This is true only if is_first_champ_round_feed
|
||||||
|
idx += 1 # Increment for the second championship match
|
||||||
|
champ_match2 = champ[idx]
|
||||||
|
if champ_match2
|
||||||
|
# BYE check is only relevant for the first championship round feed
|
||||||
|
if is_first_champ_round_feed && ((champ_match2.w1 && champ_match2.w2.nil?) || (champ_match2.w1.nil? && champ_match2.w2))
|
||||||
|
cm.loser2_name = "BYE"
|
||||||
|
else
|
||||||
|
cm.loser2_name = "Loser of #{champ_match2.bout_number}"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
cm.loser2_name = nil # Should not happen
|
||||||
|
end
|
||||||
|
end
|
||||||
|
idx += 1 # Increment for the next consolation match or next pair from championship
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
conso_semi_matches = matches_by_weight.select { |match| match.bracket_position == "Conso Semis" }
|
# 5th/6th place
|
||||||
conso_quarter_matches = matches_by_weight.select { |match| match.bracket_position == "Conso Quarter" }
|
if bracket_size >= 5 && num_placers >= 6 && weight.wrestlers.size > 4
|
||||||
|
conso_semis = matches.select { |m| m.bracket_position == "Conso Semis" }
|
||||||
if number_of_placers >= 6 && weight.wrestlers.size >= 5
|
.sort_by(&:bracket_position_number)
|
||||||
five_six_match = matches_by_weight.find { |match| match.bracket_position == "5/6" }
|
if conso_semis.size >= 2
|
||||||
bout_number1 = conso_semi_matches.find { |match| match.bracket_position_number == 1 }.bout_number
|
m56 = matches.find { |m| m.bracket_position == "5/6" }
|
||||||
bout_number2 = conso_semi_matches.find { |match| match.bracket_position_number == 2 }.bout_number
|
m56.loser1_name = "Loser of #{conso_semis[0].bout_number}"
|
||||||
five_six_match.loser1_name = "Loser of #{bout_number1}"
|
m56.loser2_name = "Loser of #{conso_semis[1].bout_number}" if m56
|
||||||
five_six_match.loser2_name = "Loser of #{bout_number2}"
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if number_of_placers >= 8 && weight.wrestlers.size >= 7
|
# 7th/8th place
|
||||||
seven_eight_match = matches_by_weight.find { |match| match.bracket_position == "7/8" }
|
if bracket_size >= 7 && num_placers >= 8 && weight.wrestlers.size > 6
|
||||||
bout_number1 = conso_quarter_matches.find { |match| match.bracket_position_number == 1 }.bout_number
|
conso_quarters = matches.select { |m| m.bracket_position == "Conso Quarter" }
|
||||||
bout_number2 = conso_quarter_matches.find { |match| match.bracket_position_number == 2 }.bout_number
|
.sort_by(&:bracket_position_number)
|
||||||
seven_eight_match.loser1_name = "Loser of #{bout_number1}"
|
if conso_quarters.size >= 2
|
||||||
seven_eight_match.loser2_name = "Loser of #{bout_number2}"
|
m78 = matches.find { |m| m.bracket_position == "7/8" }
|
||||||
|
m78.loser1_name = "Loser of #{conso_quarters[0].bout_number}"
|
||||||
|
m78.loser2_name = "Loser of #{conso_quarters[1].bout_number}" if m78
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
save_matches(matches_by_weight)
|
|
||||||
end
|
|
||||||
|
|
||||||
def save_matches(matches)
|
|
||||||
matches.each(&:save!)
|
matches.each(&:save!)
|
||||||
end
|
end
|
||||||
|
|
||||||
def advance_bye_matches_championship(matches)
|
# Advance first-round byes in championship bracket
|
||||||
first_round = matches.sort_by{|m| m.round}.first.round
|
def advance_bye_matches_championship(weight)
|
||||||
matches.select do |m|
|
matches = weight.matches.reload
|
||||||
m.round == first_round
|
first_round = matches.map(&:round).min
|
||||||
end.sort_by(&:bracket_position_number).each do |match|
|
matches.select { |m| m.round == first_round }
|
||||||
next unless match.w1.nil? || match.w2.nil?
|
.sort_by(&:bracket_position_number)
|
||||||
|
.each { |m| handle_bye(m) }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Advance first-round byes in consolation bracket
|
||||||
|
def advance_bye_matches_consolation(weight)
|
||||||
|
matches = weight.matches.reload
|
||||||
|
bracket_size = weight.calculate_bracket_size
|
||||||
|
first_conso = dynamic_consolation_rounds(bracket_size).first
|
||||||
|
|
||||||
|
matches.select { |m| m.round == first_conso[:round] && m.bracket_position == first_conso[:bracket_position] }
|
||||||
|
.sort_by(&:bracket_position_number)
|
||||||
|
.each { |m| handle_bye(m) }
|
||||||
|
end
|
||||||
|
|
||||||
|
# Mark bye match, set finished, and advance
|
||||||
|
def handle_bye(match)
|
||||||
|
if [match.w1, match.w2].compact.size == 1
|
||||||
match.finished = 1
|
match.finished = 1
|
||||||
match.win_type = "BYE"
|
match.win_type = 'BYE'
|
||||||
if match.w1
|
if match.w1
|
||||||
match.winner_id = match.w1
|
match.winner_id = match.w1
|
||||||
match.loser2_name = "BYE"
|
match.loser2_name = 'BYE'
|
||||||
elsif match.w2
|
else
|
||||||
match.winner_id = match.w2
|
match.winner_id = match.w2
|
||||||
match.loser1_name = "BYE"
|
match.loser1_name = 'BYE'
|
||||||
end
|
end
|
||||||
match.score = ""
|
match.score = ''
|
||||||
match.save
|
match.save!
|
||||||
match.advance_wrestlers
|
match.advance_wrestlers
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Helpers for dynamic bracket labels
|
||||||
|
def first_round_label(size)
|
||||||
|
case size
|
||||||
|
when 2 then 'Final'
|
||||||
|
when 4 then 'Semis'
|
||||||
|
when 8 then 'Quarter'
|
||||||
|
else "Bracket Round of #{size}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dynamic_championship_rounds(size)
|
||||||
|
total = Math.log2(size).to_i
|
||||||
|
(1...total).map do |i|
|
||||||
|
participants = size / (2**i)
|
||||||
|
{ bracket_position: bracket_label(participants), round: i + 1 }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dynamic_consolation_rounds(size)
|
||||||
|
total_log2 = Math.log2(size).to_i
|
||||||
|
return [] if total_log2 <= 1
|
||||||
|
|
||||||
|
max_j_val = (2 * (total_log2 - 1) - 1)
|
||||||
|
(1..max_j_val).map do |j|
|
||||||
|
current_participants = size / (2**((j.to_f / 2).ceil))
|
||||||
|
{
|
||||||
|
bracket_position: consolation_label(current_participants, j, size),
|
||||||
|
round: j
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def bracket_label(participants)
|
||||||
|
case participants
|
||||||
|
when 2 then '1/2'
|
||||||
|
when 4 then 'Semis'
|
||||||
|
when 8 then 'Quarter'
|
||||||
|
else "Bracket Round of #{participants}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def consolation_label(participants, j, bracket_size)
|
||||||
|
max_j_for_bracket = (2 * (Math.log2(bracket_size).to_i - 1) - 1)
|
||||||
|
|
||||||
|
if participants == 2 && j == max_j_for_bracket
|
||||||
|
return '3/4'
|
||||||
|
elsif participants == 4
|
||||||
|
return j.odd? ? 'Conso Quarter' : 'Conso Semis'
|
||||||
|
else
|
||||||
|
suffix = j.odd? ? ".1" : ".2"
|
||||||
|
return "Conso Round of #{participants}#{suffix}"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ class DoubleEliminationMatchGeneration
|
|||||||
|
|
||||||
# 1) Round one matchups
|
# 1) Round one matchups
|
||||||
bracket_info[:round_one_matchups].each_with_index do |matchup, idx|
|
bracket_info[:round_one_matchups].each_with_index do |matchup, idx|
|
||||||
seed1, seed2 = matchup[:seeds]
|
seed1, seed2 = matchup[:seeds]
|
||||||
bracket_position = matchup[:bracket_position]
|
bracket_position = matchup[:bracket_position]
|
||||||
bracket_pos_number = idx + 1
|
bracket_pos_number = idx + 1
|
||||||
round_number = matchup[:round] # Use the round from our definition
|
round_number = matchup[:round]
|
||||||
|
|
||||||
create_matchup_from_seed(
|
create_matchup_from_seed(
|
||||||
seed1,
|
seed1,
|
||||||
@@ -77,167 +77,112 @@ class DoubleEliminationMatchGeneration
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
|
||||||
# 5/6, 7/8 placing logic
|
# 5/6, 7/8 placing logic
|
||||||
#
|
if weight.wrestlers.size >= 5 && @tournament.number_of_placers >= 6 && matches_this_round == 1
|
||||||
if weight.wrestlers.size >= 5
|
create_matchup(nil, nil, "5/6", 1, round_number, weight)
|
||||||
if @tournament.number_of_placers >= 6 && matches_this_round == 1
|
|
||||||
create_matchup(nil, nil, "5/6", 1, round_number, weight)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if weight.wrestlers.size >= 7
|
if weight.wrestlers.size >= 7 && @tournament.number_of_placers >= 8 && matches_this_round == 1
|
||||||
if @tournament.number_of_placers >= 8 && matches_this_round == 1
|
create_matchup(nil, nil, "7/8", 1, round_number, weight)
|
||||||
create_matchup(nil, nil, "7/8", 1, round_number, weight)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
# Single bracket definition dynamically generated for any power-of-two bracket size.
|
||||||
# Single bracket definition that includes both bracket_position and round.
|
# Returns a hash with :round_one_matchups, :championship_rounds, and :consolation_rounds.
|
||||||
# If you later decide to tweak round numbering, you do it in ONE place.
|
|
||||||
#
|
|
||||||
def define_bracket_matches(bracket_size)
|
def define_bracket_matches(bracket_size)
|
||||||
case bracket_size
|
# Only support brackets that are powers of two
|
||||||
when 4
|
return nil unless (bracket_size & (bracket_size - 1)).zero?
|
||||||
{
|
|
||||||
round_one_matchups: [
|
|
||||||
# First round is Semis => round=1
|
|
||||||
{ seeds: [1, 4], bracket_position: "Semis", round: 1 },
|
|
||||||
{ seeds: [2, 3], bracket_position: "Semis", round: 1 }
|
|
||||||
],
|
|
||||||
championship_rounds: [
|
|
||||||
# Final => round=2
|
|
||||||
{ bracket_position: "1/2", number_of_matches: 1, round: 2 }
|
|
||||||
],
|
|
||||||
consolation_rounds: [
|
|
||||||
# 3rd place => round=2
|
|
||||||
{ bracket_position: "3/4", number_of_matches: 1, round: 2 }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
when 8
|
# 1) Generate the seed sequence (e.g., [1,8,5,4,...] for size=8)
|
||||||
{
|
seeds = generate_seed_sequence(bracket_size)
|
||||||
round_one_matchups: [
|
|
||||||
# Quarter => round=1
|
|
||||||
{ seeds: [1, 8], bracket_position: "Quarter", round: 1 },
|
|
||||||
{ seeds: [4, 5], bracket_position: "Quarter", round: 1 },
|
|
||||||
{ seeds: [3, 6], bracket_position: "Quarter", round: 1 },
|
|
||||||
{ seeds: [2, 7], bracket_position: "Quarter", round: 1 }
|
|
||||||
],
|
|
||||||
championship_rounds: [
|
|
||||||
# Semis => round=2, Final => round=4
|
|
||||||
{ bracket_position: "Semis", number_of_matches: 2, round: 2 },
|
|
||||||
{ bracket_position: "1/2", number_of_matches: 1, round: 4 }
|
|
||||||
],
|
|
||||||
consolation_rounds: [
|
|
||||||
# Conso Quarter => round=2, Conso Semis => round=3, 3/4 => round=4
|
|
||||||
{ bracket_position: "Conso Quarter", number_of_matches: 2, round: 2 },
|
|
||||||
{ bracket_position: "Conso Semis", number_of_matches: 2, round: 3 },
|
|
||||||
{ bracket_position: "3/4", number_of_matches: 1, round: 4 }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
when 16
|
# 2) Pair seeds into first-round matchups, sorting so lower seed is w1
|
||||||
|
round_one = seeds.each_slice(2).map.with_index do |(s1, s2), idx|
|
||||||
|
a, b = [s1, s2].sort
|
||||||
{
|
{
|
||||||
round_one_matchups: [
|
seeds: [a, b],
|
||||||
{ seeds: [1,16], bracket_position: "Bracket Round of 16", round: 1 },
|
bracket_position: first_round_label(bracket_size),
|
||||||
{ seeds: [8,9], bracket_position: "Bracket Round of 16", round: 1 },
|
round: 1
|
||||||
{ seeds: [5,12], bracket_position: "Bracket Round of 16", round: 1 },
|
|
||||||
{ seeds: [4,13], bracket_position: "Bracket Round of 16", round: 1 },
|
|
||||||
{ seeds: [3,14], bracket_position: "Bracket Round of 16", round: 1 },
|
|
||||||
{ seeds: [6,11], bracket_position: "Bracket Round of 16", round: 1 },
|
|
||||||
{ seeds: [7,10], bracket_position: "Bracket Round of 16", round: 1 },
|
|
||||||
{ seeds: [2,15], bracket_position: "Bracket Round of 16", round: 1 }
|
|
||||||
],
|
|
||||||
championship_rounds: [
|
|
||||||
# Quarter => round=2, Semis => round=4, Final => round=6
|
|
||||||
{ bracket_position: "Quarter", number_of_matches: 4, round: 2 },
|
|
||||||
{ bracket_position: "Semis", number_of_matches: 2, round: 4 },
|
|
||||||
{ bracket_position: "1/2", number_of_matches: 1, round: 6 }
|
|
||||||
],
|
|
||||||
consolation_rounds: [
|
|
||||||
# Just carry over your standard numbering
|
|
||||||
{ bracket_position: "Conso Round of 8.1", number_of_matches: 4, round: 2 },
|
|
||||||
{ bracket_position: "Conso Round of 8.2", number_of_matches: 4, round: 3 },
|
|
||||||
{ bracket_position: "Conso Quarter", number_of_matches: 2, round: 4 },
|
|
||||||
{ bracket_position: "Conso Semis", number_of_matches: 2, round: 5 },
|
|
||||||
{ bracket_position: "3/4", number_of_matches: 1, round: 6 }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
when 32
|
|
||||||
{
|
|
||||||
round_one_matchups: [
|
|
||||||
{ seeds: [1,32], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [16,17], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [9,24], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [8,25], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [5,28], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [12,21], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [13,20], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [4,29], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [3,30], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [14,19], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [11,22], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [6,27], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [7,26], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [10,23], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [15,18], bracket_position: "Bracket Round of 32", round: 1 },
|
|
||||||
{ seeds: [2,31], bracket_position: "Bracket Round of 32", round: 1 }
|
|
||||||
],
|
|
||||||
championship_rounds: [
|
|
||||||
{ bracket_position: "Bracket Round of 16", number_of_matches: 8, round: 2 },
|
|
||||||
{ bracket_position: "Quarter", number_of_matches: 4, round: 4 },
|
|
||||||
{ bracket_position: "Semis", number_of_matches: 2, round: 6 },
|
|
||||||
{ bracket_position: "1/2", number_of_matches: 1, round: 8 }
|
|
||||||
],
|
|
||||||
consolation_rounds: [
|
|
||||||
{ bracket_position: "Conso Round of 16.1", number_of_matches: 8, round: 2 },
|
|
||||||
{ bracket_position: "Conso Round of 16.2", number_of_matches: 8, round: 3 },
|
|
||||||
{ bracket_position: "Conso Round of 8.1", number_of_matches: 4, round: 4 },
|
|
||||||
{ bracket_position: "Conso Round of 8.2", number_of_matches: 4, round: 5 },
|
|
||||||
{ bracket_position: "Conso Quarter", number_of_matches: 2, round: 6 },
|
|
||||||
{ bracket_position: "Conso Semis", number_of_matches: 2, round: 7 },
|
|
||||||
{ bracket_position: "3/4", number_of_matches: 1, round: 8 }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 3) Build full structure, including dynamic championship & consolation rounds
|
||||||
|
{
|
||||||
|
round_one_matchups: round_one,
|
||||||
|
championship_rounds: dynamic_championship_rounds(bracket_size),
|
||||||
|
consolation_rounds: dynamic_consolation_rounds(bracket_size)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns a human-readable label for the first round based on bracket size.
|
||||||
|
def first_round_label(bracket_size)
|
||||||
|
case bracket_size
|
||||||
|
when 2 then "1/2"
|
||||||
|
when 4 then "Semis"
|
||||||
|
when 8 then "Quarter"
|
||||||
|
else "Bracket Round of #{bracket_size}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Dynamically generate championship rounds for any power-of-two bracket size.
|
||||||
|
def dynamic_championship_rounds(bracket_size)
|
||||||
|
rounds = []
|
||||||
|
num_rounds = Math.log2(bracket_size).to_i
|
||||||
|
# i: 1 -> first post-initial round, up to num_rounds-1 (final)
|
||||||
|
(1...num_rounds).each do |i|
|
||||||
|
participants = bracket_size / (2**i)
|
||||||
|
number_of_matches = participants / 2
|
||||||
|
bracket_position = case participants
|
||||||
|
when 2 then "1/2"
|
||||||
|
when 4 then "Semis"
|
||||||
|
when 8 then "Quarter"
|
||||||
|
else "Bracket Round of #{participants}"
|
||||||
|
end
|
||||||
|
round_number = i * 2
|
||||||
|
rounds << { bracket_position: bracket_position,
|
||||||
|
number_of_matches: number_of_matches,
|
||||||
|
round: round_number }
|
||||||
|
end
|
||||||
|
rounds
|
||||||
|
end
|
||||||
|
|
||||||
|
# Dynamically generate consolation rounds for any power-of-two bracket size.
|
||||||
|
def dynamic_consolation_rounds(bracket_size)
|
||||||
|
rounds = []
|
||||||
|
num_rounds = Math.log2(bracket_size).to_i
|
||||||
|
total_conso = 2 * (num_rounds - 1) - 1
|
||||||
|
(1..total_conso).each do |j|
|
||||||
|
participants = bracket_size / (2**((j.to_f / 2).ceil))
|
||||||
|
number_of_matches = participants / 2
|
||||||
|
bracket_position = case participants
|
||||||
|
when 2 then "3/4"
|
||||||
|
when 4
|
||||||
|
j.odd? ? "Conso Quarter" : "Conso Semis"
|
||||||
|
else
|
||||||
|
suffix = j.odd? ? ".1" : ".2"
|
||||||
|
"Conso Round of #{participants}#{suffix}"
|
||||||
|
end
|
||||||
|
round_number = j + 1
|
||||||
|
rounds << { bracket_position: bracket_position,
|
||||||
|
number_of_matches: number_of_matches,
|
||||||
|
round: round_number }
|
||||||
|
end
|
||||||
|
rounds
|
||||||
end
|
end
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# PHASE 2: Overwrite rounds in all smaller brackets to match the largest one.
|
# PHASE 2: Overwrite rounds in all smaller brackets to match the largest one.
|
||||||
###########################################################################
|
###########################################################################
|
||||||
def align_all_rounds_to_largest_bracket
|
def align_all_rounds_to_largest_bracket
|
||||||
#
|
|
||||||
# 1) Find the bracket size that is largest
|
|
||||||
#
|
|
||||||
largest_weight = @tournament.weights.max_by { |w| w.calculate_bracket_size }
|
largest_weight = @tournament.weights.max_by { |w| w.calculate_bracket_size }
|
||||||
return unless largest_weight
|
return unless largest_weight
|
||||||
|
|
||||||
#
|
|
||||||
# 2) Gather all matches for that bracket. Build a map from bracket_position => round
|
|
||||||
#
|
|
||||||
# We assume "largest bracket" is the single weight with the largest bracket_size.
|
|
||||||
#
|
|
||||||
largest_bracket_size = largest_weight.calculate_bracket_size
|
|
||||||
largest_matches = largest_weight.tournament.matches.where(weight_id: largest_weight.id)
|
|
||||||
|
|
||||||
position_to_round = {}
|
position_to_round = {}
|
||||||
largest_matches.each do |m|
|
largest_weight.tournament.matches.where(weight_id: largest_weight.id).each do |m|
|
||||||
# In case multiple matches have the same bracket_position but different rounds
|
position_to_round[m.bracket_position] ||= m.round
|
||||||
# (like "3/4" might appear more than once), you can pick the first or max.
|
|
||||||
position_to_round[m.bracket_position] ||= m.round
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
|
||||||
# 3) For every other match in the entire tournament (including possibly the largest bracket, if you want),
|
|
||||||
# overwrite the round to match this map.
|
|
||||||
#
|
|
||||||
@tournament.matches.find_each do |match|
|
@tournament.matches.find_each do |match|
|
||||||
# If there's a known round for this bracket_position, use it
|
|
||||||
if position_to_round.key?(match.bracket_position)
|
if position_to_round.key?(match.bracket_position)
|
||||||
match.update(round: position_to_round[match.bracket_position])
|
match.update(round: position_to_round[match.bracket_position])
|
||||||
end
|
end
|
||||||
@@ -272,4 +217,23 @@ class DoubleEliminationMatchGeneration
|
|||||||
bracket_position_number: bracket_position_number
|
bracket_position_number: bracket_position_number
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Calculates the sequence of seeds for the first round of a power-of-two bracket.
|
||||||
|
def generate_seed_sequence(n)
|
||||||
|
raise ArgumentError, "Bracket size must be a power of two" unless (n & (n - 1)).zero?
|
||||||
|
return [1, 2] if n == 2
|
||||||
|
|
||||||
|
half = n / 2
|
||||||
|
prev = generate_seed_sequence(half)
|
||||||
|
comp = prev.map { |s| n + 1 - s }
|
||||||
|
|
||||||
|
result = []
|
||||||
|
(0...prev.size).step(2) do |k|
|
||||||
|
result << prev[k]
|
||||||
|
result << comp[k]
|
||||||
|
result << comp[k + 1]
|
||||||
|
result << prev[k + 1]
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,11 +37,19 @@ class TournamentBackupService
|
|||||||
attributes: @tournament.attributes,
|
attributes: @tournament.attributes,
|
||||||
schools: @tournament.schools.map(&:attributes),
|
schools: @tournament.schools.map(&:attributes),
|
||||||
weights: @tournament.weights.map(&:attributes),
|
weights: @tournament.weights.map(&:attributes),
|
||||||
mats: @tournament.mats.map(&:attributes),
|
mats: @tournament.mats.map do |mat|
|
||||||
|
mat.attributes.merge(
|
||||||
|
"queue_bout_numbers" => mat.queue_matches.map { |match| match&.bout_number }
|
||||||
|
)
|
||||||
|
end,
|
||||||
mat_assignment_rules: @tournament.mat_assignment_rules.map do |rule|
|
mat_assignment_rules: @tournament.mat_assignment_rules.map do |rule|
|
||||||
rule.attributes.merge(
|
rule.attributes.merge(
|
||||||
mat: Mat.find_by(id: rule.mat_id)&.attributes.slice("name"),
|
mat: Mat.find_by(id: rule.mat_id)&.attributes.slice("name"),
|
||||||
weight_classes: rule.weight_classes.map do |weight_id|
|
# Emit the human-readable max values under a distinct key to avoid
|
||||||
|
# colliding with the raw DB-backed "weight_classes" attribute (which
|
||||||
|
# is stored as a comma-separated string). Using a different key
|
||||||
|
# prevents duplicate JSON keys when symbols and strings are both present.
|
||||||
|
"weight_class_maxes" => rule.weight_classes.map do |weight_id|
|
||||||
Weight.find_by(id: weight_id)&.max
|
Weight.find_by(id: weight_id)&.max
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -18,15 +18,15 @@ class TournamentSeeding
|
|||||||
def random_seeding(wrestlers, bracket_size)
|
def random_seeding(wrestlers, bracket_size)
|
||||||
half_of_bracket = bracket_size / 2
|
half_of_bracket = bracket_size / 2
|
||||||
available_bracket_lines = (1..bracket_size).to_a
|
available_bracket_lines = (1..bracket_size).to_a
|
||||||
first_half_available_bracket_lines = (1..half_of_bracket).to_a
|
|
||||||
|
|
||||||
# remove bracket lines that are taken from available_bracket_lines
|
# remove bracket lines that are taken from available_bracket_lines
|
||||||
wrestlers_with_bracket_lines = wrestlers.select{|w| w.bracket_line != nil }
|
wrestlers_with_bracket_lines = wrestlers.select{|w| w.bracket_line != nil }
|
||||||
wrestlers_with_bracket_lines.each do |wrestler|
|
wrestlers_with_bracket_lines.each do |wrestler|
|
||||||
available_bracket_lines.delete(wrestler.bracket_line)
|
available_bracket_lines.delete(wrestler.bracket_line)
|
||||||
first_half_available_bracket_lines.delete(wrestler.bracket_line)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
available_bracket_lines_to_use = set_random_seeding_bracket_line_order(available_bracket_lines)
|
||||||
|
|
||||||
wrestlers_without_bracket_lines = wrestlers.select{|w| w.bracket_line == nil }
|
wrestlers_without_bracket_lines = wrestlers.select{|w| w.bracket_line == nil }
|
||||||
if @tournament.tournament_type == "Pool to bracket"
|
if @tournament.tournament_type == "Pool to bracket"
|
||||||
wrestlers_without_bracket_lines.shuffle.each do |wrestler|
|
wrestlers_without_bracket_lines.shuffle.each do |wrestler|
|
||||||
@@ -38,15 +38,10 @@ class TournamentSeeding
|
|||||||
else
|
else
|
||||||
# Iterrate over the list randomly
|
# Iterrate over the list randomly
|
||||||
wrestlers_without_bracket_lines.shuffle.each do |wrestler|
|
wrestlers_without_bracket_lines.shuffle.each do |wrestler|
|
||||||
if first_half_available_bracket_lines.size > 0
|
if available_bracket_lines_to_use.size > 0
|
||||||
random_available_bracket_line = first_half_available_bracket_lines.sample
|
bracket_line_to_use = available_bracket_lines_to_use.first
|
||||||
wrestler.bracket_line = random_available_bracket_line
|
wrestler.bracket_line = bracket_line_to_use
|
||||||
available_bracket_lines.delete(random_available_bracket_line)
|
available_bracket_lines_to_use.delete(bracket_line_to_use)
|
||||||
first_half_available_bracket_lines.delete(random_available_bracket_line)
|
|
||||||
else
|
|
||||||
random_available_bracket_line = available_bracket_lines.sample
|
|
||||||
wrestler.bracket_line = random_available_bracket_line
|
|
||||||
available_bracket_lines.delete(random_available_bracket_line)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -81,4 +76,24 @@ class TournamentSeeding
|
|||||||
end
|
end
|
||||||
return wrestlers
|
return wrestlers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_random_seeding_bracket_line_order(available_bracket_lines)
|
||||||
|
# This method prevents double BYEs in round 1
|
||||||
|
# It also evenly distributes matches from the top half of the bracket to the bottom half
|
||||||
|
# It does both of these while keeping the randomness of the line assignment
|
||||||
|
odd_or_even = [0, 1]
|
||||||
|
odd_or_even_sample = odd_or_even.sample
|
||||||
|
|
||||||
|
# sort by odd or even based on the sample above
|
||||||
|
if odd_or_even_sample == 1
|
||||||
|
# odd numbers first
|
||||||
|
result = available_bracket_lines.sort_by { |n| n.even? ? 1 : 0 }
|
||||||
|
else
|
||||||
|
# even numbers first
|
||||||
|
result = available_bracket_lines.sort_by { |n| n.odd? ? 1 : 0 }
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@@ -41,20 +41,20 @@ class WrestlingdevImporter
|
|||||||
@tournament.matches.destroy_all
|
@tournament.matches.destroy_all
|
||||||
@tournament.mat_assignment_rules.destroy_all # Explicitly destroy rules (might be redundant if Mat cascades)
|
@tournament.mat_assignment_rules.destroy_all # Explicitly destroy rules (might be redundant if Mat cascades)
|
||||||
@tournament.delegates.destroy_all
|
@tournament.delegates.destroy_all
|
||||||
@tournament.tournament_backups.destroy_all
|
|
||||||
@tournament.tournament_job_statuses.destroy_all
|
@tournament.tournament_job_statuses.destroy_all
|
||||||
# Note: Teampointadjusts are deleted via School/Wrestler cascade
|
# Note: Teampointadjusts are deleted via School/Wrestler cascade
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_data
|
def parse_data
|
||||||
parse_tournament(@import_data["tournament"]["attributes"])
|
parse_tournament(@import_data["tournament"]["attributes"])
|
||||||
parse_schools(@import_data["tournament"]["schools"])
|
parse_schools(@import_data["tournament"]["schools"])
|
||||||
parse_weights(@import_data["tournament"]["weights"])
|
parse_weights(@import_data["tournament"]["weights"])
|
||||||
parse_mats(@import_data["tournament"]["mats"])
|
parse_mats(@import_data["tournament"]["mats"])
|
||||||
parse_wrestlers(@import_data["tournament"]["wrestlers"])
|
parse_wrestlers(@import_data["tournament"]["wrestlers"])
|
||||||
parse_matches(@import_data["tournament"]["matches"])
|
parse_matches(@import_data["tournament"]["matches"])
|
||||||
parse_mat_assignment_rules(@import_data["tournament"]["mat_assignment_rules"])
|
apply_mat_queues
|
||||||
end
|
parse_mat_assignment_rules(@import_data["tournament"]["mat_assignment_rules"])
|
||||||
|
end
|
||||||
|
|
||||||
def parse_tournament(attributes)
|
def parse_tournament(attributes)
|
||||||
attributes.except!("id")
|
attributes.except!("id")
|
||||||
@@ -75,28 +75,47 @@ class WrestlingdevImporter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_mats(mats)
|
def parse_mats(mats)
|
||||||
mats.each do |mat_attributes|
|
@mat_queue_bout_numbers = {}
|
||||||
mat_attributes.except!("id")
|
mats.each do |mat_attributes|
|
||||||
Mat.create(mat_attributes.merge(tournament_id: @tournament.id))
|
mat_name = mat_attributes["name"]
|
||||||
end
|
queue_bout_numbers = mat_attributes["queue_bout_numbers"]
|
||||||
end
|
mat_attributes.except!("id", "queue1", "queue2", "queue3", "queue4", "queue_bout_numbers", "tournament_id")
|
||||||
|
Mat.create(mat_attributes.merge(tournament_id: @tournament.id))
|
||||||
|
if mat_name && queue_bout_numbers
|
||||||
|
@mat_queue_bout_numbers[mat_name] = queue_bout_numbers
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def parse_mat_assignment_rules(mat_assignment_rules)
|
def parse_mat_assignment_rules(mat_assignment_rules)
|
||||||
mat_assignment_rules.each do |rule_attributes|
|
mat_assignment_rules.each do |rule_attributes|
|
||||||
mat_name = rule_attributes.dig("mat", "name")
|
mat_name = rule_attributes.dig("mat", "name")
|
||||||
mat = Mat.find_by(name: mat_name, tournament_id: @tournament.id)
|
mat = Mat.find_by(name: mat_name, tournament_id: @tournament.id)
|
||||||
|
|
||||||
# Map max values of weight_classes to their new IDs
|
# Prefer the new "weight_class_maxes" key emitted by backups (human-readable
|
||||||
new_weight_classes = rule_attributes["weight_classes"].map do |max_value|
|
# max values). If not present, fall back to the legacy "weight_classes"
|
||||||
Weight.find_by(max: max_value, tournament_id: @tournament.id)&.id
|
# value which may be a comma-separated string or an array of IDs.
|
||||||
end.compact
|
if rule_attributes.key?("weight_class_maxes") && rule_attributes["weight_class_maxes"].respond_to?(:map)
|
||||||
|
new_weight_classes = rule_attributes["weight_class_maxes"].map do |max_value|
|
||||||
# Extract bracket_positions and rounds
|
Weight.find_by(max: max_value, tournament_id: @tournament.id)&.id
|
||||||
|
end.compact
|
||||||
|
elsif rule_attributes["weight_classes"].is_a?(Array)
|
||||||
|
# Already an array of IDs
|
||||||
|
new_weight_classes = rule_attributes["weight_classes"].map(&:to_i)
|
||||||
|
elsif rule_attributes["weight_classes"].is_a?(String)
|
||||||
|
# Comma-separated IDs stored in the DB column; split into integers.
|
||||||
|
new_weight_classes = rule_attributes["weight_classes"].to_s.split(",").map(&:strip).reject(&:empty?).map(&:to_i)
|
||||||
|
else
|
||||||
|
new_weight_classes = []
|
||||||
|
end
|
||||||
|
|
||||||
|
# Extract bracket_positions and rounds (leave as-is; model will coerce if needed)
|
||||||
bracket_positions = rule_attributes["bracket_positions"]
|
bracket_positions = rule_attributes["bracket_positions"]
|
||||||
rounds = rule_attributes["rounds"]
|
rounds = rule_attributes["rounds"]
|
||||||
|
|
||||||
rule_attributes.except!("id", "mat", "tournament_id", "weight_classes")
|
# Remove any keys we don't want to mass-assign (including both old/new weight keys)
|
||||||
|
rule_attributes.except!("id", "mat", "tournament_id", "weight_classes", "weight_class_maxes")
|
||||||
|
|
||||||
MatAssignmentRule.create(
|
MatAssignmentRule.create(
|
||||||
rule_attributes.merge(
|
rule_attributes.merge(
|
||||||
@@ -122,9 +141,9 @@ class WrestlingdevImporter
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_matches(matches)
|
def parse_matches(matches)
|
||||||
matches.each do |match_attributes|
|
matches.each do |match_attributes|
|
||||||
next unless match_attributes # Skip if match_attributes is nil
|
next unless match_attributes # Skip if match_attributes is nil
|
||||||
|
|
||||||
weight = Weight.find_by(max: match_attributes.dig("weight", "max"), tournament_id: @tournament.id)
|
weight = Weight.find_by(max: match_attributes.dig("weight", "max"), tournament_id: @tournament.id)
|
||||||
mat = Mat.find_by(name: match_attributes.dig("mat", "name"), tournament_id: @tournament.id)
|
mat = Mat.find_by(name: match_attributes.dig("mat", "name"), tournament_id: @tournament.id)
|
||||||
@@ -143,6 +162,53 @@ class WrestlingdevImporter
|
|||||||
w2: w2&.id,
|
w2: w2&.id,
|
||||||
winner_id: winner&.id
|
winner_id: winner&.id
|
||||||
))
|
))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
def apply_mat_queues
|
||||||
|
if @mat_queue_bout_numbers.blank?
|
||||||
|
Mat.where(tournament_id: @tournament.id).find_each do |mat|
|
||||||
|
match_ids = mat.matches.where(finished: [nil, 0]).order(:bout_number).limit(4).pluck(:id)
|
||||||
|
mat.update(
|
||||||
|
queue1: match_ids[0],
|
||||||
|
queue2: match_ids[1],
|
||||||
|
queue3: match_ids[2],
|
||||||
|
queue4: match_ids[3]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@mat_queue_bout_numbers.each do |mat_name, bout_numbers|
|
||||||
|
mat = Mat.find_by(name: mat_name, tournament_id: @tournament.id)
|
||||||
|
next unless mat
|
||||||
|
|
||||||
|
matches = Array(bout_numbers).map do |bout_number|
|
||||||
|
Match.find_by(bout_number: bout_number, tournament_id: @tournament.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
mat.update(
|
||||||
|
queue1: matches[0]&.id,
|
||||||
|
queue2: matches[1]&.id,
|
||||||
|
queue3: matches[2]&.id,
|
||||||
|
queue4: matches[3]&.id
|
||||||
|
)
|
||||||
|
|
||||||
|
matches.compact.each do |match|
|
||||||
|
match.update(mat_id: mat.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Mat.where(tournament_id: @tournament.id)
|
||||||
|
.where(queue1: nil, queue2: nil, queue3: nil, queue4: nil)
|
||||||
|
.find_each do |mat|
|
||||||
|
match_ids = mat.matches.where(finished: [nil, 0]).order(:bout_number).limit(4).pluck(:id)
|
||||||
|
mat.update(
|
||||||
|
queue1: match_ids[0],
|
||||||
|
queue2: match_ids[1],
|
||||||
|
queue3: match_ids[2],
|
||||||
|
queue4: match_ids[3]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ json.cache! ["api_tournament", @tournament] do
|
|||||||
|
|
||||||
json.mats @mats do |mat|
|
json.mats @mats do |mat|
|
||||||
json.name mat.name
|
json.name mat.name
|
||||||
json.unfinished_matches mat.unfinished_matches do |match|
|
json.unfinished_matches mat.queue_matches.compact do |match|
|
||||||
json.bout_number match.bout_number
|
json.bout_number match.bout_number
|
||||||
json.w1_name match.w1_name
|
json.w1_name match.w1_name
|
||||||
json.w2_name match.w2_name
|
json.w2_name match.w2_name
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><%= current_user.email %>
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#"><%= current_user.email %>
|
||||||
<span class="caret"></span></a>
|
<span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><%= link_to "Log out", logout_path, method: :delete %></li>
|
<li><%= button_to "Log out", logout_path, method: :delete, class: 'btn btn-link', form: { class: 'navbar-logout-form' } %></li>
|
||||||
<li><%= link_to "Edit profile", edit_user_path(current_user) %></li>
|
<li><%= link_to "Edit profile", edit_user_path(current_user) %></li>
|
||||||
<li><%= link_to "My tournaments and schools", "/static_pages/my_tournaments" %></li>
|
<li><%= link_to "My tournaments and schools", "/static_pages/my_tournaments" %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -38,12 +38,13 @@
|
|||||||
<li><strong>Pages</strong></li>
|
<li><strong>Pages</strong></li>
|
||||||
<li></span> <%= link_to "Edit Tournament Info", edit_tournament_path(@tournament) %></li>
|
<li></span> <%= link_to "Edit Tournament Info", edit_tournament_path(@tournament) %></li>
|
||||||
<li><%= link_to "Weigh In Page" , "/tournaments/#{@tournament.id}/weigh_in" %></li>
|
<li><%= link_to "Weigh In Page" , "/tournaments/#{@tournament.id}/weigh_in" %></li>
|
||||||
<li><%= link_to "All Matches" , "/tournaments/#{@tournament.id}/matches" %></li>
|
<li><%= link_to "All Matches" , "/tournaments/#{@tournament.id}/matches" %></li>
|
||||||
<li><%= link_to "Full Screen Bout Board" , "/tournaments/#{@tournament.id}/up_matches?print=true" , target: :_blank %></li>
|
<li><%= link_to "Full Screen Bout Board" , "/tournaments/#{@tournament.id}/up_matches?print=true" , target: :_blank %></li>
|
||||||
<li><%= link_to "Deduct Team Points" , "/tournaments/#{@tournament.id}/teampointadjust" %></li>
|
<li><%= link_to "QR Code (Full Screen)" , "/tournaments/#{@tournament.id}/qrcode?print=true" , target: :_blank %></li>
|
||||||
|
<li><%= link_to "Deduct Team Points" , "/tournaments/#{@tournament.id}/teampointadjust" %></li>
|
||||||
<li><%= link_to "View All Mat Assignment Rules", tournament_mat_assignment_rules_path(@tournament) %></li>
|
<li><%= link_to "View All Mat Assignment Rules", tournament_mat_assignment_rules_path(@tournament) %></li>
|
||||||
<li><%= link_to 'Manage Backups', tournament_tournament_backups_path(@tournament) %></li>
|
<li><%= link_to 'Manage Backups', tournament_tournament_backups_path(@tournament) %></li>
|
||||||
<li><%= link_to "Reset Bout Board", reset_bout_board_tournament_path(@tournament), method: :post, data: { confirm: "Are you sure you want to reset the bout board?" } %></li>
|
<li><%= link_to "Reset Bout Board", reset_bout_board_tournament_path(@tournament), data: { turbo_method: :post, turbo_confirm: "Are you sure you want to reset the bout board?" } %></li>
|
||||||
<% if can? :destroy, @tournament %>
|
<% if can? :destroy, @tournament %>
|
||||||
<li><%= link_to "Tournament Delegation" , "/tournaments/#{@tournament.id}/delegate" %></li>
|
<li><%= link_to "Tournament Delegation" , "/tournaments/#{@tournament.id}/delegate" %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -55,13 +56,13 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><strong>Time Savers</strong></li>
|
<li><strong>Time Savers</strong></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 Boys High School Weights (106-285)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::HS_WEIGHT_CLASSES}",data: { turbo_method: :get, turbo_confirm: 'Are you sure? This will delete all current weights.' } %></li>
|
||||||
<li><%= link_to "Create Girls High School Weights (100-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 Girls High School Weights (100-235)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::HS_GIRLS_WEIGHT_CLASSES}",data: { turbo_method: :get, turbo_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><%= link_to "Create Boys Middle School Weights (80-245)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::MS_WEIGHT_CLASSES}",data: { turbo_method: :get, turbo_confirm: 'Are you sure? This will delete all current weights.' } %></li>
|
||||||
<li><%= link_to "Create Girls Middle School Weights (72-235)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::MS_GIRLS_WEIGHT_CLASSES}",data: { confirm: 'Are you sure? This will delete all current weights.' } %></li>
|
<li><%= link_to "Create Girls Middle School Weights (72-235)" , "/tournaments/#{@tournament.id}/create_custom_weights?customValue=#{Weight::MS_GIRLS_WEIGHT_CLASSES}",data: { turbo_method: :get, turbo_confirm: 'Are you sure? This will delete all current weights.' } %></li>
|
||||||
<li><strong>Tournament Actions</strong></li>
|
<li><strong>Tournament Actions</strong></li>
|
||||||
<li><%= link_to "Calculate Team Scores" , "/tournaments/#{@tournament.id}/calculate_team_scores", :method => :put %></li>
|
<li><%= link_to "Calculate Team Scores" , "/tournaments/#{@tournament.id}/calculate_team_scores", data: { turbo_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 "Generate Brackets" , "/tournaments/#{@tournament.id}/generate_matches", data: { turbo_method: :get, turbo_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>
|
<li><%= link_to "Export Data" , "/tournaments/#{@tournament.id}/export?print=true", target: :_blank %></li>
|
||||||
</ul>
|
</ul>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -69,4 +70,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -36,7 +36,11 @@
|
|||||||
|
|
||||||
<div id="page-content">
|
<div id="page-content">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12"><%= render 'layouts/underheader' %></div>
|
<div class="col-md-12">
|
||||||
|
<% unless hide_ads? %>
|
||||||
|
<%= render 'layouts/underheader' %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row no-margin">
|
<div class="row no-margin">
|
||||||
<div class="col-md-12" style="padding-left: 2%;">
|
<div class="col-md-12" style="padding-left: 2%;">
|
||||||
@@ -58,4 +62,3 @@
|
|||||||
</body>
|
</body>
|
||||||
<% end %>
|
<% end %>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<td><%= Array(rule.rounds).join(", ") %></td>
|
<td><%= Array(rule.rounds).join(", ") %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to '', edit_tournament_mat_assignment_rule_path(@tournament, rule), class: "fas fa-edit" %>
|
<%= link_to '', edit_tournament_mat_assignment_rule_path(@tournament, rule), class: "fas fa-edit" %>
|
||||||
<%= link_to '', tournament_mat_assignment_rule_path(@tournament, rule), method: :delete, data: { confirm: "Are you sure?" }, class: "fas fa-trash-alt" %>
|
<%= link_to '', tournament_mat_assignment_rule_path(@tournament, rule), data: { turbo_method: :delete, turbo_confirm: "Are you sure?" }, class: "fas fa-trash-alt" %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
34
app/views/matches/edit_assignment.html.erb
Normal file
34
app/views/matches/edit_assignment.html.erb
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<h1>Assign Mat/Queue for Match <%= @match.bout_number %></h1>
|
||||||
|
|
||||||
|
<% if @current_mat %>
|
||||||
|
<p>Current Assignment: Mat <%= @current_mat.name %><%= @current_queue_position ? " (Queue #{@current_queue_position})" : "" %></p>
|
||||||
|
<% else %>
|
||||||
|
<p>Current Assignment: Unassigned</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= form_with model: @match, url: update_assignment_match_path(@match), method: :patch do |f| %>
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label :mat_id, "Mat" %><br>
|
||||||
|
<%= f.collection_select :mat_id, @mats, :id, :name, { include_blank: "Unassigned" } %>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div class="field">
|
||||||
|
<%= f.label :queue_position, "Queue Position" %><br>
|
||||||
|
<%= f.select :queue_position,
|
||||||
|
options_for_select(
|
||||||
|
[
|
||||||
|
["On Mat (Queue 1)", 1],
|
||||||
|
["On Deck (Queue 2)", 2],
|
||||||
|
["In The Hole (Queue 3)", 3],
|
||||||
|
["Warm Up (Queue 4)", 4]
|
||||||
|
],
|
||||||
|
@current_queue_position
|
||||||
|
),
|
||||||
|
include_blank: "Select position"
|
||||||
|
%>
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<div class="actions">
|
||||||
|
<%= f.submit "Update Assignment", class: "btn btn-success" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
37
app/views/mats/_current_match.html.erb
Normal file
37
app/views/mats/_current_match.html.erb
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<% @mat = mat %>
|
||||||
|
<% @match = local_assigns[:match] || mat.queue1_match %>
|
||||||
|
<% @next_match = local_assigns[:next_match] || mat.queue2_match %>
|
||||||
|
<% @show_next_bout_button = local_assigns.key?(:show_next_bout_button) ? local_assigns[:show_next_bout_button] : true %>
|
||||||
|
|
||||||
|
<% @wrestlers = [] %>
|
||||||
|
<% if @match %>
|
||||||
|
<% 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 %>
|
||||||
|
|
||||||
|
<% if @match %>
|
||||||
|
<%= render "matches/matchstats" %>
|
||||||
|
<% else %>
|
||||||
|
<p>No matches assigned to this mat.</p>
|
||||||
|
<% end %>
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
<h3>Mat <%= @mat.name %></h3>
|
<h3>Mat <%= @mat.name %></h3>
|
||||||
<h3>Tournament: <%= @mat.tournament.name %></h3>
|
<h3>Tournament: <%= @mat.tournament.name %></h3>
|
||||||
|
|
||||||
<% if @match %>
|
<%= turbo_stream_from @mat %>
|
||||||
<%= render 'matches/matchstats' %>
|
|
||||||
<% else %>
|
|
||||||
<p>No matches assigned to this mat.</p>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
|
<%= turbo_frame_tag dom_id(@mat, :current_match) do %>
|
||||||
|
<%= render "mats/current_match",
|
||||||
|
mat: @mat,
|
||||||
|
match: @match,
|
||||||
|
next_match: @next_match,
|
||||||
|
show_next_bout_button: @show_next_bout_button %>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -76,8 +76,12 @@
|
|||||||
<% delete_wrestler_path_with_key = wrestler_path(wrestler) %>
|
<% delete_wrestler_path_with_key = wrestler_path(wrestler) %>
|
||||||
<% delete_wrestler_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
|
<% delete_wrestler_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
|
||||||
|
|
||||||
<%= link_to '', edit_wrestler_path_with_key, class: "fas fa-edit" %>
|
<%= link_to edit_wrestler_path_with_key, class: "text-decoration-none" do %>
|
||||||
<%= link_to '', delete_wrestler_path_with_key, method: :delete, data: { confirm: "Are you sure you want to delete #{wrestler.name}? This will delete all of his matches." }, class: "fas fa-trash-alt" %>
|
<span class="fas fa-edit" aria-hidden="true"></span>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to delete_wrestler_path_with_key, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete #{wrestler.name}? This will delete all of his matches." }, class: "text-decoration-none" do %>
|
||||||
|
<span class="fas fa-trash-alt" aria-hidden="true"></span>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -101,8 +105,12 @@
|
|||||||
<% delete_wrestler_path_with_key = wrestler_path(wrestler) %>
|
<% delete_wrestler_path_with_key = wrestler_path(wrestler) %>
|
||||||
<% delete_wrestler_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
|
<% delete_wrestler_path_with_key += "?school_permission_key=#{params[:school_permission_key]}" if params[:school_permission_key].present? %>
|
||||||
|
|
||||||
<%= link_to '', edit_wrestler_path_with_key, class: "fas fa-edit" %>
|
<%= link_to edit_wrestler_path_with_key, class: "text-decoration-none" do %>
|
||||||
<%= link_to '', delete_wrestler_path_with_key, method: :delete, data: { confirm: "Are you sure you want to delete #{wrestler.name}? This will delete all of his matches." }, class: "fas fa-trash-alt" %>
|
<span class="fas fa-edit" aria-hidden="true"></span>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to delete_wrestler_path_with_key, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete #{wrestler.name}? This will delete all of his matches." }, class: "text-decoration-none" do %>
|
||||||
|
<span class="fas fa-trash-alt" aria-hidden="true"></span>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -111,6 +119,6 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<% if can? :manage, @school %>
|
<%# if can? :manage, @school %>
|
||||||
<%= render 'baums_roster_import' %>
|
<%#= render 'baums_roster_import' %>
|
||||||
<% end %>
|
<%# end %>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<%= link_to '', edit_tournament_path(tournament), :class=>"fas fa-edit" %>
|
<%= link_to '', edit_tournament_path(tournament), :class=>"fas fa-edit" %>
|
||||||
<% if can? :destroy, tournament %>
|
<% if can? :destroy, tournament %>
|
||||||
<%= link_to '', tournament, method: :delete, data: { confirm: "Are you sure you want to delete #{tournament.name}?" }, :class=>"fas fa-trash-alt" %>
|
<%= link_to '', tournament, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete #{tournament.name}?" }, :class=>"fas fa-trash-alt" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -55,4 +55,4 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ and will also delete all of your current data. It's best to use the create backu
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Backup Created At</th>
|
<th>Backup Created At</th>
|
||||||
<th>Backup Reason</th>
|
<th>Backup Reason</th>
|
||||||
<th><%= link_to ' Create New Backup', tournament_tournament_backups_path(@tournament), method: :post, class: 'fas fa-plus'%></th>
|
<th><%= link_to ' Create New Backup', tournament_tournament_backups_path(@tournament), data: { turbo_method: :post }, class: 'fas fa-plus'%></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -19,20 +19,20 @@ and will also delete all of your current data. It's best to use the create backu
|
|||||||
</td>
|
</td>
|
||||||
<td><%= backup.backup_reason.presence || 'No reason provided' %></td>
|
<td><%= backup.backup_reason.presence || 'No reason provided' %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to '', restore_tournament_tournament_backup_path(@tournament, backup), method: :post, data: { confirm: "This will restore the backup from #{backup.created_at.strftime('%Y-%m-%d %H:%M:%S')}. It will delete all current data from the tournament in order to restore the backup." }, class: 'fas fa-undo-alt text-warning', title: 'Restore Backup' %>
|
<%= link_to '', restore_tournament_tournament_backup_path(@tournament, backup), data: { turbo_method: :post, turbo_confirm: "This will restore the backup from #{backup.created_at.strftime('%Y-%m-%d %H:%M:%S')}. It will delete all current data from the tournament in order to restore the backup." }, class: 'fas fa-undo-alt text-warning', title: 'Restore Backup' %>
|
||||||
<%= link_to '', tournament_tournament_backup_path(@tournament, backup), method: :delete, data: { confirm: 'Are you sure you want to delete this backup?' }, class: 'fas fa-trash-alt', title: 'Delete Backup' %>
|
<%= link_to '', tournament_tournament_backup_path(@tournament, backup), data: { turbo_method: :delete, turbo_confirm: 'Are you sure you want to delete this backup?' }, class: 'fas fa-trash-alt', title: 'Delete Backup' %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<br><br>
|
<br><br>
|
||||||
<h3>Import Manual Backup</h3>
|
<% if ENV["RAILS_ENV"] == "development" %>
|
||||||
<p>Paste the backup text here. Note, if this is formatted wrong, you'll need to restore a backup from above to fix it and you'll see an error in your background jobs.</p>
|
<%= form_for(:tournament, url: import_manual_tournament_tournament_backups_path(@tournament)) do |f| %>
|
||||||
<%= form_for(:tournament, url: import_manual_tournament_tournament_backups_path(@tournament)) do |f| %>
|
<div class="field">
|
||||||
<div class="field">
|
<%= f.label 'Import text' %><br>
|
||||||
<%= f.label 'Import text' %><br>
|
<%= f.text_area :import_text, cols: "30", rows: "20" %>
|
||||||
<%= f.text_area :import_text, cols: "30", rows: "20" %>
|
</div>
|
||||||
</div>
|
<%= submit_tag "Import", class: "btn btn-success", data: { turbo_confirm: 'Are you sure? This will delete everything for the current tournament and restore it with the backup text pasted below.' } %>
|
||||||
<%= submit_tag "Import", class: "btn btn-success", data: { confirm: 'Are you sure? This will delete everything for the current tournament and restore it with the backup text pasted below.' } %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -2,7 +2,11 @@
|
|||||||
<div class="round">
|
<div class="round">
|
||||||
<div class="game">
|
<div class="game">
|
||||||
<div class="game-top "><%= match.w1_bracket_name.html_safe %> <span></span></div>
|
<div class="game-top "><%= match.w1_bracket_name.html_safe %> <span></span></div>
|
||||||
<div class="bout-number"><p><%= link_to match.bout_number, spectate_match_path(match) %> <%= match.bracket_score_string %></p><p><%= @winner_place %> Place Winner</p></div>
|
<% if params[:print] %>
|
||||||
|
<div class="bout-number"><p><%= match.bout_number %> <%= match.bracket_score_string %></p><p><%= @winner_place %> Place Winner</p></div>
|
||||||
|
<% else %>
|
||||||
|
<div class="bout-number"><p><%= link_to match.bout_number, spectate_match_path(match) %> <%= match.bracket_score_string %></p><p><%= @winner_place %> Place Winner</p></div>
|
||||||
|
<% end %>
|
||||||
<div class="game-bottom "><%= match.w2_bracket_name.html_safe %><span></span></div>
|
<div class="game-bottom "><%= match.w2_bracket_name.html_safe %><span></span></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ table.smallText tr td { font-size: 10px; }
|
|||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
/*background-color: #ddd;*/
|
/*background-color: #ddd;*/
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #000; /* Dark border so boxes stay visible when printed */
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ table.smallText tr td { font-size: 10px; }
|
|||||||
}
|
}
|
||||||
|
|
||||||
.game-top {
|
.game-top {
|
||||||
border-bottom:1px solid #ddd;
|
border-bottom:1px solid #000;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
min-height: 12px;
|
min-height: 12px;
|
||||||
}
|
}
|
||||||
@@ -77,13 +77,13 @@ table.smallText tr td { font-size: 10px; }
|
|||||||
}
|
}
|
||||||
|
|
||||||
.bracket-winner {
|
.bracket-winner {
|
||||||
border-bottom:1px solid #ddd;
|
border-bottom:1px solid #000;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
min-height: 12px;
|
min-height: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.game-bottom {
|
.game-bottom {
|
||||||
border-top:1px solid #ddd;
|
border-top:1px solid #000;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
min-height: 12px;
|
min-height: 12px;
|
||||||
}
|
}
|
||||||
@@ -131,4 +131,4 @@ table.smallText tr td { font-size: 10px; }
|
|||||||
<% elsif @tournament.tournament_type.include? "Regular Double Elimination" %>
|
<% elsif @tournament.tournament_type.include? "Regular Double Elimination" %>
|
||||||
<%= render 'double_elimination_bracket' %>
|
<%= render 'double_elimination_bracket' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,13 @@
|
|||||||
<% @round_matches.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
<% @round_matches.sort_by{|m| m.bracket_position_number}.each do |match| %>
|
||||||
<div class="game">
|
<div class="game">
|
||||||
<div class="game-top "><%= match.w1_bracket_name.html_safe %> <span></span></div>
|
<div class="game-top "><%= match.w1_bracket_name.html_safe %> <span></span></div>
|
||||||
<div class="bout-number"><%= link_to match.bout_number, spectate_match_path(match) %> <%= match.bracket_score_string %> </div>
|
<% if params[:print] %>
|
||||||
|
<div class="bout-number"><%= match.bout_number %> <%= match.bracket_score_string %> </div>
|
||||||
|
<% else %>
|
||||||
|
<div class="bout-number"><%= link_to match.bout_number, spectate_match_path(match) %> <%= match.bracket_score_string %> </div>
|
||||||
|
<% end %>
|
||||||
|
<div class="bout-number">Round <%= match.round %></div>
|
||||||
|
<div class="bout-number"><%= match.bracket_position %></div>
|
||||||
<div class="game-bottom "><%= match.w2_bracket_name.html_safe %><span></span></div>
|
<div class="game-bottom "><%= match.w2_bracket_name.html_safe %><span></span></div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
34
app/views/tournaments/_up_matches_mat_row.html.erb
Normal file
34
app/views/tournaments/_up_matches_mat_row.html.erb
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<% queue1_match, queue2_match, queue3_match, queue4_match = mat.queue_matches %>
|
||||||
|
<% cache ["up_matches_mat_row", mat, mat.queue1, mat.queue2, mat.queue3, mat.queue4] do %>
|
||||||
|
<tr>
|
||||||
|
<td><%= mat.name %></td>
|
||||||
|
<td>
|
||||||
|
<% if queue1_match %><strong><%= queue1_match.bout_number %></strong> (<%= queue1_match.bracket_position %>)<br>
|
||||||
|
<%= queue1_match.weight_max %> lbs
|
||||||
|
<br><%= queue1_match.w1_bracket_name %> vs. <br>
|
||||||
|
<%= queue1_match.w2_bracket_name %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if queue2_match %><strong><%= queue2_match.bout_number %></strong> (<%= queue2_match.bracket_position %>)<br>
|
||||||
|
<%= queue2_match.weight_max %> lbs
|
||||||
|
<br><%= queue2_match.w1_bracket_name %> vs. <br>
|
||||||
|
<%= queue2_match.w2_bracket_name %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if queue3_match %><strong><%= queue3_match.bout_number %></strong> (<%= queue3_match.bracket_position %>)<br>
|
||||||
|
<%= queue3_match.weight_max %> lbs
|
||||||
|
<br><%= queue3_match.w1_bracket_name %> vs. <br>
|
||||||
|
<%= queue3_match.w2_bracket_name %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<% if queue4_match %><strong><%= queue4_match.bout_number %></strong> (<%= queue4_match.bracket_position %>)<br>
|
||||||
|
<%= queue4_match.weight_max %> lbs
|
||||||
|
<br><%= queue4_match.w1_bracket_name %> vs. <br>
|
||||||
|
<%= queue4_match.w2_bracket_name %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
@@ -42,10 +42,10 @@
|
|||||||
<% @users_delegates.each do |delegate| %>
|
<% @users_delegates.each do |delegate| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= delegate.user.email %></td>
|
<td><%= delegate.user.email %></td>
|
||||||
<td><%= link_to 'Remove permissions', "/tournaments/#{@tournament.id}/#{delegate.id}/remove_delegate", method: :delete, confirm: 'Are you sure?', :class=>"btn btn-danger btn-sm" %></td>
|
<td><%= link_to 'Remove permissions', "/tournaments/#{@tournament.id}/#{delegate.id}/remove_delegate", data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
"attributes": <%= @tournament.attributes.to_json %>,
|
"attributes": <%= @tournament.attributes.to_json %>,
|
||||||
"schools": <%= @tournament.schools.map(&:attributes).to_json %>,
|
"schools": <%= @tournament.schools.map(&:attributes).to_json %>,
|
||||||
"weights": <%= @tournament.weights.map(&:attributes).to_json %>,
|
"weights": <%= @tournament.weights.map(&:attributes).to_json %>,
|
||||||
"mats": <%= @tournament.mats.map(&:attributes).to_json %>,
|
"mats": <%= @tournament.mats.map { |mat| mat.attributes.merge(
|
||||||
|
{
|
||||||
|
"queue_bout_numbers": mat.queue_matches.map { |match| match&.bout_number }
|
||||||
|
}
|
||||||
|
) }.to_json %>,
|
||||||
"wrestlers": <%= @tournament.wrestlers.map { |wrestler| wrestler.attributes.merge(
|
"wrestlers": <%= @tournament.wrestlers.map { |wrestler| wrestler.attributes.merge(
|
||||||
{
|
{
|
||||||
"school": wrestler.school&.attributes,
|
"school": wrestler.school&.attributes,
|
||||||
@@ -20,4 +24,4 @@
|
|||||||
}
|
}
|
||||||
) }.to_json %>
|
) }.to_json %>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,85 @@
|
|||||||
<h1>Upcoming Tournaments</h1> <%= form_tag(tournaments_path, :method => "get", id: "search-form") do %>
|
<h1>Upcoming Tournaments</h1>
|
||||||
<%= text_field_tag :search, params[:search], placeholder: "Search Tournaments" %>
|
<%= form_tag(tournaments_path, :method => "get", id: "search-form") do %>
|
||||||
<%= submit_tag "Search" %>
|
<%= text_field_tag :search, params[:search], placeholder: "Search Tournaments" %>
|
||||||
<% end %>
|
<%= submit_tag "Search" %>
|
||||||
<p>Search by name or date YYYY-MM-DD</p>
|
<% end %>
|
||||||
<script>
|
<p>Search by name or date YYYY-MM-DD</p>
|
||||||
// $(document).ready(function() {
|
|
||||||
// $('#tournamentList').dataTable();
|
|
||||||
// pagingType: "bootstrap";
|
|
||||||
// } );
|
|
||||||
</script>
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<table class="table table-hover table-condensed" id="tournamentList">
|
<table class="table table-hover table-condensed" id="tournamentList">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th><% if user_signed_in? %><%= link_to ' New Tournament', new_tournament_path, :class=>"fas fa-plus" %></th><% end %>
|
<th>
|
||||||
|
<% if user_signed_in? %>
|
||||||
|
<%= link_to ' New Tournament', new_tournament_path, :class=>"fas fa-plus" %>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @tournaments.each do |tournament| %>
|
<% @tournaments.each do |tournament| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to "#{tournament.name}", tournament %></td>
|
<td><%= link_to tournament.name, tournament %></td>
|
||||||
<td><%= tournament.date %></td>
|
<td><%= tournament.date %></td>
|
||||||
<td>
|
<td>
|
||||||
<% if can? :manage, tournament %>
|
<% if can? :manage, tournament %>
|
||||||
<%= link_to '', edit_tournament_path(tournament), :class=>"fas fa-edit" %>
|
<%= link_to '', edit_tournament_path(tournament), :class=>"fas fa-edit" %>
|
||||||
<% if can? :destroy, tournament %>
|
<% if can? :destroy, tournament %>
|
||||||
<%= link_to '', tournament, method: :delete, data: { confirm: "Are you sure you want to delete #{tournament.name}?" }, :class=>"fas fa-trash-alt" %>
|
<%= link_to '', tournament, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete #{tournament.name}?" }, :class=>"fas fa-trash-alt" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br>
|
<%# Pagination controls %>
|
||||||
|
<% if @total_pages.present? && @total_pages > 1 %>
|
||||||
|
<nav aria-label="Tournaments pagination">
|
||||||
|
<ul class="pagination">
|
||||||
|
<%# Previous link %>
|
||||||
|
<% if @page > 1 %>
|
||||||
|
<li class="page-item">
|
||||||
|
<%= link_to 'Previous', tournaments_path(page: @page - 1, search: params[:search]), class: "page-link" %>
|
||||||
|
</li>
|
||||||
|
<% else %>
|
||||||
|
<li class="page-item disabled"><span class="page-link">Previous</span></li>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%# Page number links (limit displayed pages for large counts) %>
|
||||||
|
<% window = 5
|
||||||
|
left = [1, @page - window/2].max
|
||||||
|
right = [@total_pages, left + window - 1].min
|
||||||
|
left = [1, right - window + 1].max
|
||||||
|
%>
|
||||||
|
<% (left..right).each do |p| %>
|
||||||
|
<% if p == @page %>
|
||||||
|
<li class="page-item active"><span class="page-link"><%= p %></span></li>
|
||||||
|
<% else %>
|
||||||
|
<li class="page-item"><%= link_to p, tournaments_path(page: p, search: params[:search]), class: "page-link" %></li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%# Next link %>
|
||||||
|
<% if @page < @total_pages %>
|
||||||
|
<li class="page-item">
|
||||||
|
<%= link_to 'Next', tournaments_path(page: @page + 1, search: params[:search]), class: "page-link" %>
|
||||||
|
</li>
|
||||||
|
<% else %>
|
||||||
|
<li class="page-item disabled"><span class="page-link">Next</span></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<p class="text-muted">
|
||||||
|
<% start_index = ((@page - 1) * @per_page) + 1
|
||||||
|
end_index = [@page * @per_page, @total_count].min
|
||||||
|
%>
|
||||||
|
Showing <%= start_index %> - <%= end_index %> of <%= @total_count %> tournaments
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|||||||
@@ -28,9 +28,13 @@
|
|||||||
<td><%= match.finished %></td>
|
<td><%= match.finished %></td>
|
||||||
<td><%= link_to 'Show', match, :class=>"btn btn-default btn-sm" %>
|
<td><%= link_to 'Show', match, :class=>"btn btn-default btn-sm" %>
|
||||||
<%= link_to 'Edit Wrestlers', edit_match_path(match), :class=>"btn btn-primary btn-sm" %>
|
<%= link_to 'Edit Wrestlers', edit_match_path(match), :class=>"btn btn-primary btn-sm" %>
|
||||||
|
<%= link_to 'Edit Mat/Queue', edit_assignment_match_path(match), :class=>"btn btn-primary btn-sm" %>
|
||||||
<%= link_to 'Stat Match', "/matches/#{match.id}/stat", :class=>"btn btn-primary btn-sm" %>
|
<%= link_to 'Stat Match', "/matches/#{match.id}/stat", :class=>"btn btn-primary btn-sm" %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<br>
|
||||||
|
<p>Total matches without byes: <%= @matches.select{|m| m.loser1_name != 'BYE' and m.loser2_name != 'BYE'}.size %></p>
|
||||||
|
<p>Unfinished matches: <%= @matches.select{|m| m.finished != 1 and m.loser1_name != 'BYE' and m.loser2_name != 'BYE'}.size %></p>
|
||||||
|
|||||||
50
app/views/tournaments/qrcode.html.erb
Normal file
50
app/views/tournaments/qrcode.html.erb
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<style>
|
||||||
|
.qr-page {
|
||||||
|
min-height: 100vh;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr-page h1 {
|
||||||
|
margin: 0 0 24px 0;
|
||||||
|
font-size: 40px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr-code {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr-code svg {
|
||||||
|
width: min(80vmin, 720px);
|
||||||
|
height: auto;
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="qr-page">
|
||||||
|
<h1><%= @tournament.name %> Brackets and Results Available Here</h1>
|
||||||
|
<div class="qr-code">
|
||||||
|
<%= raw @qrcode.as_svg(
|
||||||
|
offset: 0,
|
||||||
|
color: "000",
|
||||||
|
shape_rendering: "crispEdges",
|
||||||
|
module_size: 8,
|
||||||
|
standalone: true
|
||||||
|
) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><%= delegate.user.email %></td>
|
<td><%= delegate.user.email %></td>
|
||||||
<td><%= delegate.school.name %></td>
|
<td><%= delegate.school.name %></td>
|
||||||
<td><%= link_to 'Remove permissions', "/tournaments/#{@tournament.id}/#{delegate.id}/remove_school_delegate", method: :delete, confirm: 'Are you sure?', :class=>"btn btn-danger btn-sm" %></td>
|
<td><%= link_to 'Remove permissions', "/tournaments/#{@tournament.id}/#{delegate.id}/remove_school_delegate", data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -70,9 +70,13 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<% if can? :manage, school %>
|
<% if can? :manage, school %>
|
||||||
<%= link_to '', edit_school_path(school), :class=>"fas fa-edit" %>
|
<%= link_to edit_school_path(school), class: "text-decoration-none" do %>
|
||||||
|
<span class="fas fa-edit" aria-hidden="true"></span>
|
||||||
|
<% end %>
|
||||||
<% if can? :manage, @tournament %>
|
<% 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" %>
|
<%= link_to school, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete #{school.name}?" }, class: "text-decoration-none" do %>
|
||||||
|
<span class="fas fa-trash-alt" aria-hidden="true"></span>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
@@ -105,8 +109,12 @@
|
|||||||
<td><%= weight.bracket_size %></td>
|
<td><%= weight.bracket_size %></td>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, @tournament %>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to '', edit_weight_path(weight), :class=>"fas fa-edit" %>
|
<%= link_to edit_weight_path(weight), class: "text-decoration-none" do %>
|
||||||
<%= link_to '', weight, method: :delete, data: { confirm: "Are you sure you want to delete the #{weight.max} weight class?" }, :class=>"fas fa-trash-alt" %>
|
<span class="fas fa-edit" aria-hidden="true"></span>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to weight, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete the #{weight.max} weight class?" }, class: "text-decoration-none" do %>
|
||||||
|
<span class="fas fa-trash-alt" aria-hidden="true"></span>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -130,8 +138,10 @@
|
|||||||
<td><%= link_to "Mat #{mat.name}", mat %></td>
|
<td><%= link_to "Mat #{mat.name}", mat %></td>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, @tournament %>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to '', mat, method: :delete, data: { confirm: "Are you sure you want to delete Mat #{mat.name}?" }, :class=>"fas fa-trash-alt" %>
|
<%= link_to mat, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete Mat #{mat.name}?" }, class: "text-decoration-none" do %>
|
||||||
<%= link_to '', "/mats/#{mat.id}/assign_next_match", method: :post, :class=>"fas fa-solid fa-arrow-right" %>
|
<span class="fas fa-trash-alt" aria-hidden="true"></span>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to '', "/mats/#{mat.id}/assign_next_match", data: { turbo_method: :post }, :class=>"fas fa-solid fa-arrow-right" %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -47,10 +47,10 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= point_adjustment.points %></td>
|
<td><%= point_adjustment.points %></td>
|
||||||
<td><%= link_to 'Remove Point Adjustment', "/tournaments/#{@tournament.id}/#{point_adjustment.id}/remove_teampointadjust", method: :delete, confirm: 'Are you sure?', :class=>"btn btn-danger btn-sm" %></td>
|
<td><%= link_to 'Remove Point Adjustment', "/tournaments/#{@tournament.id}/#{point_adjustment.id}/remove_teampointadjust", data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' }, :class=>"btn btn-danger btn-sm" %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,11 +1,26 @@
|
|||||||
<% cache ["#{@tournament.id}_up_matches", @tournament] do %>
|
|
||||||
<script>
|
<script>
|
||||||
// $(document).ready(function() {
|
// $(document).ready(function() {
|
||||||
// $('#matchList').dataTable();
|
// $('#matchList').dataTable();
|
||||||
// } );
|
// } );
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
setTimeout("location.reload(true);",30000);
|
const setUpMatchesRefresh = () => {
|
||||||
|
if (window.__upMatchesRefreshTimeout) {
|
||||||
|
clearTimeout(window.__upMatchesRefreshTimeout);
|
||||||
|
}
|
||||||
|
window.__upMatchesRefreshTimeout = setTimeout(() => {
|
||||||
|
window.location.reload(true);
|
||||||
|
}, 30000);
|
||||||
|
};
|
||||||
|
|
||||||
|
document.addEventListener("turbo:load", setUpMatchesRefresh);
|
||||||
|
// turbo:before-cache stops the timer refresh from occurring if you navigate away from up_matches
|
||||||
|
document.addEventListener("turbo:before-cache", () => {
|
||||||
|
if (window.__upMatchesRefreshTimeout) {
|
||||||
|
clearTimeout(window.__upMatchesRefreshTimeout);
|
||||||
|
window.__upMatchesRefreshTimeout = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
@@ -26,13 +41,7 @@
|
|||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @mats.each.map do |m| %>
|
<% @mats.each.map do |m| %>
|
||||||
<tr>
|
<%= render "up_matches_mat_row", mat: m %>
|
||||||
<td><%= m.name %></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 %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -64,4 +73,3 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -1,48 +1,50 @@
|
|||||||
<h3>Weight Class:<%= @weight.max %> <% if can? :manage, @tournament %><%= link_to " Edit", edit_weight_path(@weight), :class=>"fas fa-edit" %><% end %></h3>
|
<h3>Weight Class:<%= @weight.max %> <% if can? :manage, @tournament %><%= link_to edit_weight_path(@weight), class: "text-decoration-none" do %><span class="fas fa-edit" aria-hidden="true"></span><% end %><% end %></h3>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<table class="table table-hover table-condensed">
|
<%= form_tag @wrestlers_update_path do %>
|
||||||
<thead>
|
<table class="table table-hover table-condensed">
|
||||||
<tr>
|
<thead>
|
||||||
<th>Name</th>
|
<tr>
|
||||||
<th>School</th>
|
<th>Name</th>
|
||||||
<th>Seed</th>
|
<th>School</th>
|
||||||
<th>Record</th>
|
<th>Seed</th>
|
||||||
<th>Seed Criteria</th>
|
<th>Record</th>
|
||||||
<th>Extra?</th>
|
<th>Seed Criteria</th>
|
||||||
</tr>
|
<th>Extra?</th>
|
||||||
</thead>
|
</tr>
|
||||||
<tbody>
|
</thead>
|
||||||
<%= form_tag @wrestlers_update_path do %>
|
<tbody>
|
||||||
<% @wrestlers.sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]}.each do |wrestler| %>
|
<% @wrestlers.sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]}.each do |wrestler| %>
|
||||||
<% if wrestler.weight_id == @weight.id %>
|
<% if wrestler.weight_id == @weight.id %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to "#{wrestler.name}", wrestler %></td>
|
<td><%= link_to "#{wrestler.name}", wrestler %></td>
|
||||||
<td><%= wrestler.school.name %></td>
|
<td><%= wrestler.school.name %></td>
|
||||||
<td>
|
<td>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, @tournament %>
|
||||||
<%= fields_for "wrestler[]", wrestler do |w| %>
|
<%= fields_for "wrestler[]", wrestler do |w| %>
|
||||||
<%= w.text_field :original_seed %>
|
<%= w.text_field :original_seed %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= wrestler.original_seed %>
|
<%= wrestler.original_seed %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
|
||||||
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
|
|
||||||
<td><%= wrestler.criteria %> Win <%= wrestler.season_win_percentage %>%</td>
|
|
||||||
<td><% if wrestler.extra? == true %>
|
|
||||||
Yes
|
|
||||||
<% end %></td>
|
|
||||||
<% if can? :manage, @tournament %>
|
|
||||||
<td>
|
|
||||||
<%= link_to '', wrestler, method: :delete, data: { confirm: "Are you sure you want to delete #{wrestler.name}? THIS WILL DELETE ALL MATCHES." } , :class=>"fas fa-trash-alt" %>
|
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
|
||||||
</tr>
|
<td><%= wrestler.criteria %> Win <%= wrestler.season_win_percentage %>%</td>
|
||||||
<% end %>
|
<td><% if wrestler.extra? == true %>
|
||||||
<% end %>
|
Yes
|
||||||
</tbody>
|
<% end %></td>
|
||||||
</table>
|
<% if can? :manage, @tournament %>
|
||||||
|
<td>
|
||||||
|
<%= link_to wrestler, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete #{wrestler.name}? THIS WILL DELETE ALL MATCHES." }, class: "text-decoration-none" do %>
|
||||||
|
<span class="fas fa-trash-alt" aria-hidden="true"></span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
<br><p>*All wrestlers without a seed (determined by tournament director) will be assigned a random bracket line.</p>
|
<br><p>*All wrestlers without a seed (determined by tournament director) will be assigned a random bracket line.</p>
|
||||||
<% if can? :manage, @tournament %>
|
<% if can? :manage, @tournament %>
|
||||||
<br>
|
<br>
|
||||||
@@ -81,4 +83,4 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
6
bin/bundler-audit
Executable file
6
bin/bundler-audit
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
require_relative "../config/boot"
|
||||||
|
require "bundler/audit/cli"
|
||||||
|
|
||||||
|
ARGV.concat %w[ --config config/bundler-audit.yml ] if ARGV.empty? || ARGV.include?("check")
|
||||||
|
Bundler::Audit::CLI.start
|
||||||
6
bin/ci
Executable file
6
bin/ci
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
require_relative "../config/boot"
|
||||||
|
require "active_support/continuous_integration"
|
||||||
|
|
||||||
|
CI = ActiveSupport::ContinuousIntegration
|
||||||
|
require_relative "../config/ci.rb"
|
||||||
4
bin/dev
4
bin/dev
@@ -1,4 +1,2 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
exec "./bin/rails", "server", *ARGV
|
||||||
# Start Rails server with defaults
|
|
||||||
exec "bin/rails", "server", *ARGV
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
require "rubygems"
|
require "rubygems"
|
||||||
require "bundler/setup"
|
require "bundler/setup"
|
||||||
|
|
||||||
# explicit rubocop config increases performance slightly while avoiding config confusion.
|
# Explicit RuboCop config increases performance slightly while avoiding config confusion.
|
||||||
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
|
ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
|
||||||
|
|
||||||
load Gem.bin_path("rubocop", "rubocop")
|
load Gem.bin_path("rubocop", "rubocop")
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ project_dir="$(dirname $( dirname $(readlink -f ${BASH_SOURCE[0]})))"
|
|||||||
cd ${project_dir}
|
cd ${project_dir}
|
||||||
bundle exec rake db:migrate RAILS_ENV=test
|
bundle exec rake db:migrate RAILS_ENV=test
|
||||||
CI=true brakeman
|
CI=true brakeman
|
||||||
bundle exec bundle-audit check --update
|
bundle audit
|
||||||
bundle exec rake test
|
rails test -v
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ FileUtils.chdir APP_ROOT do
|
|||||||
|
|
||||||
puts "\n== Preparing database =="
|
puts "\n== Preparing database =="
|
||||||
system! "bin/rails db:prepare"
|
system! "bin/rails db:prepare"
|
||||||
|
system! "bin/rails db:reset" if ARGV.include?("--reset")
|
||||||
|
|
||||||
puts "\n== Removing old logs and tempfiles =="
|
puts "\n== Removing old logs and tempfiles =="
|
||||||
system! "bin/rails log:clear tmp:clear"
|
system! "bin/rails log:clear tmp:clear"
|
||||||
|
|||||||
@@ -25,9 +25,6 @@ module Wrestling
|
|||||||
config.active_record.schema_format = :ruby
|
config.active_record.schema_format = :ruby
|
||||||
config.active_record.dump_schemas = :all
|
config.active_record.dump_schemas = :all
|
||||||
|
|
||||||
# Fix deprecation warning for to_time in Rails 8.1
|
|
||||||
config.active_support.to_time_preserves_timezone = :zone
|
|
||||||
|
|
||||||
# Please, add to the `ignore` list any other `lib` subdirectories that do
|
# Please, add to the `ignore` list any other `lib` subdirectories that do
|
||||||
# not contain `.rb` files, or that should not be reloaded or eager loaded.
|
# not contain `.rb` files, or that should not be reloaded or eager loaded.
|
||||||
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
# Common ones are `templates`, `generators`, or `middleware`, for example.
|
||||||
@@ -55,5 +52,7 @@ module Wrestling
|
|||||||
# Set cache format version to a value supported by Rails 8.0
|
# Set cache format version to a value supported by Rails 8.0
|
||||||
# Valid values are 7.0 or 7.1
|
# Valid values are 7.0 or 7.1
|
||||||
config.active_support.cache_format_version = 7.1
|
config.active_support.cache_format_version = 7.1
|
||||||
|
|
||||||
|
config.load_defaults 8.1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
5
config/bundler-audit.yml
Normal file
5
config/bundler-audit.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Audit all gems listed in the Gemfile for known security problems by running bin/bundler-audit.
|
||||||
|
# CVEs that are not relevant to the application can be enumerated on the ignore list below.
|
||||||
|
|
||||||
|
ignore:
|
||||||
|
- CVE-THAT-DOES-NOT-APPLY
|
||||||
24
config/ci.rb
Normal file
24
config/ci.rb
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Run using bin/ci
|
||||||
|
|
||||||
|
CI.run do
|
||||||
|
step "Setup", "bin/setup --skip-server"
|
||||||
|
|
||||||
|
step "Style: Ruby", "bin/rubocop"
|
||||||
|
|
||||||
|
step "Security: Gem audit", "bin/bundler-audit"
|
||||||
|
step "Security: Importmap vulnerability audit", "bin/importmap audit"
|
||||||
|
step "Security: Brakeman code analysis", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error"
|
||||||
|
step "Tests: Rails", "bin/rails test"
|
||||||
|
step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant"
|
||||||
|
|
||||||
|
# Optional: Run system tests
|
||||||
|
# step "Tests: System", "bin/rails test:system"
|
||||||
|
|
||||||
|
# Optional: set a green GitHub commit status to unblock PR merge.
|
||||||
|
# Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`.
|
||||||
|
# if success?
|
||||||
|
# step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
|
||||||
|
# else
|
||||||
|
# failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
|
||||||
|
# end
|
||||||
|
end
|
||||||
@@ -99,4 +99,7 @@ Rails.application.configure do
|
|||||||
|
|
||||||
# Nobuild in development
|
# Nobuild in development
|
||||||
config.assets.build_assets = false
|
config.assets.build_assets = false
|
||||||
|
|
||||||
|
MissionControl::Jobs.http_basic_auth_user = "dev"
|
||||||
|
MissionControl::Jobs.http_basic_auth_password = "secret"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -120,4 +120,7 @@ Rails.application.configure do
|
|||||||
config.assets.compile = true
|
config.assets.compile = true
|
||||||
# Generate digests for assets URLs.
|
# Generate digests for assets URLs.
|
||||||
config.assets.digest = true
|
config.assets.digest = true
|
||||||
|
|
||||||
|
MissionControl::Jobs.http_basic_auth_user = ENV["WRESTLINGDEV_MISSION_CONTROL_USER"]
|
||||||
|
MissionControl::Jobs.http_basic_auth_password =ENV["WRESTLINGDEV_MISSION_CONTROL_PASSWORD"]
|
||||||
end
|
end
|
||||||
|
|||||||
7
config/initializers/assets.rb
Normal file
7
config/initializers/assets.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Be sure to restart your server when you modify this file.
|
||||||
|
|
||||||
|
# Version of your assets, change this if you want to expire all your assets.
|
||||||
|
Rails.application.config.assets.version = "1.0"
|
||||||
|
|
||||||
|
# Add additional assets to the asset load path.
|
||||||
|
# Rails.application.config.assets.paths << Emoji.images_path
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
Wrestling::Application.routes.draw do
|
Wrestling::Application.routes.draw do
|
||||||
# Mount Action Cable server
|
# Mount Action Cable server
|
||||||
mount ActionCable.server => '/cable'
|
mount ActionCable.server => '/cable'
|
||||||
|
mount MissionControl::Jobs::Engine, at: "/jobs"
|
||||||
|
|
||||||
resources :mats
|
resources :mats
|
||||||
post "mats/:id/assign_next_match" => "mats#assign_next_match", :as => :assign_next_match
|
post "mats/:id/assign_next_match" => "mats#assign_next_match", :as => :assign_next_match
|
||||||
@@ -9,6 +10,8 @@ Wrestling::Application.routes.draw do
|
|||||||
member do
|
member do
|
||||||
get :stat
|
get :stat
|
||||||
get :spectate
|
get :spectate
|
||||||
|
get :edit_assignment
|
||||||
|
patch :update_assignment
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -70,6 +73,7 @@ Wrestling::Application.routes.draw do
|
|||||||
get 'tournaments/:id/bout_sheets' => 'tournaments#bout_sheets'
|
get 'tournaments/:id/bout_sheets' => 'tournaments#bout_sheets'
|
||||||
get 'tournaments/:id/no_matches' => 'tournaments#no_matches'
|
get 'tournaments/:id/no_matches' => 'tournaments#no_matches'
|
||||||
get 'tournaments/:id/matches' => 'tournaments#matches'
|
get 'tournaments/:id/matches' => 'tournaments#matches'
|
||||||
|
get 'tournaments/:id/qrcode' => 'tournaments#qrcode'
|
||||||
get 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :tournament_delegate
|
get 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :tournament_delegate
|
||||||
post 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :set_tournament_delegate
|
post 'tournaments/:id/delegate' => 'tournaments#delegate', :as => :set_tournament_delegate
|
||||||
delete 'tournaments/:id/:delegate/remove_delegate' => 'tournaments#remove_delegate', :as => :delete_delegate_path
|
delete 'tournaments/:id/:delegate/remove_delegate' => 'tournaments#remove_delegate', :as => :delete_delegate_path
|
||||||
|
|||||||
49
db/migrate/20260129120000_add_queues_to_mats.rb
Normal file
49
db/migrate/20260129120000_add_queues_to_mats.rb
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
class AddQueuesToMats < ActiveRecord::Migration[7.0]
|
||||||
|
class Mat < ActiveRecord::Base
|
||||||
|
self.table_name = "mats"
|
||||||
|
has_many :matches, class_name: "AddQueuesToMats::Match", foreign_key: "mat_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
class Match < ActiveRecord::Base
|
||||||
|
self.table_name = "matches"
|
||||||
|
end
|
||||||
|
|
||||||
|
def up
|
||||||
|
add_column :mats, :queue1, :bigint
|
||||||
|
add_column :mats, :queue2, :bigint
|
||||||
|
add_column :mats, :queue3, :bigint
|
||||||
|
add_column :mats, :queue4, :bigint
|
||||||
|
|
||||||
|
add_index :mats, :queue1
|
||||||
|
add_index :mats, :queue2
|
||||||
|
add_index :mats, :queue3
|
||||||
|
add_index :mats, :queue4
|
||||||
|
|
||||||
|
say_with_time "Backfilling mat queues from unfinished matches" do
|
||||||
|
Mat.reset_column_information
|
||||||
|
Match.reset_column_information
|
||||||
|
|
||||||
|
Mat.find_each do |mat|
|
||||||
|
match_ids = mat.matches.where(finished: [nil, 0]).order(:bout_number).limit(4).pluck(:id)
|
||||||
|
mat.update_columns(
|
||||||
|
queue1: match_ids[0],
|
||||||
|
queue2: match_ids[1],
|
||||||
|
queue3: match_ids[2],
|
||||||
|
queue4: match_ids[3]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
remove_index :mats, :queue1
|
||||||
|
remove_index :mats, :queue2
|
||||||
|
remove_index :mats, :queue3
|
||||||
|
remove_index :mats, :queue4
|
||||||
|
|
||||||
|
remove_column :mats, :queue1
|
||||||
|
remove_column :mats, :queue2
|
||||||
|
remove_column :mats, :queue3
|
||||||
|
remove_column :mats, :queue4
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
class IncreaseSolidQueueJobArgumentsLimit < ActiveRecord::Migration[8.0]
|
||||||
|
def up
|
||||||
|
# Allow large payloads (e.g., pasted import text) to be enqueued without blowing up MySQL's TEXT limit (~64KB).
|
||||||
|
change_column :solid_queue_jobs, :arguments, :text, limit: 16.megabytes - 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
change_column :solid_queue_jobs, :arguments, :text
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2025_04_04_153529) do
|
ActiveRecord::Schema[8.0].define(version: 2025_05_04_190000) do
|
||||||
create_table "solid_queue_blocked_executions", force: :cascade do |t|
|
create_table "solid_queue_blocked_executions", force: :cascade do |t|
|
||||||
t.bigint "job_id", null: false
|
t.bigint "job_id", null: false
|
||||||
t.string "queue_name", null: false
|
t.string "queue_name", null: false
|
||||||
@@ -41,7 +41,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_04_04_153529) do
|
|||||||
create_table "solid_queue_jobs", force: :cascade do |t|
|
create_table "solid_queue_jobs", force: :cascade do |t|
|
||||||
t.string "queue_name", null: false
|
t.string "queue_name", null: false
|
||||||
t.string "class_name", null: false
|
t.string "class_name", null: false
|
||||||
t.text "arguments"
|
t.text "arguments", limit: 16777215
|
||||||
t.integer "priority", default: 0, null: false
|
t.integer "priority", default: 0, null: false
|
||||||
t.string "active_job_id"
|
t.string "active_job_id"
|
||||||
t.datetime "scheduled_at"
|
t.datetime "scheduled_at"
|
||||||
|
|||||||
10
db/schema.rb
10
db/schema.rb
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2025_04_15_173921) do
|
ActiveRecord::Schema[8.0].define(version: 2026_01_29_120000) do
|
||||||
create_table "mat_assignment_rules", force: :cascade do |t|
|
create_table "mat_assignment_rules", force: :cascade do |t|
|
||||||
t.bigint "tournament_id"
|
t.bigint "tournament_id"
|
||||||
t.bigint "mat_id"
|
t.bigint "mat_id"
|
||||||
@@ -56,6 +56,14 @@ ActiveRecord::Schema[8.0].define(version: 2025_04_15_173921) do
|
|||||||
t.bigint "tournament_id"
|
t.bigint "tournament_id"
|
||||||
t.datetime "created_at", precision: nil
|
t.datetime "created_at", precision: nil
|
||||||
t.datetime "updated_at", precision: nil
|
t.datetime "updated_at", precision: nil
|
||||||
|
t.bigint "queue1"
|
||||||
|
t.bigint "queue2"
|
||||||
|
t.bigint "queue3"
|
||||||
|
t.bigint "queue4"
|
||||||
|
t.index ["queue1"], name: "index_mats_on_queue1"
|
||||||
|
t.index ["queue2"], name: "index_mats_on_queue2"
|
||||||
|
t.index ["queue3"], name: "index_mats_on_queue3"
|
||||||
|
t.index ["queue4"], name: "index_mats_on_queue4"
|
||||||
t.index ["tournament_id"], name: "index_mats_on_tournament_id"
|
t.index ["tournament_id"], name: "index_mats_on_tournament_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@
|
|||||||
|
|
||||||
# Regular Double Elimination 1-8
|
# Regular Double Elimination 1-8
|
||||||
tournament = Tournament.create(id: 204, name: 'Regular Double Elimination 1-8', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Regular Double Elimination 1-8', user_id: 1, date: future_date, is_public: true)
|
tournament = Tournament.create(id: 204, name: 'Regular Double Elimination 1-8', address: 'some place', director: 'some guy', director_email: 'their@email.com', tournament_type: 'Regular Double Elimination 1-8', user_id: 1, date: future_date, is_public: true)
|
||||||
create_schools(tournament, 32)
|
create_schools(tournament, 64)
|
||||||
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
weight_classes=Weight::HS_WEIGHT_CLASSES.split(",")
|
||||||
tournament.create_pre_defined_weights(weight_classes)
|
tournament.create_pre_defined_weights(weight_classes)
|
||||||
wrestler_name_number = 1
|
wrestler_name_number = 1
|
||||||
@@ -126,6 +126,8 @@
|
|||||||
number_of_wrestlers = 32
|
number_of_wrestlers = 32
|
||||||
elsif index == 3
|
elsif index == 3
|
||||||
number_of_wrestlers = 17
|
number_of_wrestlers = 17
|
||||||
|
elsif index == 4
|
||||||
|
number_of_wrestlers = 62
|
||||||
else
|
else
|
||||||
number_of_wrestlers = 16
|
number_of_wrestlers = 16
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,9 +25,11 @@ docker-compose -f ${project_dir}/deploy/docker-compose-test.yml run --rm app bin
|
|||||||
docker-compose -f ${project_dir}/deploy/docker-compose-test.yml run --rm app bin/rails db:migrate:queue
|
docker-compose -f ${project_dir}/deploy/docker-compose-test.yml run --rm app bin/rails db:migrate:queue
|
||||||
docker-compose -f ${project_dir}/deploy/docker-compose-test.yml run --rm app bin/rails db:migrate:cable
|
docker-compose -f ${project_dir}/deploy/docker-compose-test.yml run --rm app bin/rails db:migrate:cable
|
||||||
|
|
||||||
# Start all services (will start app and others, db is already running)
|
echo "Stopping all services..."
|
||||||
|
docker-compose -f ${project_dir}/deploy/docker-compose-test.yml down
|
||||||
|
|
||||||
echo "Starting application services..."
|
echo "Starting application services..."
|
||||||
docker-compose -f ${project_dir}/deploy/docker-compose-test.yml up -d
|
docker-compose -f ${project_dir}/deploy/docker-compose-test.yml up --force-recreate --remove-orphans -d
|
||||||
|
|
||||||
# DISABLE_DATABASE_ENVIRONMENT_CHECK=1 is needed because this is "destructive" action on production
|
# DISABLE_DATABASE_ENVIRONMENT_CHECK=1 is needed because this is "destructive" action on production
|
||||||
echo Resetting the db with seed data
|
echo Resetting the db with seed data
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ services:
|
|||||||
- WRESTLINGDEV_INFLUXDB_HOST=influxdb
|
- WRESTLINGDEV_INFLUXDB_HOST=influxdb
|
||||||
- WRESTLINGDEV_INFLUXDB_PORT=8086
|
- WRESTLINGDEV_INFLUXDB_PORT=8086
|
||||||
- SOLID_QUEUE_IN_PUMA=true
|
- SOLID_QUEUE_IN_PUMA=true
|
||||||
|
- WRESTLINGDEV_MISSION_CONTROL_USER=dev
|
||||||
|
- WRESTLINGDEV_MISSION_CONTROL_PASSWORD=secret
|
||||||
networks:
|
networks:
|
||||||
database:
|
database:
|
||||||
caching:
|
caching:
|
||||||
|
|||||||
160
deploy/kubernetes/manifests/mariadb-replica-watcher.yaml
Normal file
160
deploy/kubernetes/manifests/mariadb-replica-watcher.yaml
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: mariadb-replica-watcher
|
||||||
|
labels:
|
||||||
|
app: wrestlingdev
|
||||||
|
component: mariadb-watcher
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: wrestlingdev
|
||||||
|
component: mariadb-watcher
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: wrestlingdev
|
||||||
|
component: mariadb-watcher
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: replica-watcher
|
||||||
|
image: mariadb:10.3
|
||||||
|
env:
|
||||||
|
- name: MARIADB_ROOT_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: wrestlingdev-secrets
|
||||||
|
key: dbpassword
|
||||||
|
- name: MYSQL_REPLICATION_USER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: wrestlingdev-secrets
|
||||||
|
key: replication_user
|
||||||
|
- name: MYSQL_REPLICATION_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: wrestlingdev-secrets
|
||||||
|
key: replication_password
|
||||||
|
- name: MASTER_SERVICE_HOST
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: wrestlingdev-secrets
|
||||||
|
key: replication_host
|
||||||
|
- name: REPLICA_SERVICE_HOST
|
||||||
|
value: "wrestlingdev-mariadb"
|
||||||
|
- name: DB_NAME
|
||||||
|
value: "wrestlingdev"
|
||||||
|
command:
|
||||||
|
- bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
set -euo pipefail
|
||||||
|
LOG=/var/log/replica-watcher.log
|
||||||
|
echo "replica-watcher starting: $(date -u)" >>"$LOG"
|
||||||
|
|
||||||
|
trim() { sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'; }
|
||||||
|
get_val() {
|
||||||
|
grep -m1 -E "^[[:space:]]*$1[[:space:]]*:" \
|
||||||
|
| sed -E "s/^[[:space:]]*$1[[:space:]]*:[[:space:]]*(.*)$/\1/" \
|
||||||
|
| tr -d '\r' \
|
||||||
|
| xargs
|
||||||
|
}
|
||||||
|
|
||||||
|
# initial wait
|
||||||
|
sleep 120
|
||||||
|
while true; do
|
||||||
|
echo "$(date -u) Checking SHOW SLAVE STATUS" | tee -a "$LOG"
|
||||||
|
SLAVE_RAW=$(mysql --protocol=TCP -h "$REPLICA_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" -e "SHOW SLAVE STATUS\\G" 2>>"$LOG" || true)
|
||||||
|
|
||||||
|
NEED=0
|
||||||
|
if [ -z "$SLAVE_RAW" ]; then
|
||||||
|
echo "SHOW SLAVE STATUS is empty (replication not configured / not running) -> will rebootstrap" | tee -a "$LOG"
|
||||||
|
NEED=1
|
||||||
|
else
|
||||||
|
SLAVE_IO=$(echo "$SLAVE_RAW" | get_val "Slave_IO_Running")
|
||||||
|
SLAVE_SQL=$(echo "$SLAVE_RAW" | get_val "Slave_SQL_Running")
|
||||||
|
LAST_IO_ERRNO=$(echo "$SLAVE_RAW" | get_val "Last_IO_Errno")
|
||||||
|
LAST_SQL_ERRNO=$(echo "$SLAVE_RAW" | get_val "Last_SQL_Errno")
|
||||||
|
LAST_IO_ERR=$(echo "$SLAVE_RAW" | get_val "Last_IO_Error")
|
||||||
|
LAST_SQL_ERR=$(echo "$SLAVE_RAW" | get_val "Last_SQL_Error")
|
||||||
|
|
||||||
|
echo "Slave IO='${SLAVE_IO:-}' Slave SQL='${SLAVE_SQL:-}'" | tee -a "$LOG"
|
||||||
|
echo "Last_IO_Errno='${LAST_IO_ERRNO:-}' Last_SQL_Errno='${LAST_SQL_ERRNO:-}'" | tee -a "$LOG"
|
||||||
|
echo "Last_IO_Error='${LAST_IO_ERR:-}' Last_SQL_Error='${LAST_SQL_ERR:-}'" | tee -a "$LOG"
|
||||||
|
|
||||||
|
if [ "${SLAVE_IO:-}" = "Yes" ] && [ "${SLAVE_SQL:-}" = "Yes" ] \
|
||||||
|
&& { [ -z "${LAST_IO_ERR:-}" ] || [ "${LAST_IO_ERR,,}" = "no error" ]; } \
|
||||||
|
&& { [ -z "${LAST_SQL_ERR:-}" ] || [ "${LAST_SQL_ERR,,}" = "no error" ]; } \
|
||||||
|
&& { [ -z "${LAST_IO_ERRNO:-}" ] || [ "${LAST_IO_ERRNO:-0}" = "0" ]; } \
|
||||||
|
&& { [ -z "${LAST_SQL_ERRNO:-}" ] || [ "${LAST_SQL_ERRNO:-0}" = "0" ]; }; then
|
||||||
|
echo "Both slave threads running and no replication errors -> no action" | tee -a "$LOG"
|
||||||
|
else
|
||||||
|
NOT_RUNNING=0
|
||||||
|
[ "${SLAVE_IO:-No}" != "Yes" ] && NOT_RUNNING=1
|
||||||
|
[ "${SLAVE_SQL:-No}" != "Yes" ] && NOT_RUNNING=1
|
||||||
|
HAS_ERROR=0
|
||||||
|
[ -n "${LAST_IO_ERRNO:-}" ] && [ "${LAST_IO_ERRNO:-0}" != "0" ] && HAS_ERROR=1
|
||||||
|
[ -n "${LAST_SQL_ERRNO:-}" ] && [ "${LAST_SQL_ERRNO:-0}" != "0" ] && HAS_ERROR=1
|
||||||
|
ERR_TEXT="$(printf '%s %s' "${LAST_IO_ERR:-}" "${LAST_SQL_ERR:-}" | tr '[:upper:]' '[:lower:]' | trim)"
|
||||||
|
[ -n "$ERR_TEXT" ] && [ "$ERR_TEXT" != "no error" ] && HAS_ERROR=1
|
||||||
|
|
||||||
|
echo "Decision: NOT_RUNNING=$NOT_RUNNING HAS_ERROR=$HAS_ERROR" | tee -a "$LOG"
|
||||||
|
[ $NOT_RUNNING -eq 1 ] || [ $HAS_ERROR -eq 1 ] && NEED=1 || echo "Threads healthy -> no action" | tee -a "$LOG"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $NEED -eq 1 ]; then
|
||||||
|
echo "$(date -u) Starting rebootstrap flow" | tee -a "$LOG"
|
||||||
|
|
||||||
|
MASTER_STATUS=$(mysql --protocol=TCP -h "$MASTER_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" -sse "SHOW MASTER STATUS;" 2>>"$LOG" || true)
|
||||||
|
MASTER_LOG_FILE=$(echo "$MASTER_STATUS" | awk '{print $1}' | trim || true)
|
||||||
|
MASTER_LOG_POS=$(echo "$MASTER_STATUS" | awk '{print $2}' | trim || true)
|
||||||
|
if [ -z "$MASTER_LOG_FILE" ] || [ -z "$MASTER_LOG_POS" ]; then
|
||||||
|
echo "Failed to get master position from $MASTER_SERVICE_HOST" | tee -a "$LOG"
|
||||||
|
sleep 120; continue
|
||||||
|
fi
|
||||||
|
echo "Master position: ${MASTER_LOG_FILE}:${MASTER_LOG_POS}" | tee -a "$LOG"
|
||||||
|
|
||||||
|
echo "Stopping slave on replica host" | tee -a "$LOG"
|
||||||
|
mysql --protocol=TCP -h "$REPLICA_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" -e "STOP SLAVE;" >>"$LOG" 2>&1 || true
|
||||||
|
|
||||||
|
DUMP_FILE="/tmp/${DB_NAME}_backup.sql"
|
||||||
|
echo "Dumping ${DB_NAME} from master ${MASTER_SERVICE_HOST}" | tee -a "$LOG"
|
||||||
|
if command -v timeout >/dev/null 2>&1; then
|
||||||
|
if ! timeout 300 mysqldump --protocol=TCP -h "$MASTER_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" --single-transaction "$DB_NAME" \
|
||||||
|
| tee "$DUMP_FILE" >/dev/null 2>>"$LOG"; then
|
||||||
|
echo "Dump FAILED; aborting this cycle" | tee -a "$LOG"; sleep 120; continue
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if ! mysqldump --protocol=TCP -h "$MASTER_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" --single-transaction "$DB_NAME" \
|
||||||
|
| tee "$DUMP_FILE" >/dev/null 2>>"$LOG"; then
|
||||||
|
echo "Dump FAILED; aborting this cycle" | tee -a "$LOG"; sleep 120; continue
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
ls -lh $DUMP_FILE
|
||||||
|
|
||||||
|
echo "Ensuring database '$DB_NAME' exists on replica" | tee -a "$LOG"
|
||||||
|
mysql --protocol=TCP -h "$REPLICA_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" \
|
||||||
|
-e "CREATE DATABASE IF NOT EXISTS \`$DB_NAME\`;" >>"$LOG" 2>&1
|
||||||
|
|
||||||
|
echo "Importing dump into replica host" | tee -a "$LOG"
|
||||||
|
if ! cat "$DUMP_FILE" | mysql --protocol=TCP -h "$REPLICA_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" "$DB_NAME" >>"$LOG" 2>&1; then
|
||||||
|
echo "Import FAILED; aborting this cycle (replication will not be reconfigured)" | tee -a "$LOG"
|
||||||
|
sleep 120; continue
|
||||||
|
fi
|
||||||
|
echo "Import completed successfully" | tee -a "$LOG"
|
||||||
|
|
||||||
|
echo "Reconfiguring replication to ${MASTER_SERVICE_HOST}:${MASTER_LOG_FILE}:${MASTER_LOG_POS}" | tee -a "$LOG"
|
||||||
|
mysql --protocol=TCP -h "$REPLICA_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" -e "RESET SLAVE ALL;" >>"$LOG" 2>&1 || true
|
||||||
|
mysql --protocol=TCP -h "$REPLICA_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" -e "CHANGE MASTER TO MASTER_HOST='${MASTER_SERVICE_HOST}', MASTER_USER='${MYSQL_REPLICATION_USER}', MASTER_PASSWORD='${MYSQL_REPLICATION_PASSWORD}', MASTER_LOG_FILE='${MASTER_LOG_FILE}', MASTER_LOG_POS=${MASTER_LOG_POS}; START SLAVE;" >>"$LOG" 2>&1 || true
|
||||||
|
|
||||||
|
echo "SHOW SLAVE STATUS after rebootstrap:" | tee -a "$LOG"
|
||||||
|
mysql --protocol=TCP -h "$REPLICA_SERVICE_HOST" -uroot -p"$MARIADB_ROOT_PASSWORD" -e "SHOW SLAVE STATUS\\G" >>"$LOG" 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Sleeping 120s before next check" | tee -a "$LOG"
|
||||||
|
sleep 120
|
||||||
|
done
|
||||||
|
restartPolicy: Always
|
||||||
@@ -214,6 +214,6 @@ data:
|
|||||||
# if you want to ignore dbs to replicate
|
# if you want to ignore dbs to replicate
|
||||||
# replicate-ignore-db=wrestlingtourney-queue
|
# replicate-ignore-db=wrestlingtourney-queue
|
||||||
# if you only want to replicate certain dbs
|
# if you only want to replicate certain dbs
|
||||||
replicate-do-db=wrestlingtourney
|
replicate-do-db=wrestlingdev
|
||||||
|
|
||||||
# /etc/mysql/mariadb.conf.d/70-mysettings.cnf
|
# /etc/mysql/mariadb.conf.d/70-mysettings.cnf
|
||||||
|
|||||||
@@ -56,6 +56,16 @@ spec:
|
|||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: wrestlingdev-secrets
|
name: wrestlingdev-secrets
|
||||||
key: dbpassword
|
key: dbpassword
|
||||||
|
- name: REPLICATION_USER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: wrestlingdev-secrets
|
||||||
|
key: replication_user
|
||||||
|
- name: REPLICATION_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: wrestlingdev-secrets
|
||||||
|
key: replication_password
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 3306
|
- containerPort: 3306
|
||||||
name: mariadb
|
name: mariadb
|
||||||
@@ -64,12 +74,36 @@ spec:
|
|||||||
mountPath: /var/lib/mysql
|
mountPath: /var/lib/mysql
|
||||||
- name: mysettings-config-volume
|
- name: mysettings-config-volume
|
||||||
mountPath: /etc/mysql/mariadb.conf.d
|
mountPath: /etc/mysql/mariadb.conf.d
|
||||||
|
# lifecycle: create replication user with proper privileges if it doesn't exist
|
||||||
|
lifecycle:
|
||||||
|
postStart:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
# Wait up to 60s for mysqld to be available
|
||||||
|
for i in $(seq 1 60); do
|
||||||
|
if mysqladmin ping -uroot -p"$MARIADB_ROOT_PASSWORD" --silent; then
|
||||||
|
echo "mysqld is up"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Ensuring replication user ${REPLICATION_USER} exists and has REPLICATION SLAVE privileges"
|
||||||
|
|
||||||
|
# Create the replication user if it doesn't exist and grant replication privileges.
|
||||||
|
# Use CREATE USER IF NOT EXISTS so the command is idempotent.
|
||||||
|
mysql -uroot -p"$MARIADB_ROOT_PASSWORD" -e "CREATE USER IF NOT EXISTS '${REPLICATION_USER}'@'%' IDENTIFIED BY '${REPLICATION_PASSWORD}';" 2>/dev/null || true
|
||||||
|
mysql -uroot -p"$MARIADB_ROOT_PASSWORD" -e "GRANT REPLICATION SLAVE ON *.* TO '${REPLICATION_USER}'@'%';" 2>/dev/null || true
|
||||||
|
mysql -uroot -p"$MARIADB_ROOT_PASSWORD" -e "FLUSH PRIVILEGES;" 2>/dev/null || true
|
||||||
|
echo "Replication user ready (errors ignored to avoid blocking startup)"
|
||||||
# resources:
|
# resources:
|
||||||
# limits:
|
# limits:
|
||||||
# memory: "512Mi"
|
# memory: "512Mi"
|
||||||
# requests:
|
# requests:
|
||||||
# memory: "256Mi"
|
# memory: "256Mi"
|
||||||
# cpu: "0.2"
|
|
||||||
- image: jcwimer/mariadb-rclone-backup-docker:10.3
|
- image: jcwimer/mariadb-rclone-backup-docker:10.3
|
||||||
name: mariadb-backup
|
name: mariadb-backup
|
||||||
env:
|
env:
|
||||||
@@ -204,5 +238,14 @@ data:
|
|||||||
performance_schema=ON
|
performance_schema=ON
|
||||||
innodb_log_file_size=32M
|
innodb_log_file_size=32M
|
||||||
table_open_cache=4000
|
table_open_cache=4000
|
||||||
|
expire_logs_days=7
|
||||||
|
|
||||||
|
# master slave
|
||||||
|
server_id=1 # Unique server ID for the master
|
||||||
|
log_bin=mysql-bin # Enable binary logging
|
||||||
|
binlog_format=ROW # Recommended format for replication (ROW, STATEMENT, or MIXED)
|
||||||
|
log_slave_updates=ON # Ensure any changes replicated to the master are also logged to the binary log (useful for multi-source replication)
|
||||||
|
sync_binlog=1 # Ensures binary logs are synchronized with disk after each transaction for data safety
|
||||||
|
expire_logs_days=7 # Optional: Number of days to retain binary logs (helps with cleanup)
|
||||||
|
|
||||||
# /etc/mysql/mariadb.conf.d/70-mysettings.cnf
|
# /etc/mysql/mariadb.conf.d/70-mysettings.cnf
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: wrestlingdev-memcached
|
|
||||||
labels:
|
|
||||||
app: wrestlingdev
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- port: 11211
|
|
||||||
selector:
|
|
||||||
app: wrestlingdev
|
|
||||||
tier: memcached
|
|
||||||
clusterIP: None
|
|
||||||
---
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: wrestlingdev-memcached-deployment
|
|
||||||
labels:
|
|
||||||
app: wrestlingdev
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: wrestlingdev
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: wrestlingdev
|
|
||||||
tier: memcached
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: wrestlingdev-memcached
|
|
||||||
image: memcached
|
|
||||||
ports:
|
|
||||||
- containerPort: 11211
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
memory: "64Mi"
|
|
||||||
# requests:
|
|
||||||
# memory: "64Mi"
|
|
||||||
# cpu: "0.1"
|
|
||||||
@@ -109,6 +109,16 @@ spec:
|
|||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: wrestlingdev-secrets
|
name: wrestlingdev-secrets
|
||||||
key: influxdb_port
|
key: influxdb_port
|
||||||
|
- name: WRESTLINGDEV_MISSION_CONTROL_USER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: wrestlingdev-secrets
|
||||||
|
key: mission_control_user
|
||||||
|
- name: WRESTLINGDEV_MISSION_CONTROL_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: wrestlingdev-secrets
|
||||||
|
key: mission_control_password
|
||||||
# resources:
|
# resources:
|
||||||
# limits:
|
# limits:
|
||||||
# memory: "768Mi"
|
# memory: "768Mi"
|
||||||
@@ -122,25 +132,27 @@ spec:
|
|||||||
initialDelaySeconds: 180
|
initialDelaySeconds: 180
|
||||||
periodSeconds: 20
|
periodSeconds: 20
|
||||||
timeoutSeconds: 10
|
timeoutSeconds: 10
|
||||||
# ---
|
---
|
||||||
# apiVersion: autoscaling/v2beta1
|
apiVersion: autoscaling/v2beta1
|
||||||
# kind: HorizontalPodAutoscaler
|
kind: HorizontalPodAutoscaler
|
||||||
# metadata:
|
metadata:
|
||||||
# name: wrestlingdev-app-deployment-autoscale
|
name: wrestlingdev-app-autoscale
|
||||||
# spec:
|
spec:
|
||||||
# scaleTargetRef:
|
scaleTargetRef:
|
||||||
# apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
# kind: Deployment
|
kind: StatefulSet
|
||||||
# name: wrestlingdev-app-deployment
|
name: wrestlingdev-app
|
||||||
# minReplicas: 2
|
minReplicas: 2
|
||||||
# maxReplicas: 5
|
maxReplicas: 5
|
||||||
# metrics:
|
metrics:
|
||||||
# - type: Resource
|
- type: Resource
|
||||||
# resource:
|
resource:
|
||||||
# name: cpu
|
name: cpu
|
||||||
# targetAverageUtilization: 75
|
targetAverageUtilization: 75
|
||||||
# - type: Resource
|
- type: Resource
|
||||||
# resource:
|
resource:
|
||||||
# name: memory
|
name: memory
|
||||||
# targetAverageValue: 100Mi
|
target:
|
||||||
|
type: Utilization
|
||||||
|
averageUtilization: 80
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,14 @@ stringData:
|
|||||||
gmailpassword: PUT_EMAIL_PASSWORD_HERE # gmail password
|
gmailpassword: PUT_EMAIL_PASSWORD_HERE # gmail password
|
||||||
gmailemail: PUT EMAIL ADDRESS HERE
|
gmailemail: PUT EMAIL ADDRESS HERE
|
||||||
passenger_pool_size: "2"
|
passenger_pool_size: "2"
|
||||||
|
# Replication credentials (create a dedicated user for replication)
|
||||||
|
replication_user: replica_user_here
|
||||||
|
replication_password: PUT_REPLICATION_PASSWORD_HERE
|
||||||
|
# Replication host used by the replica to connect to the master
|
||||||
|
replication_host: wrestlingdev-mariadb
|
||||||
|
# Mission Control Credentials
|
||||||
|
mission_control_user: PUT_MISSION_CONTROL_USERNAME_HERE
|
||||||
|
mission_control_password: PUT_MISSION_CONTROL_PASSWORD_HERE
|
||||||
# OPTIONAL
|
# OPTIONAL
|
||||||
# DELETE THESE LINES IF YOU'RE NOT USING THEM
|
# DELETE THESE LINES IF YOU'RE NOT USING THEM
|
||||||
influxdb_database: PUT INFLUXDB DATABASE NAME HERE
|
influxdb_database: PUT INFLUXDB DATABASE NAME HERE
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
FROM ruby:3.2.0
|
FROM ruby:4.0.1
|
||||||
|
|
||||||
# Accept build arguments for user/group IDs
|
# Accept build arguments for user/group IDs
|
||||||
ARG USER_ID=1000
|
ARG USER_ID=1000
|
||||||
ARG GROUP_ID=1000
|
ARG GROUP_ID=1000
|
||||||
|
|
||||||
RUN apt-get -qq update \
|
RUN apt-get -qq update --fix-missing \
|
||||||
&& apt-get -qq install -y \
|
&& apt-get -qq install -y \
|
||||||
build-essential \
|
build-essential \
|
||||||
sqlite3 \
|
sqlite3 \
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM ruby:3.2.0-slim
|
FROM ruby:4.0.1-slim
|
||||||
|
|
||||||
#HEALTHCHECK --start-period=60s CMD curl http://127.0.0.1/
|
#HEALTHCHECK --start-period=60s CMD curl http://127.0.0.1/
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ ENV TINI_VERSION v0.19.0
|
|||||||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
|
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
|
||||||
RUN chmod +x /tini
|
RUN chmod +x /tini
|
||||||
|
|
||||||
RUN apt-get -qq update \
|
RUN apt-get -qq update --fix-missing \
|
||||||
&& DEBIAN_FRONTEND=noninteractive apt-get -qq install -y \
|
&& DEBIAN_FRONTEND=noninteractive apt-get -qq install -y \
|
||||||
build-essential \
|
build-essential \
|
||||||
openssl \
|
openssl \
|
||||||
@@ -15,6 +15,8 @@ RUN apt-get -qq update \
|
|||||||
libsqlite3-dev \
|
libsqlite3-dev \
|
||||||
wget \
|
wget \
|
||||||
default-libmysqlclient-dev \
|
default-libmysqlclient-dev \
|
||||||
|
libyaml-dev \
|
||||||
|
pkg-config \
|
||||||
nodejs \
|
nodejs \
|
||||||
tzdata \
|
tzdata \
|
||||||
git \
|
git \
|
||||||
|
|||||||
@@ -27,58 +27,77 @@ namespace :tournament do
|
|||||||
)
|
)
|
||||||
|
|
||||||
GenerateTournamentMatches.new(@tournament).generate
|
GenerateTournamentMatches.new(@tournament).generate
|
||||||
sleep(10)
|
sleep(60)
|
||||||
while @tournament.reload.curently_generating_matches == 1
|
while @tournament.reload.curently_generating_matches == 1
|
||||||
puts "Waiting for tournament to finish generating matches..."
|
puts "Waiting for tournament to finish generating matches..."
|
||||||
sleep(5)
|
sleep(5)
|
||||||
|
@tournament.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
@tournament.reload # Ensure matches association is fresh before iterating
|
sleep(10)
|
||||||
@tournament.matches.sort_by(&:bout_number).each do |match|
|
loop do
|
||||||
match.reload
|
@tournament.reload
|
||||||
if match.loser1_name != "BYE" and match.loser2_name != "BYE"
|
@tournament.refill_open_bout_board_queues
|
||||||
# Wait until both wrestlers are assigned
|
|
||||||
while match.w1.nil? || match.w2.nil?
|
|
||||||
puts "Waiting for wrestlers in match #{match.bout_number}..."
|
|
||||||
sleep(5) # Wait for 5 seconds before checking again
|
|
||||||
match.reload
|
|
||||||
end
|
|
||||||
puts "Finishing match with bout number #{match.bout_number}..."
|
|
||||||
|
|
||||||
# Choose a random winner
|
mats_with_queue1 = @tournament.mats.select do |mat|
|
||||||
wrestlers = [match.w1, match.w2]
|
match = mat.queue1_match
|
||||||
match.winner_id = wrestlers.sample
|
match && match.finished != 1 && match.loser1_name != "BYE" && match.loser2_name != "BYE"
|
||||||
|
|
||||||
# Choose a random win type
|
|
||||||
win_type = WIN_TYPES.sample
|
|
||||||
match.win_type = win_type
|
|
||||||
|
|
||||||
# Assign score based on win type
|
|
||||||
match.score = case win_type
|
|
||||||
when "Decision"
|
|
||||||
low_score = rand(0..10)
|
|
||||||
high_score = low_score + rand(1..7)
|
|
||||||
"#{high_score}-#{low_score}"
|
|
||||||
when "Major"
|
|
||||||
low_score = rand(0..10)
|
|
||||||
high_score = low_score + rand(8..14)
|
|
||||||
"#{high_score}-#{low_score}"
|
|
||||||
when "Tech Fall"
|
|
||||||
low_score = rand(0..10)
|
|
||||||
high_score = low_score + rand(15..19)
|
|
||||||
"#{high_score}-#{low_score}"
|
|
||||||
when "Pin"
|
|
||||||
pin_times = ["0:30","1:12","5:37","2:34","3:54","4:23","5:56","0:12","1:00"]
|
|
||||||
pin_times.sample
|
|
||||||
else
|
|
||||||
"" # Default score
|
|
||||||
end
|
|
||||||
|
|
||||||
# Mark match as finished
|
|
||||||
match.finished = 1
|
|
||||||
match.save!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
break if mats_with_queue1.empty?
|
||||||
|
|
||||||
|
mat = mats_with_queue1.sample
|
||||||
|
match = mat.queue1_match
|
||||||
|
|
||||||
|
# Wait until both wrestlers are assigned for the selected queue1 match.
|
||||||
|
while match && (match.w1.nil? || match.w2.nil?)
|
||||||
|
puts "Waiting for wrestlers in match #{match.bout_number} on mat #{mat.name}..."
|
||||||
|
sleep(5)
|
||||||
|
@tournament.reload
|
||||||
|
@tournament.refill_open_bout_board_queues
|
||||||
|
match = mat.reload.queue1_match
|
||||||
|
end
|
||||||
|
|
||||||
|
next unless match
|
||||||
|
next if match.finished == 1 || match.loser1_name == "BYE" || match.loser2_name == "BYE"
|
||||||
|
|
||||||
|
puts "Finishing queue1 match on mat #{mat.name} with bout number #{match.bout_number}..."
|
||||||
|
|
||||||
|
# Choose a random winner
|
||||||
|
wrestlers = [match.w1, match.w2]
|
||||||
|
match.winner_id = wrestlers.sample
|
||||||
|
|
||||||
|
# Choose a random win type
|
||||||
|
win_type = WIN_TYPES.sample
|
||||||
|
match.win_type = win_type
|
||||||
|
|
||||||
|
# Assign score based on win type
|
||||||
|
match.score = case win_type
|
||||||
|
when "Decision"
|
||||||
|
low_score = rand(0..10)
|
||||||
|
high_score = low_score + rand(1..7)
|
||||||
|
"#{high_score}-#{low_score}"
|
||||||
|
when "Major"
|
||||||
|
low_score = rand(0..10)
|
||||||
|
high_score = low_score + rand(8..14)
|
||||||
|
"#{high_score}-#{low_score}"
|
||||||
|
when "Tech Fall"
|
||||||
|
low_score = rand(0..10)
|
||||||
|
high_score = low_score + rand(15..19)
|
||||||
|
"#{high_score}-#{low_score}"
|
||||||
|
when "Pin"
|
||||||
|
pin_times = ["0:30","1:12","5:37","2:34","3:54","4:23","5:56","0:12","1:00"]
|
||||||
|
pin_times.sample
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
|
||||||
|
# Mark match as finished
|
||||||
|
match.finished = 1
|
||||||
|
match.save!
|
||||||
|
# sleep to prevent mysql locks when queue advancement runs
|
||||||
|
sleep(0.5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,35 @@
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
letter-spacing: -0.0025em;
|
letter-spacing: -0.0025em;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
min-height: 100vh;
|
min-height: 100dvh;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
-webkit-text-size-adjust: 100%;
|
-webkit-text-size-adjust: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#error-description {
|
||||||
|
fill: #d30001;
|
||||||
|
}
|
||||||
|
|
||||||
|
#error-id {
|
||||||
|
fill: #f0eff0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background: #101010;
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#error-description {
|
||||||
|
fill: #FF6161;
|
||||||
|
}
|
||||||
|
|
||||||
|
#error-id {
|
||||||
|
fill: #2c2c2c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
@@ -83,13 +106,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
main article br {
|
main article br {
|
||||||
|
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
@media(min-width: 48em) {
|
@media(min-width: 48em) {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -102,10 +123,10 @@
|
|||||||
|
|
||||||
<main>
|
<main>
|
||||||
<header>
|
<header>
|
||||||
<svg height="172" viewBox="0 0 480 172" width="480" xmlns="http://www.w3.org/2000/svg"><path d="m124.48 3.00509-45.6889 100.02991h26.2239v-28.1168h38.119v28.1168h21.628v35.145h-21.628v30.82h-37.308v-30.82h-72.1833v-31.901l50.2851-103.27391zm115.583 168.69891c-40.822 0-64.884-35.146-64.884-85.7015 0-50.5554 24.062-85.700907 64.884-85.700907 40.823 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.061 85.7015-64.884 85.7015zm0-133.2831c-17.572 0-22.709 21.8984-22.709 47.5816 0 25.6835 5.137 47.5815 22.709 47.5815 17.303 0 22.71-21.898 22.71-47.5815 0-25.6832-5.407-47.5816-22.71-47.5816zm140.456 133.2831c-40.823 0-64.884-35.146-64.884-85.7015 0-50.5554 24.061-85.700907 64.884-85.700907 40.822 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.062 85.7015-64.884 85.7015zm0-133.2831c-17.573 0-22.71 21.8984-22.71 47.5816 0 25.6835 5.137 47.5815 22.71 47.5815 17.302 0 22.709-21.898 22.709-47.5815 0-25.6832-5.407-47.5816-22.709-47.5816z" fill="#f0eff0"/><path d="m123.606 85.4445c3.212 1.0523 5.538 4.2089 5.538 8.0301 0 6.1472-4.209 9.5254-11.298 9.5254h-15.617v-34.0033h14.565c7.089 0 11.353 3.1566 11.353 9.2484 0 3.6551-2.049 6.3134-4.541 7.1994zm-12.904-2.9905h5.095c2.603 0 3.988-.9968 3.988-3.1013 0-2.1044-1.385-3.0459-3.988-3.0459h-5.095zm0 6.6456v6.5902h5.981c2.492 0 3.877-1.3291 3.877-3.2674 0-2.049-1.385-3.3228-3.877-3.3228zm43.786 13.9004h-8.362v-1.274c-.831.831-3.323 1.717-5.981 1.717-4.929 0-9.083-2.769-9.083-8.0301 0-4.818 4.154-7.9193 9.581-7.9193 2.049 0 4.486.6646 5.483 1.3845v-1.606c0-1.606-.942-2.9905-3.046-2.9905-1.606 0-2.548.7199-2.935 1.8275h-8.197c.72-4.8181 4.985-8.6393 11.409-8.6393 7.088 0 11.131 3.7659 11.131 10.2453zm-8.362-6.9779v-1.4399c-.554-1.0522-2.049-1.7167-3.655-1.7167-1.717 0-3.434.7199-3.434 2.3813 0 1.7168 1.717 2.4367 3.434 2.4367 1.606 0 3.101-.6645 3.655-1.6614zm27.996 6.9779v-1.994c-1.163 1.329-3.599 2.548-6.147 2.548-7.199 0-11.131-5.8151-11.131-13.0145s3.932-13.0143 11.131-13.0143c2.548 0 4.984 1.2184 6.147 2.5475v-13.0697h8.695v35.997zm0-9.1931v-6.5902c-.664-1.3291-2.159-2.326-3.821-2.326-2.99 0-4.763 2.4368-4.763 5.6488s1.773 5.5934 4.763 5.5934c1.717 0 3.157-.9415 3.821-2.326zm35.471-2.049h-3.101v11.2421h-8.806v-34.0033h15.285c7.31 0 12.35 4.1535 12.35 11.5744 0 5.1503-2.603 8.6947-6.757 10.2453l7.975 12.1836h-9.858zm-3.101-15.2849v8.1962h5.538c3.156 0 4.596-1.606 4.596-4.0981s-1.44-4.0981-4.596-4.0981zm36.957 17.8323h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.643 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.515-13.0143 7.643 0 11.962 5.095 11.962 12.5159v2.1598h-16.115c.277 2.9905 1.827 4.5965 4.32 4.5965 1.772 0 3.156-.7753 3.655-2.4921zm-3.822-10.0237c-2.049 0-3.433 1.2737-3.987 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.545-3.5997zm30.98 27.5234v-10.799c-1.163 1.329-3.6 2.548-6.147 2.548-7.2 0-11.132-5.9259-11.132-13.0145 0-7.144 3.932-13.0143 11.132-13.0143 2.547 0 4.984 1.2184 6.147 2.5475v-1.9937h8.695v33.726zm0-17.9981v-6.5902c-.665-1.3291-2.105-2.326-3.821-2.326-2.991 0-4.763 2.4368-4.763 5.6488s1.772 5.5934 4.763 5.5934c1.661 0 3.156-.9415 3.821-2.326zm36.789-15.7279v24.921h-8.695v-2.16c-1.329 1.551-3.821 2.714-6.646 2.714-5.482 0-8.75-3.5999-8.75-9.1379v-16.3371h8.64v14.288c0 2.1045.996 3.5997 3.212 3.5997 1.606 0 3.101-1.0522 3.544-2.769v-15.1187zm19.084 16.2263h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.643 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.515-13.0143 7.643 0 11.963 5.095 11.963 12.5159v2.1598h-16.116c.277 2.9905 1.828 4.5965 4.32 4.5965 1.772 0 3.156-.7753 3.655-2.4921zm-3.822-10.0237c-2.049 0-3.433 1.2737-3.987 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.545-3.5997zm13.428 11.0206h8.474c.387 1.3845 1.606 2.1598 3.156 2.1598 1.44 0 2.548-.5538 2.548-1.7168 0-.9414-.72-1.2737-1.939-1.5506l-4.873-.9969c-4.154-.886-6.867-2.8797-6.867-7.2547 0-5.3165 4.762-8.4178 10.633-8.4178 6.812 0 10.522 3.1567 11.297 8.0855h-8.03c-.277-1.0522-1.052-1.9937-3.046-1.9937-1.273 0-2.326.5538-2.326 1.6614 0 .7753.554 1.163 1.717 1.3845l4.929 1.163c4.541 1.0522 6.978 3.4335 6.978 7.4763 0 5.3168-4.818 8.2518-10.91 8.2518-6.369 0-10.965-2.88-11.741-8.2518zm27.538-.8861v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.205v6.7564h-5.205v8.307c0 1.9383.941 2.769 2.658 2.769.941 0 1.993-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.871 0-9.193-2.769-9.193-9.0819z" fill="#d30001"/></svg>
|
<svg height="172" viewBox="0 0 480 172" width="480" xmlns="http://www.w3.org/2000/svg"><path d="m124.48 3.00509-45.6889 100.02991h26.2239v-28.1168h38.119v28.1168h21.628v35.145h-21.628v30.82h-37.308v-30.82h-72.1833v-31.901l50.2851-103.27391zm115.583 168.69891c-40.822 0-64.884-35.146-64.884-85.7015 0-50.5554 24.062-85.700907 64.884-85.700907 40.823 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.061 85.7015-64.884 85.7015zm0-133.2831c-17.572 0-22.709 21.8984-22.709 47.5816 0 25.6835 5.137 47.5815 22.709 47.5815 17.303 0 22.71-21.898 22.71-47.5815 0-25.6832-5.407-47.5816-22.71-47.5816zm140.456 133.2831c-40.823 0-64.884-35.146-64.884-85.7015 0-50.5554 24.061-85.700907 64.884-85.700907 40.822 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.062 85.7015-64.884 85.7015zm0-133.2831c-17.573 0-22.71 21.8984-22.71 47.5816 0 25.6835 5.137 47.5815 22.71 47.5815 17.302 0 22.709-21.898 22.709-47.5815 0-25.6832-5.407-47.5816-22.709-47.5816z" id="error-id"/><path d="m123.606 85.4445c3.212 1.0523 5.538 4.2089 5.538 8.0301 0 6.1472-4.209 9.5254-11.298 9.5254h-15.617v-34.0033h14.565c7.089 0 11.353 3.1566 11.353 9.2484 0 3.6551-2.049 6.3134-4.541 7.1994zm-12.904-2.9905h5.095c2.603 0 3.988-.9968 3.988-3.1013 0-2.1044-1.385-3.0459-3.988-3.0459h-5.095zm0 6.6456v6.5902h5.981c2.492 0 3.877-1.3291 3.877-3.2674 0-2.049-1.385-3.3228-3.877-3.3228zm43.786 13.9004h-8.362v-1.274c-.831.831-3.323 1.717-5.981 1.717-4.929 0-9.083-2.769-9.083-8.0301 0-4.818 4.154-7.9193 9.581-7.9193 2.049 0 4.486.6646 5.483 1.3845v-1.606c0-1.606-.942-2.9905-3.046-2.9905-1.606 0-2.548.7199-2.935 1.8275h-8.197c.72-4.8181 4.985-8.6393 11.409-8.6393 7.088 0 11.131 3.7659 11.131 10.2453zm-8.362-6.9779v-1.4399c-.554-1.0522-2.049-1.7167-3.655-1.7167-1.717 0-3.434.7199-3.434 2.3813 0 1.7168 1.717 2.4367 3.434 2.4367 1.606 0 3.101-.6645 3.655-1.6614zm27.996 6.9779v-1.994c-1.163 1.329-3.599 2.548-6.147 2.548-7.199 0-11.131-5.8151-11.131-13.0145s3.932-13.0143 11.131-13.0143c2.548 0 4.984 1.2184 6.147 2.5475v-13.0697h8.695v35.997zm0-9.1931v-6.5902c-.664-1.3291-2.159-2.326-3.821-2.326-2.99 0-4.763 2.4368-4.763 5.6488s1.773 5.5934 4.763 5.5934c1.717 0 3.157-.9415 3.821-2.326zm35.471-2.049h-3.101v11.2421h-8.806v-34.0033h15.285c7.31 0 12.35 4.1535 12.35 11.5744 0 5.1503-2.603 8.6947-6.757 10.2453l7.975 12.1836h-9.858zm-3.101-15.2849v8.1962h5.538c3.156 0 4.596-1.606 4.596-4.0981s-1.44-4.0981-4.596-4.0981zm36.957 17.8323h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.643 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.515-13.0143 7.643 0 11.962 5.095 11.962 12.5159v2.1598h-16.115c.277 2.9905 1.827 4.5965 4.32 4.5965 1.772 0 3.156-.7753 3.655-2.4921zm-3.822-10.0237c-2.049 0-3.433 1.2737-3.987 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.545-3.5997zm30.98 27.5234v-10.799c-1.163 1.329-3.6 2.548-6.147 2.548-7.2 0-11.132-5.9259-11.132-13.0145 0-7.144 3.932-13.0143 11.132-13.0143 2.547 0 4.984 1.2184 6.147 2.5475v-1.9937h8.695v33.726zm0-17.9981v-6.5902c-.665-1.3291-2.105-2.326-3.821-2.326-2.991 0-4.763 2.4368-4.763 5.6488s1.772 5.5934 4.763 5.5934c1.661 0 3.156-.9415 3.821-2.326zm36.789-15.7279v24.921h-8.695v-2.16c-1.329 1.551-3.821 2.714-6.646 2.714-5.482 0-8.75-3.5999-8.75-9.1379v-16.3371h8.64v14.288c0 2.1045.996 3.5997 3.212 3.5997 1.606 0 3.101-1.0522 3.544-2.769v-15.1187zm19.084 16.2263h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.643 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.515-13.0143 7.643 0 11.963 5.095 11.963 12.5159v2.1598h-16.116c.277 2.9905 1.828 4.5965 4.32 4.5965 1.772 0 3.156-.7753 3.655-2.4921zm-3.822-10.0237c-2.049 0-3.433 1.2737-3.987 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.545-3.5997zm13.428 11.0206h8.474c.387 1.3845 1.606 2.1598 3.156 2.1598 1.44 0 2.548-.5538 2.548-1.7168 0-.9414-.72-1.2737-1.939-1.5506l-4.873-.9969c-4.154-.886-6.867-2.8797-6.867-7.2547 0-5.3165 4.762-8.4178 10.633-8.4178 6.812 0 10.522 3.1567 11.297 8.0855h-8.03c-.277-1.0522-1.052-1.9937-3.046-1.9937-1.273 0-2.326.5538-2.326 1.6614 0 .7753.554 1.163 1.717 1.3845l4.929 1.163c4.541 1.0522 6.978 3.4335 6.978 7.4763 0 5.3168-4.818 8.2518-10.91 8.2518-6.369 0-10.965-2.88-11.741-8.2518zm27.538-.8861v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.205v6.7564h-5.205v8.307c0 1.9383.941 2.769 2.658 2.769.941 0 1.993-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.871 0-9.193-2.769-9.193-9.0819z" id="error-description"/></svg>
|
||||||
</header>
|
</header>
|
||||||
<article>
|
<article>
|
||||||
<p><strong>The server cannot process the request due to a client error.</strong> Please check the request and try again. If you’re the application owner check the logs for more information.</p>
|
<p><strong>The server cannot process the request due to a client error.</strong> Please check the request and try again. If you're the application owner check the logs for more information.</p>
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
|
||||||
<title>The page you were looking for doesn’t exist (404 Not found)</title>
|
<title>The page you were looking for doesn't exist (404 Not found)</title>
|
||||||
|
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="initial-scale=1, width=device-width">
|
<meta name="viewport" content="initial-scale=1, width=device-width">
|
||||||
@@ -35,12 +35,35 @@
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
letter-spacing: -0.0025em;
|
letter-spacing: -0.0025em;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
min-height: 100vh;
|
min-height: 100dvh;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
-webkit-text-size-adjust: 100%;
|
-webkit-text-size-adjust: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#error-description {
|
||||||
|
fill: #d30001;
|
||||||
|
}
|
||||||
|
|
||||||
|
#error-id {
|
||||||
|
fill: #f0eff0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background: #101010;
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#error-description {
|
||||||
|
fill: #FF6161;
|
||||||
|
}
|
||||||
|
|
||||||
|
#error-id {
|
||||||
|
fill: #2c2c2c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
@@ -83,13 +106,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
main article br {
|
main article br {
|
||||||
|
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
@media(min-width: 48em) {
|
@media(min-width: 48em) {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -102,10 +123,10 @@
|
|||||||
|
|
||||||
<main>
|
<main>
|
||||||
<header>
|
<header>
|
||||||
<svg height="172" viewBox="0 0 480 172" width="480" xmlns="http://www.w3.org/2000/svg"><path d="m124.48 3.00509-45.6889 100.02991h26.2239v-28.1168h38.119v28.1168h21.628v35.145h-21.628v30.82h-37.308v-30.82h-72.1833v-31.901l50.2851-103.27391zm115.583 168.69891c-40.822 0-64.884-35.146-64.884-85.7015 0-50.5554 24.062-85.700907 64.884-85.700907 40.823 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.061 85.7015-64.884 85.7015zm0-133.2831c-17.572 0-22.709 21.8984-22.709 47.5816 0 25.6835 5.137 47.5815 22.709 47.5815 17.303 0 22.71-21.898 22.71-47.5815 0-25.6832-5.407-47.5816-22.71-47.5816zm165.328-35.41581-45.689 100.02991h26.224v-28.1168h38.119v28.1168h21.628v35.145h-21.628v30.82h-37.308v-30.82h-72.184v-31.901l50.285-103.27391z" fill="#f0eff0"/><path d="m157.758 68.9967v34.0033h-7.199l-14.233-19.8814v19.8814h-8.584v-34.0033h8.307l13.125 18.7184v-18.7184zm28.454 21.5428c0 7.6978-5.15 13.0145-12.737 13.0145-7.532 0-12.738-5.3167-12.738-13.0145s5.206-13.0143 12.738-13.0143c7.587 0 12.737 5.3165 12.737 13.0143zm-8.528 0c0-3.4336-1.496-5.8703-4.209-5.8703-2.659 0-4.154 2.4367-4.154 5.8703s1.495 5.8149 4.154 5.8149c2.713 0 4.209-2.3813 4.209-5.8149zm13.184 3.8766v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.205v6.7564h-5.205v8.307c0 1.9383.941 2.769 2.658 2.769.941 0 1.994-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.87 0-9.193-2.769-9.193-9.0819zm37.027 8.5839h-8.806v-34.0033h23.924v7.6978h-15.118v6.7564h13.9v7.5316h-13.9zm41.876-12.4605c0 7.6978-5.15 13.0145-12.737 13.0145-7.532 0-12.738-5.3167-12.738-13.0145s5.206-13.0143 12.738-13.0143c7.587 0 12.737 5.3165 12.737 13.0143zm-8.529 0c0-3.4336-1.495-5.8703-4.208-5.8703-2.659 0-4.154 2.4367-4.154 5.8703s1.495 5.8149 4.154 5.8149c2.713 0 4.208-2.3813 4.208-5.8149zm35.337-12.4605v24.921h-8.695v-2.16c-1.329 1.551-3.821 2.714-6.646 2.714-5.482 0-8.75-3.5999-8.75-9.1379v-16.3371h8.64v14.288c0 2.1045.997 3.5997 3.212 3.5997 1.606 0 3.101-1.0522 3.544-2.769v-15.1187zm4.076 24.921v-24.921h8.694v2.1598c1.385-1.5506 3.822-2.7136 6.701-2.7136 5.538 0 8.806 3.5997 8.806 9.1377v16.3371h-8.639v-14.2327c0-2.049-1.053-3.5443-3.268-3.5443-1.717 0-3.156.9969-3.6 2.7136v15.0634zm44.113 0v-1.994c-1.163 1.329-3.6 2.548-6.147 2.548-7.2 0-11.132-5.8151-11.132-13.0145s3.932-13.0143 11.132-13.0143c2.547 0 4.984 1.2184 6.147 2.5475v-13.0697h8.695v35.997zm0-9.1931v-6.5902c-.665-1.3291-2.16-2.326-3.821-2.326-2.991 0-4.763 2.4368-4.763 5.6488s1.772 5.5934 4.763 5.5934c1.717 0 3.156-.9415 3.821-2.326z" fill="#d30001"/></svg>
|
<svg height="172" viewBox="0 0 480 172" width="480" xmlns="http://www.w3.org/2000/svg"><path d="m124.48 3.00509-45.6889 100.02991h26.2239v-28.1168h38.119v28.1168h21.628v35.145h-21.628v30.82h-37.308v-30.82h-72.1833v-31.901l50.2851-103.27391zm115.583 168.69891c-40.822 0-64.884-35.146-64.884-85.7015 0-50.5554 24.062-85.700907 64.884-85.700907 40.823 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.061 85.7015-64.884 85.7015zm0-133.2831c-17.572 0-22.709 21.8984-22.709 47.5816 0 25.6835 5.137 47.5815 22.709 47.5815 17.303 0 22.71-21.898 22.71-47.5815 0-25.6832-5.407-47.5816-22.71-47.5816zm165.328-35.41581-45.689 100.02991h26.224v-28.1168h38.119v28.1168h21.628v35.145h-21.628v30.82h-37.308v-30.82h-72.184v-31.901l50.285-103.27391z" id="error-id"/><path d="m157.758 68.9967v34.0033h-7.199l-14.233-19.8814v19.8814h-8.584v-34.0033h8.307l13.125 18.7184v-18.7184zm28.454 21.5428c0 7.6978-5.15 13.0145-12.737 13.0145-7.532 0-12.738-5.3167-12.738-13.0145s5.206-13.0143 12.738-13.0143c7.587 0 12.737 5.3165 12.737 13.0143zm-8.528 0c0-3.4336-1.496-5.8703-4.209-5.8703-2.659 0-4.154 2.4367-4.154 5.8703s1.495 5.8149 4.154 5.8149c2.713 0 4.209-2.3813 4.209-5.8149zm13.184 3.8766v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.205v6.7564h-5.205v8.307c0 1.9383.941 2.769 2.658 2.769.941 0 1.994-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.87 0-9.193-2.769-9.193-9.0819zm37.027 8.5839h-8.806v-34.0033h23.924v7.6978h-15.118v6.7564h13.9v7.5316h-13.9zm41.876-12.4605c0 7.6978-5.15 13.0145-12.737 13.0145-7.532 0-12.738-5.3167-12.738-13.0145s5.206-13.0143 12.738-13.0143c7.587 0 12.737 5.3165 12.737 13.0143zm-8.529 0c0-3.4336-1.495-5.8703-4.208-5.8703-2.659 0-4.154 2.4367-4.154 5.8703s1.495 5.8149 4.154 5.8149c2.713 0 4.208-2.3813 4.208-5.8149zm35.337-12.4605v24.921h-8.695v-2.16c-1.329 1.551-3.821 2.714-6.646 2.714-5.482 0-8.75-3.5999-8.75-9.1379v-16.3371h8.64v14.288c0 2.1045.997 3.5997 3.212 3.5997 1.606 0 3.101-1.0522 3.544-2.769v-15.1187zm4.076 24.921v-24.921h8.694v2.1598c1.385-1.5506 3.822-2.7136 6.701-2.7136 5.538 0 8.806 3.5997 8.806 9.1377v16.3371h-8.639v-14.2327c0-2.049-1.053-3.5443-3.268-3.5443-1.717 0-3.156.9969-3.6 2.7136v15.0634zm44.113 0v-1.994c-1.163 1.329-3.6 2.548-6.147 2.548-7.2 0-11.132-5.8151-11.132-13.0145s3.932-13.0143 11.132-13.0143c2.547 0 4.984 1.2184 6.147 2.5475v-13.0697h8.695v35.997zm0-9.1931v-6.5902c-.665-1.3291-2.16-2.326-3.821-2.326-2.991 0-4.763 2.4368-4.763 5.6488s1.772 5.5934 4.763 5.5934c1.717 0 3.156-.9415 3.821-2.326z" id="error-description"/></svg>
|
||||||
</header>
|
</header>
|
||||||
<article>
|
<article>
|
||||||
<p><strong>The page you were looking for doesn’t exist.</strong> You may have mistyped the address or the page may have moved. If you’re the application owner check the logs for more information.</p>
|
<p><strong>The page you were looking for doesn't exist.</strong> You may have mistyped the address or the page may have moved. If you're the application owner check the logs for more information.</p>
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,35 @@
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
letter-spacing: -0.0025em;
|
letter-spacing: -0.0025em;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
min-height: 100vh;
|
min-height: 100dvh;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
-webkit-text-size-adjust: 100%;
|
-webkit-text-size-adjust: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#error-description {
|
||||||
|
fill: #d30001;
|
||||||
|
}
|
||||||
|
|
||||||
|
#error-id {
|
||||||
|
fill: #f0eff0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
background: #101010;
|
||||||
|
color: #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#error-description {
|
||||||
|
fill: #FF6161;
|
||||||
|
}
|
||||||
|
|
||||||
|
#error-id {
|
||||||
|
fill: #2c2c2c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
@@ -83,13 +106,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
main article br {
|
main article br {
|
||||||
|
|
||||||
display: none;
|
display: none;
|
||||||
|
|
||||||
@media(min-width: 48em) {
|
@media(min-width: 48em) {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -102,7 +123,7 @@
|
|||||||
|
|
||||||
<main>
|
<main>
|
||||||
<header>
|
<header>
|
||||||
<svg height="172" viewBox="0 0 480 172" width="480" xmlns="http://www.w3.org/2000/svg"><path d="m124.48 3.00509-45.6889 100.02991h26.2239v-28.1168h38.119v28.1168h21.628v35.145h-21.628v30.82h-37.308v-30.82h-72.1833v-31.901l50.2851-103.27391zm115.583 168.69891c-40.822 0-64.884-35.146-64.884-85.7015 0-50.5554 24.062-85.700907 64.884-85.700907 40.823 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.061 85.7015-64.884 85.7015zm0-133.2831c-17.572 0-22.709 21.8984-22.709 47.5816 0 25.6835 5.137 47.5815 22.709 47.5815 17.303 0 22.71-21.898 22.71-47.5815 0-25.6832-5.407-47.5816-22.71-47.5816zm202.906 9.7326h-41.093c-2.433-7.2994-7.84-12.4361-17.302-12.4361-16.221 0-25.413 17.5728-25.954 34.8752v1.3517c5.137-7.0291 16.221-12.4361 30.82-12.4361 33.524 0 54.881 24.0612 54.881 53.7998 0 33.253-23.791 58.396-61.64 58.396-21.628 0-39.741-10.003-50.825-27.576-9.733-14.599-13.788-32.442-13.788-54.3406 0-51.9072 24.331-89.485807 66.236-89.485807 32.712 0 53.258 18.654107 58.665 47.851907zm-82.727 66.2355c0 13.247 9.463 22.439 22.71 22.439 12.977 0 22.439-9.192 22.439-22.439 0-13.517-9.462-22.7091-22.439-22.7091-13.247 0-22.71 9.1921-22.71 22.7091z" fill="#f0eff0"/><path d="m100.761 68.9967v34.0033h-7.1991l-14.2326-19.8814v19.8814h-8.5839v-34.0033h8.307l13.125 18.7184v-18.7184zm28.454 21.5428c0 7.6978-5.15 13.0145-12.737 13.0145-7.532 0-12.738-5.3167-12.738-13.0145s5.206-13.0143 12.738-13.0143c7.587 0 12.737 5.3165 12.737 13.0143zm-8.529 0c0-3.4336-1.495-5.8703-4.208-5.8703-2.659 0-4.154 2.4367-4.154 5.8703s1.495 5.8149 4.154 5.8149c2.713 0 4.208-2.3813 4.208-5.8149zm13.185 3.8766v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.205v6.7564h-5.205v8.307c0 1.9383.941 2.769 2.658 2.769.941 0 1.994-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.87 0-9.193-2.769-9.193-9.0819zm39.02-25.4194h9.083l12.958 34.0033h-9.027l-2.436-6.5902h-12.35l-2.381 6.5902h-8.806zm4.431 10.5222-3.489 9.5807h6.978zm17.44 11.0206c0-7.6978 5.095-13.0143 12.572-13.0143 6.701 0 10.854 3.9874 11.574 9.8023h-8.418c-.221-1.4953-1.384-2.6029-3.156-2.6029-2.437 0-3.988 2.2706-3.988 5.8149s1.551 5.7595 3.988 5.7595c1.772 0 2.935-1.0522 3.156-2.5475h8.418c-.72 5.7596-4.873 9.8025-11.574 9.8025-7.477 0-12.572-5.3167-12.572-13.0145zm25.676 0c0-7.6978 5.095-13.0143 12.572-13.0143 6.701 0 10.854 3.9874 11.574 9.8023h-8.418c-.221-1.4953-1.384-2.6029-3.156-2.6029-2.437 0-3.988 2.2706-3.988 5.8149s1.551 5.7595 3.988 5.7595c1.772 0 2.935-1.0522 3.156-2.5475h8.418c-.72 5.7596-4.873 9.8025-11.574 9.8025-7.477 0-12.572-5.3167-12.572-13.0145zm42.013 3.7658h8.031c-.887 5.7597-5.206 9.2487-11.686 9.2487-7.642 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.317-13.0143 12.516-13.0143 7.643 0 11.962 5.095 11.962 12.5159v2.1598h-16.115c.277 2.9905 1.827 4.5965 4.319 4.5965 1.773 0 3.157-.7753 3.655-2.4921zm-3.821-10.0237c-2.049 0-3.433 1.2737-3.987 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.545-3.5997zm23.4 16.7244v10.799h-8.694v-33.726h8.694v1.9937c1.163-1.3291 3.6-2.5475 6.148-2.5475 7.199 0 11.131 5.8703 11.131 13.0143 0 7.0886-3.932 13.0145-11.131 13.0145-2.548 0-4.985-1.219-6.148-2.548zm0-13.7893v6.5902c.665 1.3845 2.16 2.326 3.822 2.326 2.99 0 4.762-2.3814 4.762-5.5934s-1.772-5.6488-4.762-5.6488c-1.717 0-3.157.9969-3.822 2.326zm21.892 7.1994v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.206v6.7564h-5.206v8.307c0 1.9383.941 2.769 2.658 2.769.942 0 1.994-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.87 0-9.193-2.769-9.193-9.0819zm39.458 8.5839h-8.363v-1.274c-.83.831-3.322 1.717-5.981 1.717-4.928 0-9.082-2.769-9.082-8.0301 0-4.818 4.154-7.9193 9.581-7.9193 2.049 0 4.486.6646 5.482 1.3845v-1.606c0-1.606-.941-2.9905-3.045-2.9905-1.606 0-2.548.7199-2.936 1.8275h-8.196c.72-4.8181 4.984-8.6393 11.408-8.6393 7.089 0 11.132 3.7659 11.132 10.2453zm-8.363-6.9779v-1.4399c-.553-1.0522-2.049-1.7167-3.655-1.7167-1.716 0-3.433.7199-3.433 2.3813 0 1.7168 1.717 2.4367 3.433 2.4367 1.606 0 3.102-.6645 3.655-1.6614zm20.742 4.9839v1.994h-8.694v-35.997h8.694v13.0697c1.163-1.3291 3.6-2.5475 6.148-2.5475 7.199 0 11.131 5.8149 11.131 13.0143s-3.932 13.0145-11.131 13.0145c-2.548 0-4.985-1.219-6.148-2.548zm0-13.7893v6.5902c.665 1.3845 2.105 2.326 3.822 2.326 2.99 0 4.762-2.3814 4.762-5.5934s-1.772-5.6488-4.762-5.6488c-1.662 0-3.157.9969-3.822 2.326zm28.759-20.2137v35.997h-8.695v-35.997zm19.172 27.3023h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.643 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.516-13.0143 7.642 0 11.962 5.095 11.962 12.5159v2.1598h-16.116c.277 2.9905 1.828 4.5965 4.32 4.5965 1.772 0 3.157-.7753 3.655-2.4921zm-3.821-10.0237c-2.049 0-3.434 1.2737-3.988 3.5997h7.532c-.111-2.0491-1.384-3.5997-3.544-3.5997z" fill="#d30001"/></svg>
|
<svg height="172" viewBox="0 0 480 172" width="480" xmlns="http://www.w3.org/2000/svg"><path d="m124.48 3.00509-45.6889 100.02991h26.2239v-28.1168h38.119v28.1168h21.628v35.145h-21.628v30.82h-37.308v-30.82h-72.1833v-31.901l50.2851-103.27391zm115.583 168.69891c-40.822 0-64.884-35.146-64.884-85.7015 0-50.5554 24.062-85.700907 64.884-85.700907 40.823 0 64.884 35.145507 64.884 85.700907 0 50.5555-24.061 85.7015-64.884 85.7015zm0-133.2831c-17.572 0-22.709 21.8984-22.709 47.5816 0 25.6835 5.137 47.5815 22.709 47.5815 17.303 0 22.71-21.898 22.71-47.5815 0-25.6832-5.407-47.5816-22.71-47.5816zm202.906 9.7326h-41.093c-2.433-7.2994-7.84-12.4361-17.302-12.4361-16.221 0-25.413 17.5728-25.954 34.8752v1.3517c5.137-7.0291 16.221-12.4361 30.82-12.4361 33.524 0 54.881 24.0612 54.881 53.7998 0 33.253-23.791 58.396-61.64 58.396-21.628 0-39.741-10.003-50.825-27.576-9.733-14.599-13.788-32.442-13.788-54.3406 0-51.9072 24.331-89.485807 66.236-89.485807 32.712 0 53.258 18.654107 58.665 47.851907zm-82.727 66.2355c0 13.247 9.463 22.439 22.71 22.439 12.977 0 22.439-9.192 22.439-22.439 0-13.517-9.462-22.7091-22.439-22.7091-13.247 0-22.71 9.1921-22.71 22.7091z" id="error-id"/><path d="m100.761 68.9967v34.0033h-7.1991l-14.2326-19.8814v19.8814h-8.5839v-34.0033h8.307l13.125 18.7184v-18.7184zm28.454 21.5428c0 7.6978-5.15 13.0145-12.737 13.0145-7.532 0-12.738-5.3167-12.738-13.0145s5.206-13.0143 12.738-13.0143c7.587 0 12.737 5.3165 12.737 13.0143zm-8.529 0c0-3.4336-1.495-5.8703-4.208-5.8703-2.659 0-4.154 2.4367-4.154 5.8703s1.495 5.8149 4.154 5.8149c2.713 0 4.208-2.3813 4.208-5.8149zm13.185 3.8766v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.205v6.7564h-5.205v8.307c0 1.9383.941 2.769 2.658 2.769.941 0 1.994-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.87 0-9.193-2.769-9.193-9.0819zm39.02-25.4194h9.083l12.958 34.0033h-9.027l-2.436-6.5902h-12.35l-2.381 6.5902h-8.806zm4.431 10.5222-3.489 9.5807h6.978zm17.44 11.0206c0-7.6978 5.095-13.0143 12.572-13.0143 6.701 0 10.854 3.9874 11.574 9.8023h-8.418c-.221-1.4953-1.384-2.6029-3.156-2.6029-2.437 0-3.988 2.2706-3.988 5.8149s1.551 5.7595 3.988 5.7595c1.772 0 2.935-1.0522 3.156-2.5475h8.418c-.72 5.7596-4.873 9.8025-11.574 9.8025-7.477 0-12.572-5.3167-12.572-13.0145zm25.676 0c0-7.6978 5.095-13.0143 12.572-13.0143 6.701 0 10.854 3.9874 11.574 9.8023h-8.418c-.221-1.4953-1.384-2.6029-3.156-2.6029-2.437 0-3.988 2.2706-3.988 5.8149s1.551 5.7595 3.988 5.7595c1.772 0 2.935-1.0522 3.156-2.5475h8.418c-.72 5.7596-4.873 9.8025-11.574 9.8025-7.477 0-12.572-5.3167-12.572-13.0145zm42.013 3.7658h8.031c-.887 5.7597-5.206 9.2487-11.686 9.2487-7.642 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.317-13.0143 12.516-13.0143 7.643 0 11.962 5.095 11.962 12.5159v2.1598h-16.115c.277 2.9905 1.827 4.5965 4.319 4.5965 1.773 0 3.157-.7753 3.655-2.4921zm-3.821-10.0237c-2.049 0-3.433 1.2737-3.987 3.5997h7.532c-.111-2.0491-1.385-3.5997-3.545-3.5997zm23.4 16.7244v10.799h-8.694v-33.726h8.694v1.9937c1.163-1.3291 3.6-2.5475 6.148-2.5475 7.199 0 11.131 5.8703 11.131 13.0143 0 7.0886-3.932 13.0145-11.131 13.0145-2.548 0-4.985-1.219-6.148-2.548zm0-13.7893v6.5902c.665 1.3845 2.16 2.326 3.822 2.326 2.99 0 4.762-2.3814 4.762-5.5934s-1.772-5.6488-4.762-5.6488c-1.717 0-3.157.9969-3.822 2.326zm21.892 7.1994v-9.5807h-3.655v-6.7564h3.655v-6.8671h8.584v6.8671h5.206v6.7564h-5.206v8.307c0 1.9383.941 2.769 2.658 2.769.942 0 1.994-.2216 2.769-.5538v7.3654c-.997.443-2.88.775-4.818.775-5.87 0-9.193-2.769-9.193-9.0819zm39.458 8.5839h-8.363v-1.274c-.83.831-3.322 1.717-5.981 1.717-4.928 0-9.082-2.769-9.082-8.0301 0-4.818 4.154-7.9193 9.581-7.9193 2.049 0 4.486.6646 5.482 1.3845v-1.606c0-1.606-.941-2.9905-3.045-2.9905-1.606 0-2.548.7199-2.936 1.8275h-8.196c.72-4.8181 4.984-8.6393 11.408-8.6393 7.089 0 11.132 3.7659 11.132 10.2453zm-8.363-6.9779v-1.4399c-.553-1.0522-2.049-1.7167-3.655-1.7167-1.716 0-3.433.7199-3.433 2.3813 0 1.7168 1.717 2.4367 3.433 2.4367 1.606 0 3.102-.6645 3.655-1.6614zm20.742 4.9839v1.994h-8.694v-35.997h8.694v13.0697c1.163-1.3291 3.6-2.5475 6.148-2.5475 7.199 0 11.131 5.8149 11.131 13.0143s-3.932 13.0145-11.131 13.0145c-2.548 0-4.985-1.219-6.148-2.548zm0-13.7893v6.5902c.665 1.3845 2.105 2.326 3.822 2.326 2.99 0 4.762-2.3814 4.762-5.5934s-1.772-5.6488-4.762-5.6488c-1.662 0-3.157.9969-3.822 2.326zm28.759-20.2137v35.997h-8.695v-35.997zm19.172 27.3023h8.03c-.886 5.7597-5.206 9.2487-11.685 9.2487-7.643 0-12.682-5.2613-12.682-13.0145 0-7.6978 5.316-13.0143 12.516-13.0143 7.642 0 11.962 5.095 11.962 12.5159v2.1598h-16.116c.277 2.9905 1.828 4.5965 4.32 4.5965 1.772 0 3.157-.7753 3.655-2.4921zm-3.821-10.0237c-2.049 0-3.434 1.2737-3.988 3.5997h7.532c-.111-2.0491-1.384-3.5997-3.544-3.5997z" id="error-description"/></svg>
|
||||||
</header>
|
</header>
|
||||||
<article>
|
<article>
|
||||||
<p><strong>Your browser is not supported.</strong><br> Please upgrade your browser to continue.</p>
|
<p><strong>Your browser is not supported.</strong><br> Please upgrade your browser to continue.</p>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
public/ads.txt
Normal file
1
public/ads.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
google.com, pub-6845455733812572, DIRECT, f08c47fec0942fa0
|
||||||
@@ -25,6 +25,7 @@ class MatchesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def post_update_from_match_stat
|
def post_update_from_match_stat
|
||||||
|
@request.env["HTTP_REFERER"] = "/tournaments/#{@tournament.id}/matches"
|
||||||
get :stat, params: { id: @match.id }
|
get :stat, params: { id: @match.id }
|
||||||
patch :update, params: { id: @match.id, match: {tournament_id: 1, mat_id: 1} }
|
patch :update, params: { id: @match.id, match: {tournament_id: 1, mat_id: 1} }
|
||||||
end
|
end
|
||||||
@@ -32,6 +33,21 @@ class MatchesControllerTest < ActionController::TestCase
|
|||||||
def get_stat
|
def get_stat
|
||||||
get :stat, params: { id: @match.id }
|
get :stat, params: { id: @match.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_edit_assignment(extra_params = {})
|
||||||
|
get :edit_assignment, params: { id: @match.id }.merge(extra_params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def patch_update_assignment(extra_params = {})
|
||||||
|
base = {
|
||||||
|
id: @match.id,
|
||||||
|
match: {
|
||||||
|
mat_id: @match.mat_id,
|
||||||
|
queue_position: 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
patch :update_assignment, params: base.deep_merge(extra_params)
|
||||||
|
end
|
||||||
|
|
||||||
def sign_in_owner
|
def sign_in_owner
|
||||||
sign_in users(:one)
|
sign_in users(:one)
|
||||||
@@ -174,4 +190,72 @@ class MatchesControllerTest < ActionController::TestCase
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
assert_includes @response.body, time_ago_in_words(finished_at), "time_ago_in_words(finished_at) should be displayed on the page"
|
assert_includes @response.body, time_ago_in_words(finished_at), "time_ago_in_words(finished_at) should be displayed on the page"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "tournament owner can view edit_assignment and execute update_assignment" do
|
||||||
|
sign_in_owner
|
||||||
|
get_edit_assignment
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
patch_update_assignment
|
||||||
|
assert_response :redirect
|
||||||
|
assert_not_equal "/static_pages/not_allowed", @response.redirect_url&.sub("http://test.host", "")
|
||||||
|
end
|
||||||
|
|
||||||
|
test "tournament delegate can view edit_assignment and execute update_assignment" do
|
||||||
|
sign_in_tournament_delegate
|
||||||
|
get_edit_assignment
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
patch_update_assignment
|
||||||
|
assert_response :redirect
|
||||||
|
assert_not_equal "/static_pages/not_allowed", @response.redirect_url&.sub("http://test.host", "")
|
||||||
|
end
|
||||||
|
|
||||||
|
test "school delegate cannot view edit_assignment or execute update_assignment" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_edit_assignment
|
||||||
|
assert_redirected_to "/static_pages/not_allowed"
|
||||||
|
|
||||||
|
patch_update_assignment
|
||||||
|
assert_redirected_to "/static_pages/not_allowed"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user cannot view edit_assignment or execute update_assignment" do
|
||||||
|
get_edit_assignment
|
||||||
|
assert_redirected_to "/static_pages/not_allowed"
|
||||||
|
|
||||||
|
patch_update_assignment
|
||||||
|
assert_redirected_to "/static_pages/not_allowed"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in user without delegations cannot view edit_assignment or execute update_assignment" do
|
||||||
|
sign_in_non_owner
|
||||||
|
get_edit_assignment
|
||||||
|
assert_redirected_to "/static_pages/not_allowed"
|
||||||
|
|
||||||
|
patch_update_assignment
|
||||||
|
assert_redirected_to "/static_pages/not_allowed"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "valid school permission key cannot view edit_assignment or execute update_assignment" do
|
||||||
|
school = @tournament.schools.first
|
||||||
|
school.update!(permission_key: "valid-school-key")
|
||||||
|
|
||||||
|
get_edit_assignment(school_permission_key: "valid-school-key")
|
||||||
|
assert_redirected_to "/static_pages/not_allowed"
|
||||||
|
|
||||||
|
patch_update_assignment(school_permission_key: "valid-school-key")
|
||||||
|
assert_redirected_to "/static_pages/not_allowed"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "invalid school permission key cannot view edit_assignment or execute update_assignment" do
|
||||||
|
school = @tournament.schools.first
|
||||||
|
school.update!(permission_key: "valid-school-key")
|
||||||
|
|
||||||
|
get_edit_assignment(school_permission_key: "invalid-school-key")
|
||||||
|
assert_redirected_to "/static_pages/not_allowed"
|
||||||
|
|
||||||
|
patch_update_assignment(school_permission_key: "invalid-school-key")
|
||||||
|
assert_redirected_to "/static_pages/not_allowed"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
# @tournament.generateMatchups
|
# @tournament.generateMatchups
|
||||||
@match = Match.where("tournament_id = ? and mat_id = ?",1,1).first
|
@match = Match.where("tournament_id = ? and mat_id = ?",1,1).first
|
||||||
@mat = mats(:one)
|
@mat = mats(:one)
|
||||||
|
@match ||= @tournament.matches.first
|
||||||
|
if @match && @mat.queue1.nil?
|
||||||
|
@mat.assign_match_to_queue!(@match, 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@@ -62,6 +66,15 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
def redirect
|
def redirect
|
||||||
assert_redirected_to '/static_pages/not_allowed'
|
assert_redirected_to '/static_pages/not_allowed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assert_ads_hidden
|
||||||
|
assert_no_match(/blocked_message/, response.body)
|
||||||
|
assert_no_match(/adsbygoogle/, response.body)
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_ads_visible
|
||||||
|
assert_match(/blocked_message/, response.body)
|
||||||
|
end
|
||||||
|
|
||||||
def no_matches
|
def no_matches
|
||||||
assert_redirected_to "/tournaments/#{@tournament.id}/no_matches"
|
assert_redirected_to "/tournaments/#{@tournament.id}/no_matches"
|
||||||
@@ -217,6 +230,13 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "ads are hidden on mat show" do
|
||||||
|
sign_in_owner
|
||||||
|
show
|
||||||
|
success
|
||||||
|
assert_ads_hidden
|
||||||
|
end
|
||||||
|
|
||||||
test "redirect to mat show when posting a match from mat show" do
|
test "redirect to mat show when posting a match from mat show" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
post_match_update_from_mat_show
|
post_match_update_from_mat_show
|
||||||
@@ -242,7 +262,7 @@ class MatsControllerTest < ActionController::TestCase
|
|||||||
test "logged in tournament owner should redirect back to the first unfinished bout on a mat after submitting a match with a bout number param" do
|
test "logged in tournament owner should redirect back to the first unfinished bout on a mat after submitting a match with a bout number param" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
|
|
||||||
first_bout_number = @mat.unfinished_matches.first.bout_number
|
first_bout_number = @mat.queue1_match.bout_number
|
||||||
|
|
||||||
# Set a specific bout number to test
|
# Set a specific bout number to test
|
||||||
bout_number = @match.bout_number
|
bout_number = @match.bout_number
|
||||||
|
|||||||
@@ -60,6 +60,15 @@ class SchoolsControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to '/static_pages/not_allowed'
|
assert_redirected_to '/static_pages/not_allowed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assert_ads_hidden
|
||||||
|
assert_no_match(/blocked_message/, response.body)
|
||||||
|
assert_no_match(/adsbygoogle/, response.body)
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_ads_visible
|
||||||
|
assert_match(/blocked_message/, response.body)
|
||||||
|
end
|
||||||
|
|
||||||
def baums_import
|
def baums_import
|
||||||
baums_text = "***** 2019-01-09 13:36:50 *****
|
baums_text = "***** 2019-01-09 13:36:50 *****
|
||||||
Some School
|
Some School
|
||||||
@@ -357,7 +366,7 @@ Some Guy
|
|||||||
|
|
||||||
@school.wrestlers.each do |wrestler|
|
@school.wrestlers.each do |wrestler|
|
||||||
# Check only for the DELETE link, specifying 'data-method="delete"' to exclude profile links
|
# Check only for the DELETE link, specifying 'data-method="delete"' to exclude profile links
|
||||||
assert_select "a[href=?][data-method=delete]", wrestler_path(wrestler), count: 1
|
assert_select "a[href=?][data-turbo-method=delete]", wrestler_path(wrestler), count: 1
|
||||||
|
|
||||||
# Check edit link
|
# Check edit link
|
||||||
assert_select "a[href=?]", edit_wrestler_path(wrestler), count: 1
|
assert_select "a[href=?]", edit_wrestler_path(wrestler), count: 1
|
||||||
@@ -373,18 +382,53 @@ Some Guy
|
|||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in user without delegation can get show page when using valid school_permission_key" do
|
||||||
|
sign_in_non_owner
|
||||||
|
@tournament.update(is_public: false)
|
||||||
|
get_show(school_permission_key: @school_permission_key)
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
test "non logged in user cannot get show page when using invalid school_permission_key" do
|
test "non logged in user cannot get show page when using invalid school_permission_key" do
|
||||||
@tournament.update(is_public: false)
|
@tournament.update(is_public: false)
|
||||||
get_show(school_permission_key: "invalid-key")
|
get_show(school_permission_key: "invalid-key")
|
||||||
redirect
|
redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in user without delegation can edit school with valid school_permission_key" do
|
||||||
|
sign_in_non_owner
|
||||||
|
@tournament.update(is_public: false)
|
||||||
|
get_edit(school_permission_key: @school_permission_key)
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
test "non logged in user can edit school with valid school_permission_key" do
|
test "non logged in user can edit school with valid school_permission_key" do
|
||||||
@tournament.update(is_public: false)
|
@tournament.update(is_public: false)
|
||||||
get_edit(school_permission_key: @school_permission_key)
|
get_edit(school_permission_key: @school_permission_key)
|
||||||
success
|
success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "ads are hidden on school show when logged in" do
|
||||||
|
sign_in_owner
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
assert_ads_hidden
|
||||||
|
end
|
||||||
|
|
||||||
|
test "ads are hidden on school show with school permission key" do
|
||||||
|
@tournament.update(is_public: false)
|
||||||
|
get_show(school_permission_key: @school_permission_key)
|
||||||
|
success
|
||||||
|
assert_ads_hidden
|
||||||
|
end
|
||||||
|
|
||||||
|
test "ads are visible on school show for anonymous user without key" do
|
||||||
|
@tournament.update(is_public: true)
|
||||||
|
get_show
|
||||||
|
success
|
||||||
|
assert_ads_visible
|
||||||
|
end
|
||||||
|
|
||||||
test "non logged in user cannot edit school with invalid school_permission_key" do
|
test "non logged in user cannot edit school with invalid school_permission_key" do
|
||||||
@tournament.update(is_public: false)
|
@tournament.update(is_public: false)
|
||||||
get_edit(school_permission_key: "invalid-key")
|
get_edit(school_permission_key: "invalid-key")
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ class TournamentsControllerTest < ActionController::TestCase
|
|||||||
def get_up_matches
|
def get_up_matches
|
||||||
get :up_matches, params: { id: 1 }
|
get :up_matches, params: { id: 1 }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_qrcode(params = {})
|
||||||
|
get :qrcode, params: { id: 1 }.merge(params)
|
||||||
|
end
|
||||||
|
|
||||||
def get_edit
|
def get_edit
|
||||||
get :edit, params: { id: 1 }
|
get :edit, params: { id: 1 }
|
||||||
@@ -192,6 +196,47 @@ class TournamentsControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to '/static_pages/not_allowed'
|
assert_redirected_to '/static_pages/not_allowed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "logged in non owner and non delegate cannot access qrcode" do
|
||||||
|
sign_in_non_owner
|
||||||
|
get_qrcode
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user cannot access qrcode" do
|
||||||
|
get_qrcode
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user with valid school permission key cannot access qrcode" do
|
||||||
|
@school.update(permission_key: "valid-key")
|
||||||
|
get_qrcode(school_permission_key: "valid-key")
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "non logged in user with invalid school permission key cannot access qrcode" do
|
||||||
|
@school.update(permission_key: "valid-key")
|
||||||
|
get_qrcode(school_permission_key: "invalid-key")
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in owner can access qrcode" do
|
||||||
|
sign_in_owner
|
||||||
|
get_qrcode
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in tournament delegate can access qrcode" do
|
||||||
|
sign_in_delegate
|
||||||
|
get_qrcode
|
||||||
|
success
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logged in school delegate cannot access qrcode" do
|
||||||
|
sign_in_school_delegate
|
||||||
|
get_qrcode
|
||||||
|
redirect
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in user should not post update tournament if not owner" do
|
test "logged in user should not post update tournament if not owner" do
|
||||||
sign_in_non_owner
|
sign_in_non_owner
|
||||||
post_update
|
post_update
|
||||||
@@ -1084,4 +1129,55 @@ class TournamentsControllerTest < ActionController::TestCase
|
|||||||
assert_match(/#{match.bout_number}/, response.body, "Bout number #{match.bout_number} is missing from the bracket page")
|
assert_match(/#{match.bout_number}/, response.body, "Bout number #{match.bout_number} is missing from the bracket page")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
test "index sorts tournaments by date closest to today" do
|
||||||
|
today = Date.today
|
||||||
|
t_today = Tournament.create!(name: "Closest Today", address: "123 Test St", director: "Director", director_email: "today@example.com", date: today, tournament_type: "Pool to bracket", is_public: true)
|
||||||
|
t_minus1 = Tournament.create!(name: "Minus 1", address: "123 Test St", director: "Director", director_email: "m1@example.com", date: today - 1, tournament_type: "Pool to bracket", is_public: true)
|
||||||
|
t_plus1 = Tournament.create!(name: "Plus 1", address: "123 Test St", director: "Director", director_email: "p1@example.com", date: today + 1, tournament_type: "Pool to bracket", is_public: true)
|
||||||
|
t_plus2 = Tournament.create!(name: "Plus 2", address: "123 Test St", director: "Director", director_email: "p2@example.com", date: today + 2, tournament_type: "Pool to bracket", is_public: true)
|
||||||
|
t_minus3 = Tournament.create!(name: "Minus 3", address: "123 Test St", director: "Director", director_email: "m3@example.com", date: today - 3, tournament_type: "Pool to bracket", is_public: true)
|
||||||
|
t_plus10 = Tournament.create!(name: "Plus 10", address: "123 Test St", director: "Director", director_email: "p10@example.com", date: today + 10, tournament_type: "Pool to bracket", is_public: true)
|
||||||
|
|
||||||
|
created = [t_today, t_minus1, t_plus1, t_plus2, t_minus3, t_plus10]
|
||||||
|
# Hit index
|
||||||
|
get :index
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
# From the controller result, select only the tournaments we just created and verify their relative order
|
||||||
|
results = assigns(:tournaments).select { |t| created.map(&:id).include?(t.id) }
|
||||||
|
expected_order = created.sort_by { |t| (t.date - today).abs }.map(&:id)
|
||||||
|
|
||||||
|
# Basic ordering assertions
|
||||||
|
assert_equal expected_order, results.map(&:id), "Created tournaments should be ordered by distance from today"
|
||||||
|
assert_equal t_today.id, results.first.id, "The tournament dated today should be first (closest)"
|
||||||
|
assert_equal t_plus10.id, results.last.id, "The farthest tournament should appear last"
|
||||||
|
|
||||||
|
# Relative order checks (smaller distance should appear before larger distance)
|
||||||
|
assert results.index { |r| r.id == t_minus1.id } < results.index { |r| r.id == t_plus2.id }, "t_minus1 (distance 1) should appear before t_plus2 (distance 2)"
|
||||||
|
assert results.index { |r| r.id == t_plus2.id } < results.index { |r| r.id == t_minus3.id }, "t_plus2 (distance 2) should appear before t_minus3 (distance 3)"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "index paginates tournaments with page param and exposes total_count" do
|
||||||
|
initial_count = Tournament.count
|
||||||
|
# Create 25 tournaments to ensure we exceed the per_page (20)
|
||||||
|
25.times do |i|
|
||||||
|
Tournament.create!(name: "Paginate Test #{i}", address: "1 Paginate Rd", director: "Dir", director_email: "paginate#{i}@example.com", date: Date.today + i, tournament_type: "Pool to bracket", is_public: true)
|
||||||
|
end
|
||||||
|
expected_total = initial_count + 25
|
||||||
|
|
||||||
|
# Page 1
|
||||||
|
get :index, params: { page: 1 }
|
||||||
|
assert_response :success
|
||||||
|
assert_equal expected_total, assigns(:total_count), "total_count should reflect all tournaments"
|
||||||
|
assert_equal 20, assigns(:tournaments).size, "first page should contain 20 tournaments"
|
||||||
|
|
||||||
|
# Page 2
|
||||||
|
get :index, params: { page: 2 }
|
||||||
|
assert_response :success
|
||||||
|
assert_equal expected_total, assigns(:total_count), "total_count should remain the same on subsequent pages"
|
||||||
|
expected_page2_size = expected_total - 20
|
||||||
|
# If there are more than 20 initial fixtures, expected_page2_size might be > 20; clamp to per_page logic:
|
||||||
|
expected_page2_display = [expected_page2_size, 20].min
|
||||||
|
assert_equal expected_page2_display, assigns(:tournaments).size, "second page should contain the remaining tournaments (or up to per_page)"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
84
test/controllers/up_matches_cache_test.rb
Normal file
84
test/controllers/up_matches_cache_test.rb
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class UpMatchesCacheTest < ActionController::TestCase
|
||||||
|
tests TournamentsController
|
||||||
|
|
||||||
|
setup do
|
||||||
|
create_double_elim_tournament_1_6_with_multiple_weights_and_multiple_mats(16, 4, 2)
|
||||||
|
@tournament.update!(user_id: users(:one).id)
|
||||||
|
@tournament.reset_and_fill_bout_board
|
||||||
|
|
||||||
|
sign_in users(:one)
|
||||||
|
|
||||||
|
@original_perform_caching = ActionController::Base.perform_caching
|
||||||
|
ActionController::Base.perform_caching = true
|
||||||
|
Rails.cache.clear
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
Rails.cache.clear
|
||||||
|
ActionController::Base.perform_caching = @original_perform_caching
|
||||||
|
end
|
||||||
|
|
||||||
|
test "up_matches row fragments hit cache and invalidate when a mat queue changes" do
|
||||||
|
first_events = cache_events_for_up_matches do
|
||||||
|
get :up_matches, params: { id: @tournament.id }
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_operator cache_writes(first_events), :>, 0, "Expected initial render to write row fragments"
|
||||||
|
|
||||||
|
second_events = cache_events_for_up_matches do
|
||||||
|
get :up_matches, params: { id: @tournament.id }
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal 0, cache_writes(second_events), "Expected second render to reuse cached row fragments"
|
||||||
|
assert_operator cache_hits(second_events), :>, 0, "Expected second render to have cache hits"
|
||||||
|
|
||||||
|
mat = @tournament.mats.first
|
||||||
|
mat.reload
|
||||||
|
movable_match = mat.queue2_match || mat.queue1_match
|
||||||
|
assert movable_match, "Expected at least one queued match to move"
|
||||||
|
mat.assign_match_to_queue!(movable_match, 4)
|
||||||
|
|
||||||
|
third_events = cache_events_for_up_matches do
|
||||||
|
get :up_matches, params: { id: @tournament.id }
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_operator cache_writes(third_events), :>, 0, "Expected queue change to invalidate and rewrite at least one row fragment"
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def cache_events_for_up_matches
|
||||||
|
events = []
|
||||||
|
subscriber = lambda do |name, _start, _finish, _id, payload|
|
||||||
|
key = payload[:key].to_s
|
||||||
|
next unless key.include?("up_matches_mat_row")
|
||||||
|
|
||||||
|
events << { name: name, hit: payload[:hit] }
|
||||||
|
end
|
||||||
|
|
||||||
|
ActiveSupport::Notifications.subscribed(
|
||||||
|
subscriber,
|
||||||
|
/cache_(read|write|fetch_hit|generate)\.active_support/
|
||||||
|
) do
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
|
||||||
|
events
|
||||||
|
end
|
||||||
|
|
||||||
|
def cache_writes(events)
|
||||||
|
events.count { |event| event[:name] == "cache_write.active_support" }
|
||||||
|
end
|
||||||
|
|
||||||
|
def cache_hits(events)
|
||||||
|
events.count do |event|
|
||||||
|
event[:name] == "cache_fetch_hit.active_support" ||
|
||||||
|
(event[:name] == "cache_read.active_support" && event[:hit])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -56,6 +56,15 @@ class WrestlersControllerTest < ActionController::TestCase
|
|||||||
assert_redirected_to '/static_pages/not_allowed'
|
assert_redirected_to '/static_pages/not_allowed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assert_ads_hidden
|
||||||
|
assert_no_match(/blocked_message/, response.body)
|
||||||
|
assert_no_match(/adsbygoogle/, response.body)
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_ads_visible
|
||||||
|
assert_match(/blocked_message/, response.body)
|
||||||
|
end
|
||||||
|
|
||||||
test "logged in tournament owner should get edit wrestler page" do
|
test "logged in tournament owner should get edit wrestler page" do
|
||||||
sign_in_owner
|
sign_in_owner
|
||||||
get_edit
|
get_edit
|
||||||
@@ -305,4 +314,39 @@ class WrestlersControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
assert_select "a[href=?]", school_path(@school), text: /Back to/
|
assert_select "a[href=?]", school_path(@school), text: /Back to/
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "ads are hidden on wrestler new" do
|
||||||
|
sign_in_owner
|
||||||
|
new
|
||||||
|
success
|
||||||
|
assert_ads_hidden
|
||||||
|
end
|
||||||
|
|
||||||
|
test "ads are hidden on wrestler edit" do
|
||||||
|
sign_in_owner
|
||||||
|
get_edit
|
||||||
|
success
|
||||||
|
assert_ads_hidden
|
||||||
|
end
|
||||||
|
|
||||||
|
test "ads are hidden on wrestler new with school permission key" do
|
||||||
|
valid_key = @school.permission_key
|
||||||
|
get :new, params: { school: @school.id, school_permission_key: valid_key }
|
||||||
|
success
|
||||||
|
assert_ads_hidden
|
||||||
|
end
|
||||||
|
|
||||||
|
test "ads are hidden on wrestler edit with school permission key" do
|
||||||
|
valid_key = @school.permission_key
|
||||||
|
get :edit, params: { id: @wrestler.id, school_permission_key: valid_key }
|
||||||
|
success
|
||||||
|
assert_ads_hidden
|
||||||
|
end
|
||||||
|
|
||||||
|
test "ads are visible on wrestler show" do
|
||||||
|
sign_in_owner
|
||||||
|
get :show, params: { id: @wrestler.id }
|
||||||
|
success
|
||||||
|
assert_ads_visible
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
22
test/fixtures/tournament_job_statuses.yml
vendored
22
test/fixtures/tournament_job_statuses.yml
vendored
@@ -2,26 +2,4 @@
|
|||||||
|
|
||||||
# This model requires tournament, job_name, and status fields
|
# This model requires tournament, job_name, and status fields
|
||||||
|
|
||||||
queued_job:
|
|
||||||
tournament: one
|
|
||||||
job_name: "Test Queued Job"
|
|
||||||
status: "Queued"
|
|
||||||
details: "Test job details"
|
|
||||||
|
|
||||||
running_job:
|
|
||||||
tournament: one
|
|
||||||
job_name: "Test Running Job"
|
|
||||||
status: "Running"
|
|
||||||
details: "Test running job details"
|
|
||||||
|
|
||||||
errored_job:
|
|
||||||
tournament: one
|
|
||||||
job_name: "Test Errored Job"
|
|
||||||
status: "Errored"
|
|
||||||
details: "Test error message"
|
|
||||||
|
|
||||||
another_tournament_job:
|
|
||||||
tournament: two
|
|
||||||
job_name: "Another Tournament Job"
|
|
||||||
status: "Running"
|
|
||||||
details: "Different tournament test"
|
|
||||||
|
|||||||
289
test/integration/bout_board_test.rb
Normal file
289
test/integration/bout_board_test.rb
Normal file
@@ -0,0 +1,289 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class BoutBoardTest < ActionDispatch::IntegrationTest
|
||||||
|
test "only assigns matches with w1 and w2" do
|
||||||
|
create_double_elim_tournament_single_weight(16, "Regular Double Elimination 1-6")
|
||||||
|
mat = @tournament.mats.create!(name: "Mat 1")
|
||||||
|
|
||||||
|
@tournament.matches.update_all(mat_id: nil)
|
||||||
|
@tournament.matches.update_all(w1: nil)
|
||||||
|
|
||||||
|
@tournament.reset_and_fill_bout_board
|
||||||
|
mat.reload
|
||||||
|
|
||||||
|
assert_empty mat.queue_match_ids.compact, "No matches should be assigned when w1 is missing"
|
||||||
|
|
||||||
|
GenerateTournamentMatches.new(@tournament).generate
|
||||||
|
@tournament.reload
|
||||||
|
@tournament.matches.reload
|
||||||
|
|
||||||
|
@tournament.matches.update_all(mat_id: nil)
|
||||||
|
@tournament.matches.update_all(w2: nil)
|
||||||
|
|
||||||
|
@tournament.reset_and_fill_bout_board
|
||||||
|
mat.reload
|
||||||
|
|
||||||
|
assert_empty mat.queue_match_ids.compact, "No matches should be assigned when w2 is missing"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "only assigns matches without a loser1_name or loser2_name of BYE" do
|
||||||
|
create_double_elim_tournament_single_weight(16, "Regular Double Elimination 1-6")
|
||||||
|
mat = @tournament.mats.create!(name: "Mat 1")
|
||||||
|
|
||||||
|
@tournament.matches.update_all(mat_id: nil)
|
||||||
|
@tournament.matches.update_all(loser1_name: "BYE")
|
||||||
|
|
||||||
|
@tournament.reset_and_fill_bout_board
|
||||||
|
mat.reload
|
||||||
|
|
||||||
|
assert_empty mat.queue_match_ids.compact, "No matches should be assigned when loser1_name is BYE"
|
||||||
|
|
||||||
|
GenerateTournamentMatches.new(@tournament).generate
|
||||||
|
@tournament.reload
|
||||||
|
@tournament.matches.reload
|
||||||
|
|
||||||
|
@tournament.matches.update_all(mat_id: nil)
|
||||||
|
@tournament.matches.update_all(loser2_name: "BYE")
|
||||||
|
|
||||||
|
@tournament.reset_and_fill_bout_board
|
||||||
|
mat.reload
|
||||||
|
|
||||||
|
assert_empty mat.queue_match_ids.compact, "No matches should be assigned when loser1_name is BYE"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "moving queue2 from mat1 to mat2 shifts queues and unassigns bumped match" do
|
||||||
|
create_double_elim_tournament_1_6_with_multiple_weights_and_multiple_mats(16, 8, 2)
|
||||||
|
@tournament = Tournament.find(@tournament.id)
|
||||||
|
|
||||||
|
eligible_matches = Match.where(tournament_id: @tournament.id)
|
||||||
|
.where(finished: [nil, 0])
|
||||||
|
.where.not(bout_number: nil)
|
||||||
|
.where.not(w1: nil)
|
||||||
|
.where.not(w2: nil)
|
||||||
|
.where("loser1_name != ? OR loser1_name IS NULL", "BYE")
|
||||||
|
.where("loser2_name != ? OR loser2_name IS NULL", "BYE")
|
||||||
|
.where(mat_id: nil)
|
||||||
|
assert eligible_matches.count >= 8, "Expected enough eligible matches to fill two mats"
|
||||||
|
|
||||||
|
@tournament.reload
|
||||||
|
@tournament.matches.reload
|
||||||
|
@tournament.reset_and_fill_bout_board
|
||||||
|
@tournament = Tournament.find(@tournament.id)
|
||||||
|
mat1 = @tournament.mats.order(:id).first
|
||||||
|
mat2 = @tournament.mats.order(:id).second
|
||||||
|
mat1.reload
|
||||||
|
mat2.reload
|
||||||
|
|
||||||
|
assert mat1.queue2_match, "Expected mat1 queue2 to be assigned"
|
||||||
|
assert mat1.queue3_match, "Expected mat1 queue3 to be assigned"
|
||||||
|
assert mat1.queue4_match, "Expected mat1 queue4 to be assigned"
|
||||||
|
assert mat2.queue2_match, "Expected mat2 queue2 to be assigned"
|
||||||
|
assert mat2.queue3_match, "Expected mat2 queue3 to be assigned"
|
||||||
|
assert mat2.queue4_match, "Expected mat2 queue4 to be assigned"
|
||||||
|
|
||||||
|
mat1_q2 = mat1.queue2_match
|
||||||
|
mat1_q3 = mat1.queue3_match
|
||||||
|
mat1_q4 = mat1.queue4_match
|
||||||
|
|
||||||
|
mat2_q2 = mat2.queue2_match
|
||||||
|
mat2_q3 = mat2.queue3_match
|
||||||
|
mat2_q4 = mat2.queue4_match
|
||||||
|
|
||||||
|
mat2_q4_original_match = Match.find(mat2_q4.id)
|
||||||
|
|
||||||
|
mat2.assign_match_to_queue!(mat1_q2, 2)
|
||||||
|
|
||||||
|
mat1.reload
|
||||||
|
mat2.reload
|
||||||
|
|
||||||
|
assert_equal mat1_q2.id, mat2.queue2, "Moved match should land in mat2 queue2"
|
||||||
|
assert_equal mat2_q2.id, mat2.queue3, "Mat2 queue2 should shift to queue3"
|
||||||
|
assert_equal mat2_q3.id, mat2.queue4, "Mat2 queue3 should shift to queue4"
|
||||||
|
assert_nil mat2_q4.reload.mat_id, "Original mat2 queue4 match should be unassigned"
|
||||||
|
|
||||||
|
assert_equal mat1_q3.id, mat1.queue2, "Mat1 queue3 should shift to queue2"
|
||||||
|
assert_equal mat1_q4.id, mat1.queue3, "Mat1 queue4 should shift to queue3"
|
||||||
|
assert mat1.queue4, "Mat1 queue4 should be refilled"
|
||||||
|
refute_includes [mat1_q2.id, mat1_q3.id, mat1_q4.id], mat1.queue4, "Mat1 queue4 should be a new match"
|
||||||
|
assert_equal mat1.id, Match.find(mat1.queue4).mat_id, "New mat1 queue4 match should be assigned to mat1"
|
||||||
|
assert_nil mat2_q4_original_match.reload.mat_id, "Mat 2 queue4 match should no longer have a mat_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "moving queue2 to queue4 on the same mat shifts queues" do
|
||||||
|
create_double_elim_tournament_1_6_with_multiple_weights_and_multiple_mats(16, 8, 1)
|
||||||
|
@tournament.reset_and_fill_bout_board
|
||||||
|
|
||||||
|
mat1 = @tournament.mats.order(:id).first
|
||||||
|
mat1.reload
|
||||||
|
|
||||||
|
assert mat1.queue2_match, "Expected mat1 queue2 to be assigned"
|
||||||
|
assert mat1.queue3_match, "Expected mat1 queue3 to be assigned"
|
||||||
|
assert mat1.queue4_match, "Expected mat1 queue4 to be assigned"
|
||||||
|
|
||||||
|
mat1_q2 = mat1.queue2_match
|
||||||
|
mat1_q3 = mat1.queue3_match
|
||||||
|
mat1_q4 = mat1.queue4_match
|
||||||
|
|
||||||
|
mat1.assign_match_to_queue!(mat1_q2, 4)
|
||||||
|
mat1.reload
|
||||||
|
|
||||||
|
assert_equal mat1_q3.id, mat1.queue2, "Mat1 queue3 should shift to queue2"
|
||||||
|
assert_equal mat1_q4.id, mat1.queue3, "Mat1 queue4 should shift to queue3"
|
||||||
|
assert_equal mat1_q2.id, mat1.queue4, "Mat1 queue2 should move to queue4"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "moving queue4 to queue2 on the same mat shifts queues" do
|
||||||
|
create_double_elim_tournament_1_6_with_multiple_weights_and_multiple_mats(16, 8, 1)
|
||||||
|
@tournament.reset_and_fill_bout_board
|
||||||
|
|
||||||
|
mat1 = @tournament.mats.order(:id).first
|
||||||
|
mat1.reload
|
||||||
|
|
||||||
|
assert mat1.queue2_match, "Expected mat1 queue2 to be assigned"
|
||||||
|
assert mat1.queue3_match, "Expected mat1 queue3 to be assigned"
|
||||||
|
assert mat1.queue4_match, "Expected mat1 queue4 to be assigned"
|
||||||
|
|
||||||
|
mat1_q2 = mat1.queue2_match
|
||||||
|
mat1_q3 = mat1.queue3_match
|
||||||
|
mat1_q4 = mat1.queue4_match
|
||||||
|
|
||||||
|
mat1.assign_match_to_queue!(mat1_q4, 2)
|
||||||
|
mat1.reload
|
||||||
|
|
||||||
|
assert_equal mat1_q4.id, mat1.queue2, "Mat1 queue4 should move to queue2"
|
||||||
|
assert_equal mat1_q2.id, mat1.queue3, "Mat1 original queue2 should move to queue3"
|
||||||
|
assert_equal mat1_q3.id, mat1.queue4, "Mat1 original queue3 should move to queue4"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "queues stay filled while running through an entire tournament, mat_id's are null after a match is finished, and mat_id's exist when in a queue" do
|
||||||
|
create_double_elim_tournament_1_6_with_multiple_weights_and_multiple_mats(16, 4, 3)
|
||||||
|
@tournament = Tournament.find(@tournament.id)
|
||||||
|
@tournament.reset_and_fill_bout_board
|
||||||
|
|
||||||
|
max_iterations = @tournament.matches.count + 20
|
||||||
|
iterations = 0
|
||||||
|
|
||||||
|
loop do
|
||||||
|
iterations += 1
|
||||||
|
assert_operator iterations, :<=, max_iterations, "Loop exceeded expected match count"
|
||||||
|
|
||||||
|
assert_queue_depth_matches_available_bouts(@tournament)
|
||||||
|
|
||||||
|
next_match = next_queued_finishable_match(@tournament)
|
||||||
|
break unless next_match
|
||||||
|
|
||||||
|
next_match.update!(
|
||||||
|
winner_id: next_match.w1,
|
||||||
|
win_type: "Decision",
|
||||||
|
score: "1-0",
|
||||||
|
finished: 1
|
||||||
|
)
|
||||||
|
|
||||||
|
assert_nil next_match.reload.mat_id, "The match should have a null mat_id after it is finished"
|
||||||
|
|
||||||
|
@tournament.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
remaining_finishable = finishable_match_scope(@tournament).count
|
||||||
|
assert_equal 0, remaining_finishable, "All finishable matches should be completed"
|
||||||
|
assert_queue_depth_matches_available_bouts(@tournament)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "Deleting a mat mid tournament does not delete any matches" do
|
||||||
|
create_double_elim_tournament_1_6_with_multiple_weights_and_multiple_mats(14, 1, 3)
|
||||||
|
assert_equal 29, @tournament.matches.count, "Before deleting a mat total number of matches for a 14 man double elim 1-6 tournament should be 29"
|
||||||
|
assert_equal 1, @tournament.matches.select{|m| m.bracket_position == "1/2"}.count, "Before deleting a mat there should be 1 match for bracket position 1/2"
|
||||||
|
assert_equal 1, @tournament.matches.select{|m| m.bracket_position == "3/4"}.count, "Before deleting a mat there should be 1 match for bracket position 3/4"
|
||||||
|
assert_equal 1, @tournament.matches.select{|m| m.bracket_position == "5/6"}.count, "Before deleting a mat there should be 1 match for bracket position 5/6"
|
||||||
|
assert_equal 8, @tournament.matches.select{|m| m.bracket_position == "Bracket Round of 16"}.count, "Before deleting a mat there should be 8 matches for bracket position Bracket Round of 16"
|
||||||
|
assert_equal 4, @tournament.matches.select{|m| m.bracket_position == "Conso Round of 8.1"}.count, "Before deleting a mat there should be 4 matches for bracket position Conso Round of 8.1"
|
||||||
|
assert_equal 4, @tournament.matches.select{|m| m.bracket_position == "Quarter"}.count, "Before deleting a mat there should be 4 matches for bracket position Quarter"
|
||||||
|
assert_equal 2, @tournament.matches.select{|m| m.bracket_position == "Semis"}.count, "Before deleting a mat there should be 2 matches for bracket position Semis"
|
||||||
|
assert_equal 4, @tournament.matches.select{|m| m.bracket_position == "Conso Round of 8.2"}.count, "Before deleting a mat there should be 4 matches for bracket position Conso Round of 8.2"
|
||||||
|
assert_equal 2, @tournament.matches.select{|m| m.bracket_position == "Conso Quarter"}.count, "Before deleting a mat there should be 2 matches for bracket position Conso Quarter"
|
||||||
|
assert_equal 2, @tournament.matches.select{|m| m.bracket_position == "Conso Semis"}.count, "Before deleting a mat there should be 2 matches for bracket position Conso Semis"
|
||||||
|
|
||||||
|
@tournament.mats.first.destroy
|
||||||
|
@tournament.reload
|
||||||
|
@tournament.matches.reload
|
||||||
|
|
||||||
|
assert_equal 29, @tournament.matches.count, "After deleting a mat total number of matches for a 14 man double elim 1-6 tournament should still be 29"
|
||||||
|
assert_equal 1, @tournament.matches.select{|m| m.bracket_position == "1/2"}.count, "After deleting a mat there should still be 1 match for bracket position 1/2"
|
||||||
|
assert_equal 1, @tournament.matches.select{|m| m.bracket_position == "3/4"}.count, "After deleting a mat there should still be 1 match for bracket position 3/4"
|
||||||
|
assert_equal 1, @tournament.matches.select{|m| m.bracket_position == "5/6"}.count, "After deleting a mat there should still be 1 match for bracket position 5/6"
|
||||||
|
assert_equal 8, @tournament.matches.select{|m| m.bracket_position == "Bracket Round of 16"}.count, "After deleting a mat there should still be 8 matches for bracket position Bracket Round of 16"
|
||||||
|
assert_equal 4, @tournament.matches.select{|m| m.bracket_position == "Conso Round of 8.1"}.count, "After deleting a mat there should still be 4 matches for bracket position Conso Round of 8.1"
|
||||||
|
assert_equal 4, @tournament.matches.select{|m| m.bracket_position == "Quarter"}.count, "After deleting a mat there should still be 4 matches for bracket position Quarter"
|
||||||
|
assert_equal 2, @tournament.matches.select{|m| m.bracket_position == "Semis"}.count, "After deleting a mat there should still be 2 matches for bracket position Semis"
|
||||||
|
assert_equal 4, @tournament.matches.select{|m| m.bracket_position == "Conso Round of 8.2"}.count, "After deleting a mat there should still be 4 matches for bracket position Conso Round of 8.2"
|
||||||
|
assert_equal 2, @tournament.matches.select{|m| m.bracket_position == "Conso Quarter"}.count, "After deleting a mat there should still be 2 matches for bracket position Conso Quarter"
|
||||||
|
assert_equal 2, @tournament.matches.select{|m| m.bracket_position == "Conso Semis"}.count, "After deleting a mat there should still be 2 matches for bracket position Conso Semis"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "When matches are generated, they're assigned a mat in round robin fashion" do
|
||||||
|
create_double_elim_tournament_1_6_with_multiple_weights_and_multiple_mats(16, 8, 2)
|
||||||
|
@tournament = Tournament.find(@tournament.id)
|
||||||
|
|
||||||
|
@tournament.reload
|
||||||
|
@tournament.matches.reload
|
||||||
|
@tournament.reset_and_fill_bout_board
|
||||||
|
@tournament = Tournament.find(@tournament.id)
|
||||||
|
mat1 = @tournament.mats.order(:id).first
|
||||||
|
mat2 = @tournament.mats.order(:id).second
|
||||||
|
mat1.reload
|
||||||
|
mat2.reload
|
||||||
|
matches_ordered_by_bout = @tournament.matches.sort_by{|m| m.bout_number}
|
||||||
|
|
||||||
|
assert_equal matches_ordered_by_bout.first.bout_number, mat1.queue1_match.bout_number, "The first bout number of the tournament should be queue1 on mat 1"
|
||||||
|
assert_equal matches_ordered_by_bout.second.bout_number, mat2.queue1_match.bout_number, "The second bout number of the tournament should be queue1 on mat 2"
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def finishable_match_scope(tournament)
|
||||||
|
Match.where(tournament_id: tournament.id, finished: [nil, 0])
|
||||||
|
.where.not(w1: nil)
|
||||||
|
.where.not(w2: nil)
|
||||||
|
.where("loser1_name != ? OR loser1_name IS NULL", "BYE")
|
||||||
|
.where("loser2_name != ? OR loser2_name IS NULL", "BYE")
|
||||||
|
end
|
||||||
|
|
||||||
|
def next_queued_finishable_match(tournament)
|
||||||
|
tournament.mats.order(:id).each do |mat|
|
||||||
|
match = mat.queue1_match
|
||||||
|
next unless match
|
||||||
|
next unless match.finished != 1
|
||||||
|
return match if match.w1.present? && match.w2.present?
|
||||||
|
end
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_queue_depth_matches_available_bouts(tournament)
|
||||||
|
available_count = finishable_match_scope(tournament).count
|
||||||
|
queue_capacity = tournament.mats.count * 4
|
||||||
|
expected_queued_count = [available_count, queue_capacity].min
|
||||||
|
|
||||||
|
queued_ids = tournament.mats.order(:id).flat_map(&:queue_match_ids).compact
|
||||||
|
assert_equal expected_queued_count, queued_ids.count,
|
||||||
|
"Queue depth should match available matches (expected #{expected_queued_count}, got #{queued_ids.count})"
|
||||||
|
|
||||||
|
tournament.mats.order(:id).each do |mat|
|
||||||
|
assert_queue_has_no_gaps(mat)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert_queue_has_no_gaps(mat)
|
||||||
|
if mat.queue2.present?
|
||||||
|
assert mat.queue1.present?, "Mat #{mat.id} queue1 must be present when queue2 is present"
|
||||||
|
assert_equal mat.id, mat.queue1_match.mat_id, "The match in queue1 should have a mat_id"
|
||||||
|
end
|
||||||
|
if mat.queue3.present?
|
||||||
|
assert mat.queue2.present?, "Mat #{mat.id} queue2 must be present when queue3 is present"
|
||||||
|
assert_equal mat.id, mat.queue2_match.mat_id, "The match in queue2 should have a mat_id"
|
||||||
|
end
|
||||||
|
if mat.queue4.present?
|
||||||
|
assert mat.queue3.present?, "Mat #{mat.id} queue3 must be present when queue4 is present"
|
||||||
|
assert_equal mat.id, mat.queue3_match.mat_id, "The match in queue3 should have a mat_id"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user