From e2157179145a4faab24d7c9cc0aa60229151f6b5 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 10 Feb 2016 15:16:58 +0000 Subject: [PATCH 01/46] Start of api --- app/assets/javascripts/api.js.coffee | 3 +++ app/assets/stylesheets/api.css | 4 ++++ app/controllers/api_controller.rb | 10 ++++++++++ app/helpers/api_helper.rb | 2 ++ app/views/api/tournament.jbuilder | 1 + app/views/api/tournaments.jbuilder | 4 ++++ config/routes.rb | 5 +++++ test/controllers/api_controller_test.rb | 7 +++++++ 8 files changed, 36 insertions(+) create mode 100644 app/assets/javascripts/api.js.coffee create mode 100644 app/assets/stylesheets/api.css create mode 100644 app/controllers/api_controller.rb create mode 100644 app/helpers/api_helper.rb create mode 100644 app/views/api/tournament.jbuilder create mode 100644 app/views/api/tournaments.jbuilder create mode 100644 test/controllers/api_controller_test.rb diff --git a/app/assets/javascripts/api.js.coffee b/app/assets/javascripts/api.js.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/api.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/api.css b/app/assets/stylesheets/api.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/api.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb new file mode 100644 index 0000000..8f3a604 --- /dev/null +++ b/app/controllers/api_controller.rb @@ -0,0 +1,10 @@ +class ApiController < ApplicationController + + def tournaments + @tournaments = Tournament.all + end + + def tournament + @tournament = Tournament.where(:id => params[:tournament]).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first + end +end diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb new file mode 100644 index 0000000..1f82fcf --- /dev/null +++ b/app/helpers/api_helper.rb @@ -0,0 +1,2 @@ +module ApiHelper +end diff --git a/app/views/api/tournament.jbuilder b/app/views/api/tournament.jbuilder new file mode 100644 index 0000000..171625c --- /dev/null +++ b/app/views/api/tournament.jbuilder @@ -0,0 +1 @@ +json.(@tournament, :id, :name, :address, :director, :director_email, :schools, :weights, :mats, :matches) \ No newline at end of file diff --git a/app/views/api/tournaments.jbuilder b/app/views/api/tournaments.jbuilder new file mode 100644 index 0000000..d53a86a --- /dev/null +++ b/app/views/api/tournaments.jbuilder @@ -0,0 +1,4 @@ +json.array!(@tournaments) do |tournament| + json.extract! tournament, :id, :name, :address, :director, :director_email + json.url tournament_url(tournament, format: :json) +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2b49bab..799b3de 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -51,6 +51,11 @@ Wrestling::Application.routes.draw do get 'tournaments/:id/error' => 'tournaments#error' post "/tournaments/:id/swap" => "tournaments#swap", :as => :swap_wrestlers + + #API + get "/api/tournaments" => "api#tournaments" + get "/api/tournaments/:tournament" => "api#tournament" + # Example of regular route: # get 'products/:id' => 'catalog#view' diff --git a/test/controllers/api_controller_test.rb b/test/controllers/api_controller_test.rb new file mode 100644 index 0000000..5ba1ef0 --- /dev/null +++ b/test/controllers/api_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class ApiControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end From 643012ae1dfcfa8f54f763cedab6634fa8723815 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 10 Feb 2016 15:17:32 +0000 Subject: [PATCH 02/46] Change to ruby 2.3.0 on travis ci --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 92c17c6..13a6afa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: ruby rvm: -- 2.2.0 +- 2.3.0 env: - DB=sqlite script: From 4685173548a9e6bef2a58564bd3e32e1835b8c76 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 10 Feb 2016 15:20:52 +0000 Subject: [PATCH 03/46] Removed url for tournaments api --- app/views/api/tournaments.jbuilder | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/api/tournaments.jbuilder b/app/views/api/tournaments.jbuilder index d53a86a..a0487e3 100644 --- a/app/views/api/tournaments.jbuilder +++ b/app/views/api/tournaments.jbuilder @@ -1,4 +1,3 @@ json.array!(@tournaments) do |tournament| json.extract! tournament, :id, :name, :address, :director, :director_email - json.url tournament_url(tournament, format: :json) end \ No newline at end of file From dfa0972747025f0a3d7c2a743cfbee785262040d Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 10 Feb 2016 16:33:44 +0000 Subject: [PATCH 04/46] Added linemanjs as frontend --- Gemfile | 1 + Gemfile.lock | 3 + app/controllers/api_controller.rb | 5 + app/views/api/index.html.erb | 2 + config/application.rb | 2 +- config/routes.rb | 1 + frontend/.gitignore | 9 + frontend/.npmignore | 9 + frontend/.travis.yml | 4 + frontend/Gruntfile.js | 4 + frontend/Procfile | 1 + frontend/README.md | 1 + frontend/app/css/style.css | 4 + frontend/app/img/.keep | 0 frontend/app/js/.keep | 0 frontend/app/js/hello.js | 14 + frontend/app/pages/index.us | 12 + frontend/app/static/favicon.ico | Bin 0 -> 1150 bytes frontend/app/templates/hello.us | 3 + frontend/config/application.js | 59 + frontend/config/files.js | 23 + frontend/config/lineman.js | 1 + frontend/config/server.js | 21 + frontend/config/spec.json | 9 + frontend/package.json | 16 + frontend/spec/hello-spec.js | 4 + frontend/spec/helpers/helper.js | 2 + frontend/spec/helpers/jasmine-fixture.js | 433 +++++++ frontend/spec/helpers/jasmine-given.js | 373 ++++++ frontend/spec/helpers/jasmine-only.js | 98 ++ frontend/spec/helpers/jasmine-stealth.js | 214 ++++ frontend/tasks/.keep | 0 frontend/vendor/css/.keep | 0 frontend/vendor/img/.keep | 0 frontend/vendor/js/underscore.js | 1343 ++++++++++++++++++++++ frontend/vendor/static/.keep | 0 36 files changed, 2670 insertions(+), 1 deletion(-) create mode 100644 app/views/api/index.html.erb create mode 100644 frontend/.gitignore create mode 100644 frontend/.npmignore create mode 100644 frontend/.travis.yml create mode 100644 frontend/Gruntfile.js create mode 100644 frontend/Procfile create mode 100644 frontend/README.md create mode 100644 frontend/app/css/style.css create mode 100644 frontend/app/img/.keep create mode 100644 frontend/app/js/.keep create mode 100644 frontend/app/js/hello.js create mode 100644 frontend/app/pages/index.us create mode 100644 frontend/app/static/favicon.ico create mode 100644 frontend/app/templates/hello.us create mode 100644 frontend/config/application.js create mode 100644 frontend/config/files.js create mode 100644 frontend/config/lineman.js create mode 100644 frontend/config/server.js create mode 100644 frontend/config/spec.json create mode 100644 frontend/package.json create mode 100644 frontend/spec/hello-spec.js create mode 100644 frontend/spec/helpers/helper.js create mode 100644 frontend/spec/helpers/jasmine-fixture.js create mode 100644 frontend/spec/helpers/jasmine-given.js create mode 100644 frontend/spec/helpers/jasmine-only.js create mode 100644 frontend/spec/helpers/jasmine-stealth.js create mode 100644 frontend/tasks/.keep create mode 100644 frontend/vendor/css/.keep create mode 100644 frontend/vendor/img/.keep create mode 100644 frontend/vendor/js/underscore.js create mode 100644 frontend/vendor/static/.keep diff --git a/Gemfile b/Gemfile index 21bcd48..8ebfa18 100644 --- a/Gemfile +++ b/Gemfile @@ -56,6 +56,7 @@ gem 'spring', :group => :development gem 'delayed_job_active_record' gem 'puma' gem 'brakeman' + gem 'rails-lineman' group :development do #gem 'bullet' diff --git a/Gemfile.lock b/Gemfile.lock index e6c97cb..98334b4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -131,6 +131,8 @@ GEM rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.2) loofah (~> 2.0) + rails-lineman (0.3.0) + rake rails_12factor (0.0.3) rails_serve_static_assets rails_stdout_logging @@ -207,6 +209,7 @@ DEPENDENCIES passenger puma rails (= 4.2.5) + rails-lineman rails_12factor rb-readline round_robin_tournament diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 8f3a604..6e74089 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -1,4 +1,9 @@ class ApiController < ApplicationController + protect_from_forgery with: :null_session + + def index + + end def tournaments @tournaments = Tournament.all diff --git a/app/views/api/index.html.erb b/app/views/api/index.html.erb new file mode 100644 index 0000000..7eefeea --- /dev/null +++ b/app/views/api/index.html.erb @@ -0,0 +1,2 @@ +<%= stylesheet_link_tag "lineman/app" %> +<%= javascript_include_tag "lineman/app" %> \ No newline at end of file diff --git a/config/application.rb b/config/application.rb index 80a1c83..d8037e7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -29,7 +29,7 @@ module Wrestling config.active_job.queue_adapter = :delayed_job - + config.rails_lineman.lineman_project_location = "frontend" end diff --git a/config/routes.rb b/config/routes.rb index 799b3de..a4008fb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,6 +55,7 @@ Wrestling::Application.routes.draw do #API get "/api/tournaments" => "api#tournaments" get "/api/tournaments/:tournament" => "api#tournament" + get "/api/index" => "api#index" # Example of regular route: # get 'products/:id' => 'catalog#view' diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..275ec00 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,9 @@ +.DS_Store + +#ignore node_modules, as the node project is not "deployed" per se: http://www.mikealrogers.com/posts/nodemodules-in-git.html +/node_modules + +/dist +/generated + +.sass-cache diff --git a/frontend/.npmignore b/frontend/.npmignore new file mode 100644 index 0000000..275ec00 --- /dev/null +++ b/frontend/.npmignore @@ -0,0 +1,9 @@ +.DS_Store + +#ignore node_modules, as the node project is not "deployed" per se: http://www.mikealrogers.com/posts/nodemodules-in-git.html +/node_modules + +/dist +/generated + +.sass-cache diff --git a/frontend/.travis.yml b/frontend/.travis.yml new file mode 100644 index 0000000..53ce7b2 --- /dev/null +++ b/frontend/.travis.yml @@ -0,0 +1,4 @@ +language: node_js +node_js: +- 0.10 +script: "lineman spec-ci" diff --git a/frontend/Gruntfile.js b/frontend/Gruntfile.js new file mode 100644 index 0000000..ed05645 --- /dev/null +++ b/frontend/Gruntfile.js @@ -0,0 +1,4 @@ +/*global module:false*/ +module.exports = function(grunt) { + require('./config/lineman').config.grunt.run(grunt); +}; diff --git a/frontend/Procfile b/frontend/Procfile new file mode 100644 index 0000000..8513c01 --- /dev/null +++ b/frontend/Procfile @@ -0,0 +1 @@ +web: npm run production diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..debad91 --- /dev/null +++ b/frontend/README.md @@ -0,0 +1 @@ +# My Lineman Application \ No newline at end of file diff --git a/frontend/app/css/style.css b/frontend/app/css/style.css new file mode 100644 index 0000000..2c361ec --- /dev/null +++ b/frontend/app/css/style.css @@ -0,0 +1,4 @@ +.hello { + background-color: #efefef; + border: 1px solid #dedede; +} diff --git a/frontend/app/img/.keep b/frontend/app/img/.keep new file mode 100644 index 0000000..e69de29 diff --git a/frontend/app/js/.keep b/frontend/app/js/.keep new file mode 100644 index 0000000..e69de29 diff --git a/frontend/app/js/hello.js b/frontend/app/js/hello.js new file mode 100644 index 0000000..4a9d1e5 --- /dev/null +++ b/frontend/app/js/hello.js @@ -0,0 +1,14 @@ +window.helloText = function() { + return 'Hello, World!'; +}; + +window.hello = function() { + html = JST['app/templates/hello.us']({text: helloText()}); + document.body.innerHTML += html; +}; + +if(window.addEventListener) { + window.addEventListener('DOMContentLoaded', hello, false); +} else { + window.attachEvent('onload', hello); +} diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us new file mode 100644 index 0000000..365a292 --- /dev/null +++ b/frontend/app/pages/index.us @@ -0,0 +1,12 @@ + + + + <%= pkg.name %> + + + + + +

Test

+ + diff --git a/frontend/app/static/favicon.ico b/frontend/app/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..70de606140dd3f4a4eb64e224e50675a20db8a33 GIT binary patch literal 1150 zcmZQzU<5(|0R|wcz>vYhz#zuJz@P!dKp~(AL>x#lFaYI<1pk5Ruwg>lKj6>@HtRnS zK;^NS1D5ORXoso6puc_n3NivF4mZQq)wKg;E|MHrjjxY4Of8rOD}d_f + <%= text %> + \ No newline at end of file diff --git a/frontend/config/application.js b/frontend/config/application.js new file mode 100644 index 0000000..43bbe4e --- /dev/null +++ b/frontend/config/application.js @@ -0,0 +1,59 @@ +/* Exports a function which returns an object that overrides the default & + * plugin grunt configuration object. + * + * You can familiarize yourself with Lineman's defaults by looking at: + * + * - https://github.com/linemanjs/lineman/blob/master/config/application.coffee + * - https://github.com/linemanjs/lineman/blob/master/config/plugins + * + * You can also ask about Lineman's config from the command line: + * + * $ lineman config #=> to print the entire config + * $ lineman config concat_sourcemap.js #=> to see the JS config for the concat task. + */ +module.exports = function(lineman) { + //Override application configuration here. Common examples follow in the comments. + return { + + // API Proxying + // + // During development, you'll likely want to make XHR (AJAX) requests to an API on the same + // port as your lineman development server. By enabling the API proxy and setting the port, all + // requests for paths that don't match a static asset in ./generated will be forwarded to + // whatever service might be running on the specified port. + // + // server: { + // apiProxy: { + // enabled: true, + // host: 'localhost', + // port: 3000 + // } + // }, + + // Sass + // + // Lineman supports Sass via grunt-contrib-sass, which requires you first + // have Ruby installed as well as the `sass` gem. To enable it, uncomment the + // following line: + // + // enableSass: true, + + // Asset Fingerprints + // + // Lineman can fingerprint your static assets by appending a hash to the filename + // and logging a manifest of logical-to-hashed filenames in dist/assets.json + // via grunt-asset-fingerprint + // + // enableAssetFingerprint: true, + + // LiveReload + // + // Lineman can LiveReload browsers whenever a file is changed that results in + // assets to be processed, preventing the need to hit F5/Cmd-R every time you + // make a change in each browser you're working against. To enable LiveReload, + // comment out the following line: + // + // livereload: true + + }; +}; diff --git a/frontend/config/files.js b/frontend/config/files.js new file mode 100644 index 0000000..a64ab32 --- /dev/null +++ b/frontend/config/files.js @@ -0,0 +1,23 @@ +/* Exports a function which returns an object that overrides the default & + * plugin file patterns (used widely through the app configuration) + * + * To see the default definitions for Lineman's file paths and globs, see: + * + * - https://github.com/linemanjs/lineman/blob/master/config/files.coffee + */ +module.exports = function(lineman) { + //Override file patterns here + return { + + // As an example, to override the file patterns for + // the order in which to load third party JS libs: + // + // js: { + // vendor: [ + // "vendor/js/underscore.js", + // "vendor/js/**/*.js" + // ] + // } + + }; +}; diff --git a/frontend/config/lineman.js b/frontend/config/lineman.js new file mode 100644 index 0000000..0ce0689 --- /dev/null +++ b/frontend/config/lineman.js @@ -0,0 +1 @@ +module.exports = require(process.env['LINEMAN_MAIN']); diff --git a/frontend/config/server.js b/frontend/config/server.js new file mode 100644 index 0000000..1654dc1 --- /dev/null +++ b/frontend/config/server.js @@ -0,0 +1,21 @@ +/* Define custom server-side HTTP routes for lineman's development server + * These might be as simple as stubbing a little JSON to + * facilitate development of code that interacts with an HTTP service + * (presumably, mirroring one that will be reachable in a live environment). + * + * It's important to remember that any custom endpoints defined here + * will only be available in development, as lineman only builds + * static assets, it can't run server-side code. + * + * This file can be very useful for rapid prototyping or even organically + * defining a spec based on the needs of the client code that emerge. + * + */ + +module.exports = { + drawRoutes: function(app) { + // app.get('/api/greeting/:message', function(req, res){ + // res.json({ message: "OK, "+req.params.message }); + // }); + } +}; \ No newline at end of file diff --git a/frontend/config/spec.json b/frontend/config/spec.json new file mode 100644 index 0000000..b6258d5 --- /dev/null +++ b/frontend/config/spec.json @@ -0,0 +1,9 @@ +{ + "framework" : "jasmine", + "launch_in_dev" : ["Chrome"], + "launch_in_ci" : ["PhantomJS"], + "src_files" : [ + "generated/js/app.js", + "generated/js/spec.js" + ] +} \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..b58aa98 --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,16 @@ +{ + "name": "frontend", + "description": "An HTML/JS/CSS app", + "version": "0.0.1", + "private": true, + "author": "John Doe", + "devDependencies": { + "lineman": "~0.36.6", + "lineman-rails": "^0.1.0" + }, + "scripts": { + "start": "lineman run", + "test": "lineman spec-ci", + "production": "lineman clean build && npm i express@3 && node -e \"var e = require('express'), a = e(); a.use(e.static('dist/')); a.listen(process.env.PORT)\"" + } +} diff --git a/frontend/spec/hello-spec.js b/frontend/spec/hello-spec.js new file mode 100644 index 0000000..208eca2 --- /dev/null +++ b/frontend/spec/hello-spec.js @@ -0,0 +1,4 @@ +describe(".helloText", function(){ + When(function(){ this.result = helloText(); }); + Then(function(){ expect(this.result).toEqual("Hello, World!"); }); +}); diff --git a/frontend/spec/helpers/helper.js b/frontend/spec/helpers/helper.js new file mode 100644 index 0000000..3c9ebf8 --- /dev/null +++ b/frontend/spec/helpers/helper.js @@ -0,0 +1,2 @@ +window.context = window.describe; +window.xcontext = window.xdescribe; diff --git a/frontend/spec/helpers/jasmine-fixture.js b/frontend/spec/helpers/jasmine-fixture.js new file mode 100644 index 0000000..1d28910 --- /dev/null +++ b/frontend/spec/helpers/jasmine-fixture.js @@ -0,0 +1,433 @@ +/* jasmine-fixture - 1.3.2 + * Makes injecting HTML snippets into the DOM easy & clean! + * https://github.com/searls/jasmine-fixture + */ +(function() { + var createHTMLBlock, + __slice = [].slice; + + (function($) { + var ewwSideEffects, jasmineFixture, originalAffix, originalJasmineDotFixture, originalJasmineFixture, root, _, _ref; + root = (1, eval)('this'); + originalJasmineFixture = root.jasmineFixture; + originalJasmineDotFixture = (_ref = root.jasmine) != null ? _ref.fixture : void 0; + originalAffix = root.affix; + _ = function(list) { + return { + inject: function(iterator, memo) { + var item, _i, _len, _results; + _results = []; + for (_i = 0, _len = list.length; _i < _len; _i++) { + item = list[_i]; + _results.push(memo = iterator(memo, item)); + } + return _results; + } + }; + }; + root.jasmineFixture = function($) { + var $whatsTheRootOf, affix, create, jasmineFixture, noConflict; + affix = function(selectorOptions) { + return create.call(this, selectorOptions, true); + }; + create = function(selectorOptions, attach) { + var $top; + $top = null; + _(selectorOptions.split(/[ ](?![^\{]*\})(?=[^\]]*?(?:\[|$))/)).inject(function($parent, elementSelector) { + var $el; + if (elementSelector === ">") { + return $parent; + } + $el = createHTMLBlock($, elementSelector); + if (attach || $top) { + $el.appendTo($parent); + } + $top || ($top = $el); + return $el; + }, $whatsTheRootOf(this)); + return $top; + }; + noConflict = function() { + var currentJasmineFixture, _ref1; + currentJasmineFixture = jasmine.fixture; + root.jasmineFixture = originalJasmineFixture; + if ((_ref1 = root.jasmine) != null) { + _ref1.fixture = originalJasmineDotFixture; + } + root.affix = originalAffix; + return currentJasmineFixture; + }; + $whatsTheRootOf = function(that) { + if ((that != null ? that.jquery : void 0) != null) { + return that; + } else if ($('#jasmine_content').length > 0) { + return $('#jasmine_content'); + } else { + return $('
').appendTo('body'); + } + }; + jasmineFixture = { + affix: affix, + create: create, + noConflict: noConflict + }; + ewwSideEffects(jasmineFixture); + return jasmineFixture; + }; + ewwSideEffects = function(jasmineFixture) { + var _ref1; + if ((_ref1 = root.jasmine) != null) { + _ref1.fixture = jasmineFixture; + } + $.fn.affix = root.affix = jasmineFixture.affix; + return afterEach(function() { + return $('#jasmine_content').remove(); + }); + }; + if ($) { + return jasmineFixture = root.jasmineFixture($); + } else { + return root.affix = function() { + var nowJQueryExists; + nowJQueryExists = window.jQuery || window.$; + if (nowJQueryExists != null) { + jasmineFixture = root.jasmineFixture(nowJQueryExists); + return affix.call.apply(affix, [this].concat(__slice.call(arguments))); + } else { + throw new Error("jasmine-fixture requires jQuery to be defined at window.jQuery or window.$"); + } + }; + } + })(window.jQuery || window.$); + + createHTMLBlock = (function() { + var bindData, bindEvents, parseAttributes, parseClasses, parseContents, parseEnclosure, parseReferences, parseVariableScope, regAttr, regAttrDfn, regAttrs, regCBrace, regClass, regClasses, regData, regDatas, regEvent, regEvents, regExclamation, regId, regReference, regTag, regTagNotContent, regZenTagDfn; + createHTMLBlock = function($, ZenObject, data, functions, indexes) { + var ZenCode, arr, block, blockAttrs, blockClasses, blockHTML, blockId, blockTag, blocks, el, el2, els, forScope, indexName, inner, len, obj, origZenCode, paren, result, ret, zc, zo; + if ($.isPlainObject(ZenObject)) { + ZenCode = ZenObject.main; + } else { + ZenCode = ZenObject; + ZenObject = { + main: ZenCode + }; + } + origZenCode = ZenCode; + if (indexes === undefined) { + indexes = {}; + } + if (ZenCode.charAt(0) === "!" || $.isArray(data)) { + if ($.isArray(data)) { + forScope = ZenCode; + } else { + obj = parseEnclosure(ZenCode, "!"); + obj = obj.substring(obj.indexOf(":") + 1, obj.length - 1); + forScope = parseVariableScope(ZenCode); + } + while (forScope.charAt(0) === "@") { + forScope = parseVariableScope("!for:!" + parseReferences(forScope, ZenObject)); + } + zo = ZenObject; + zo.main = forScope; + el = $(); + if (ZenCode.substring(0, 5) === "!for:" || $.isArray(data)) { + if (!$.isArray(data) && obj.indexOf(":") > 0) { + indexName = obj.substring(0, obj.indexOf(":")); + obj = obj.substr(obj.indexOf(":") + 1); + } + arr = ($.isArray(data) ? data : data[obj]); + zc = zo.main; + if ($.isArray(arr) || $.isPlainObject(arr)) { + $.map(arr, function(value, index) { + var next; + zo.main = zc; + if (indexName !== undefined) { + indexes[indexName] = index; + } + if (!$.isPlainObject(value)) { + value = { + value: value + }; + } + next = createHTMLBlock($, zo, value, functions, indexes); + if (el.length !== 0) { + return $.each(next, function(index, value) { + return el.push(value); + }); + } + }); + } + if (!$.isArray(data)) { + ZenCode = ZenCode.substr(obj.length + 6 + forScope.length); + } else { + ZenCode = ""; + } + } else if (ZenCode.substring(0, 4) === "!if:") { + result = parseContents("!" + obj + "!", data, indexes); + if (result !== "undefined" || result !== "false" || result !== "") { + el = createHTMLBlock($, zo, data, functions, indexes); + } + ZenCode = ZenCode.substr(obj.length + 5 + forScope.length); + } + ZenObject.main = ZenCode; + } else if (ZenCode.charAt(0) === "(") { + paren = parseEnclosure(ZenCode, "(", ")"); + inner = paren.substring(1, paren.length - 1); + ZenCode = ZenCode.substr(paren.length); + zo = ZenObject; + zo.main = inner; + el = createHTMLBlock($, zo, data, functions, indexes); + } else { + blocks = ZenCode.match(regZenTagDfn); + block = blocks[0]; + if (block.length === 0) { + return ""; + } + if (block.indexOf("@") >= 0) { + ZenCode = parseReferences(ZenCode, ZenObject); + zo = ZenObject; + zo.main = ZenCode; + return createHTMLBlock($, zo, data, functions, indexes); + } + block = parseContents(block, data, indexes); + blockClasses = parseClasses($, block); + if (regId.test(block)) { + blockId = regId.exec(block)[1]; + } + blockAttrs = parseAttributes(block, data); + blockTag = (block.charAt(0) === "{" ? "span" : "div"); + if (ZenCode.charAt(0) !== "#" && ZenCode.charAt(0) !== "." && ZenCode.charAt(0) !== "{") { + blockTag = regTag.exec(block)[1]; + } + if (block.search(regCBrace) !== -1) { + blockHTML = block.match(regCBrace)[1]; + } + blockAttrs = $.extend(blockAttrs, { + id: blockId, + "class": blockClasses, + html: blockHTML + }); + el = $("<" + blockTag + ">", blockAttrs); + el.attr(blockAttrs); + el = bindEvents(block, el, functions); + el = bindData(block, el, data); + ZenCode = ZenCode.substr(blocks[0].length); + ZenObject.main = ZenCode; + } + if (ZenCode.length > 0) { + if (ZenCode.charAt(0) === ">") { + if (ZenCode.charAt(1) === "(") { + zc = parseEnclosure(ZenCode.substr(1), "(", ")"); + ZenCode = ZenCode.substr(zc.length + 1); + } else if (ZenCode.charAt(1) === "!") { + obj = parseEnclosure(ZenCode.substr(1), "!"); + forScope = parseVariableScope(ZenCode.substr(1)); + zc = obj + forScope; + ZenCode = ZenCode.substr(zc.length + 1); + } else { + len = Math.max(ZenCode.indexOf("+"), ZenCode.length); + zc = ZenCode.substring(1, len); + ZenCode = ZenCode.substr(len); + } + zo = ZenObject; + zo.main = zc; + els = $(createHTMLBlock($, zo, data, functions, indexes)); + els.appendTo(el); + } + if (ZenCode.charAt(0) === "+") { + zo = ZenObject; + zo.main = ZenCode.substr(1); + el2 = createHTMLBlock($, zo, data, functions, indexes); + $.each(el2, function(index, value) { + return el.push(value); + }); + } + } + ret = el; + return ret; + }; + bindData = function(ZenCode, el, data) { + var datas, i, split; + if (ZenCode.search(regDatas) === 0) { + return el; + } + datas = ZenCode.match(regDatas); + if (datas === null) { + return el; + } + i = 0; + while (i < datas.length) { + split = regData.exec(datas[i]); + if (split[3] === undefined) { + $(el).data(split[1], data[split[1]]); + } else { + $(el).data(split[1], data[split[3]]); + } + i++; + } + return el; + }; + bindEvents = function(ZenCode, el, functions) { + var bindings, fn, i, split; + if (ZenCode.search(regEvents) === 0) { + return el; + } + bindings = ZenCode.match(regEvents); + if (bindings === null) { + return el; + } + i = 0; + while (i < bindings.length) { + split = regEvent.exec(bindings[i]); + if (split[2] === undefined) { + fn = functions[split[1]]; + } else { + fn = functions[split[2]]; + } + $(el).bind(split[1], fn); + i++; + } + return el; + }; + parseAttributes = function(ZenBlock, data) { + var attrStrs, attrs, i, parts; + if (ZenBlock.search(regAttrDfn) === -1) { + return undefined; + } + attrStrs = ZenBlock.match(regAttrDfn); + attrs = {}; + i = 0; + while (i < attrStrs.length) { + parts = regAttr.exec(attrStrs[i]); + attrs[parts[1]] = ""; + if (parts[3] !== undefined) { + attrs[parts[1]] = parseContents(parts[3], data); + } + i++; + } + return attrs; + }; + parseClasses = function($, ZenBlock) { + var classes, clsString, i; + ZenBlock = ZenBlock.match(regTagNotContent)[0]; + if (ZenBlock.search(regClasses) === -1) { + return undefined; + } + classes = ZenBlock.match(regClasses); + clsString = ""; + i = 0; + while (i < classes.length) { + clsString += " " + regClass.exec(classes[i])[1]; + i++; + } + return $.trim(clsString); + }; + parseContents = function(ZenBlock, data, indexes) { + var html; + if (indexes === undefined) { + indexes = {}; + } + html = ZenBlock; + if (data === undefined) { + return html; + } + while (regExclamation.test(html)) { + html = html.replace(regExclamation, function(str, str2) { + var begChar, fn, val; + begChar = ""; + if (str.indexOf("!for:") > 0 || str.indexOf("!if:") > 0) { + return str; + } + if (str.charAt(0) !== "!") { + begChar = str.charAt(0); + str = str.substring(2, str.length - 1); + } + fn = new Function("data", "indexes", "var r=undefined;" + "with(data){try{r=" + str + ";}catch(e){}}" + "with(indexes){try{if(r===undefined)r=" + str + ";}catch(e){}}" + "return r;"); + val = unescape(fn(data, indexes)); + return begChar + val; + }); + } + html = html.replace(/\\./g, function(str) { + return str.charAt(1); + }); + return unescape(html); + }; + parseEnclosure = function(ZenCode, open, close, count) { + var index, ret; + if (close === undefined) { + close = open; + } + index = 1; + if (count === undefined) { + count = (ZenCode.charAt(0) === open ? 1 : 0); + } + if (count === 0) { + return; + } + while (count > 0 && index < ZenCode.length) { + if (ZenCode.charAt(index) === close && ZenCode.charAt(index - 1) !== "\\") { + count--; + } else { + if (ZenCode.charAt(index) === open && ZenCode.charAt(index - 1) !== "\\") { + count++; + } + } + index++; + } + ret = ZenCode.substring(0, index); + return ret; + }; + parseReferences = function(ZenCode, ZenObject) { + ZenCode = ZenCode.replace(regReference, function(str) { + var fn; + str = str.substr(1); + fn = new Function("objs", "var r=\"\";" + "with(objs){try{" + "r=" + str + ";" + "}catch(e){}}" + "return r;"); + return fn(ZenObject, parseReferences); + }); + return ZenCode; + }; + parseVariableScope = function(ZenCode) { + var forCode, rest, tag; + if (ZenCode.substring(0, 5) !== "!for:" && ZenCode.substring(0, 4) !== "!if:") { + return undefined; + } + forCode = parseEnclosure(ZenCode, "!"); + ZenCode = ZenCode.substr(forCode.length); + if (ZenCode.charAt(0) === "(") { + return parseEnclosure(ZenCode, "(", ")"); + } + tag = ZenCode.match(regZenTagDfn)[0]; + ZenCode = ZenCode.substr(tag.length); + if (ZenCode.length === 0 || ZenCode.charAt(0) === "+") { + return tag; + } else if (ZenCode.charAt(0) === ">") { + rest = ""; + rest = parseEnclosure(ZenCode.substr(1), "(", ")", 1); + return tag + ">" + rest; + } + return undefined; + }; + regZenTagDfn = /([#\.\@]?[\w-]+|\[([\w-!?=:"']+(="([^"]|\\")+")? {0,})+\]|\~[\w$]+=[\w$]+|&[\w$]+(=[\w$]+)?|[#\.\@]?!([^!]|\\!)+!){0,}(\{([^\}]|\\\})+\})?/i; + regTag = /(\w+)/i; + regId = /(?:^|\b)#([\w-!]+)/i; + regTagNotContent = /((([#\.]?[\w-]+)?(\[([\w!]+(="([^"]|\\")+")? {0,})+\])?)+)/i; + /* + See lookahead syntax (?!) at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp + */ + + regClasses = /(\.[\w-]+)(?!["\w])/g; + regClass = /\.([\w-]+)/i; + regReference = /(@[\w$_][\w$_\d]+)/i; + regAttrDfn = /(\[([\w-!]+(="?([^"]|\\")+"?)? {0,})+\])/ig; + regAttrs = /([\w-!]+(="([^"]|\\")+")?)/g; + regAttr = /([\w-!]+)(="?((([\w]+(\[.*?\])+)|[^"\]]|\\")+)"?)?/i; + regCBrace = /\{(([^\}]|\\\})+)\}/i; + regExclamation = /(?:([^\\]|^))!([^!]|\\!)+!/g; + regEvents = /\~[\w$]+(=[\w$]+)?/g; + regEvent = /\~([\w$]+)=([\w$]+)/i; + regDatas = /&[\w$]+(=[\w$]+)?/g; + regData = /&([\w$]+)(=([\w$]+))?/i; + return createHTMLBlock; + })(); + +}).call(this); diff --git a/frontend/spec/helpers/jasmine-given.js b/frontend/spec/helpers/jasmine-given.js new file mode 100644 index 0000000..a1c911e --- /dev/null +++ b/frontend/spec/helpers/jasmine-given.js @@ -0,0 +1,373 @@ +/* jasmine-given - 2.6.3 + * Adds a Given-When-Then DSL to jasmine as an alternative style for specs + * https://github.com/searls/jasmine-given + */ +/* jasmine-matcher-wrapper - 0.0.3 + * Wraps Jasmine 1.x matchers for use with Jasmine 2 + * https://github.com/testdouble/jasmine-matcher-wrapper + */ +(function() { + var __hasProp = {}.hasOwnProperty, + __slice = [].slice; + + (function(jasmine) { + var comparatorFor, createMatcher; + if (jasmine == null) { + return typeof console !== "undefined" && console !== null ? console.warn("jasmine was not found. Skipping jasmine-matcher-wrapper. Verify your script load order.") : void 0; + } + if (jasmine.matcherWrapper != null) { + return; + } + jasmine.matcherWrapper = { + wrap: function(matchers) { + var matcher, name, wrappedMatchers; + if (jasmine.addMatchers == null) { + return matchers; + } + wrappedMatchers = {}; + for (name in matchers) { + if (!__hasProp.call(matchers, name)) continue; + matcher = matchers[name]; + wrappedMatchers[name] = createMatcher(name, matcher); + } + return wrappedMatchers; + } + }; + createMatcher = function(name, matcher) { + return function() { + return { + compare: comparatorFor(matcher, false), + negativeCompare: comparatorFor(matcher, true) + }; + }; + }; + return comparatorFor = function(matcher, isNot) { + return function() { + var actual, context, message, params, pass, _ref; + actual = arguments[0], params = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + context = { + actual: actual, + isNot: isNot + }; + pass = matcher.apply(context, params); + if (isNot) { + pass = !pass; + } + if (!pass) { + message = (_ref = context.message) != null ? _ref.apply(context, params) : void 0; + } + return { + pass: pass, + message: message + }; + }; + }; + })(jasmine || getJasmineRequireObj()); + +}).call(this); + +(function() { + var __slice = [].slice; + + (function(jasmine) { + var Waterfall, additionalInsightsForErrorMessage, apparentReferenceError, attemptedEquality, cloneArray, comparisonInsight, currentSpec, declareJasmineSpec, deepEqualsNotice, doneWrapperFor, errorWithRemovedLines, evalInContextOfSpec, finalStatementFrom, getBlock, invariantList, mostRecentExpectations, mostRecentStacks, mostRecentlyUsed, o, root, stringifyExpectation, wasComparison, whenList, wrapAsExpectations; + mostRecentlyUsed = null; + root = (1, eval)('this'); + currentSpec = null; + beforeEach(function() { + return currentSpec = this; + }); + root.Given = function() { + mostRecentlyUsed = root.Given; + return beforeEach(getBlock(arguments)); + }; + whenList = []; + root.When = function() { + var b; + mostRecentlyUsed = root.When; + b = getBlock(arguments); + beforeEach(function() { + return whenList.push(b); + }); + return afterEach(function() { + return whenList.pop(); + }); + }; + invariantList = []; + root.Invariant = function() { + var invariantBehavior; + mostRecentlyUsed = root.Invariant; + invariantBehavior = getBlock(arguments); + beforeEach(function() { + return invariantList.push(invariantBehavior); + }); + return afterEach(function() { + return invariantList.pop(); + }); + }; + getBlock = function(thing) { + var assignResultTo, setupFunction; + setupFunction = o(thing).firstThat(function(arg) { + return o(arg).isFunction(); + }); + assignResultTo = o(thing).firstThat(function(arg) { + return o(arg).isString(); + }); + return doneWrapperFor(setupFunction, function(done) { + var context, result; + context = currentSpec; + result = setupFunction.call(context, done); + if (assignResultTo) { + if (!context[assignResultTo]) { + return context[assignResultTo] = result; + } else { + throw new Error("Unfortunately, the variable '" + assignResultTo + "' is already assigned to: " + context[assignResultTo]); + } + } + }); + }; + mostRecentExpectations = null; + mostRecentStacks = null; + declareJasmineSpec = function(specArgs, itFunction) { + var expectationFunction, expectations, label, stacks; + if (itFunction == null) { + itFunction = it; + } + label = o(specArgs).firstThat(function(arg) { + return o(arg).isString(); + }); + expectationFunction = o(specArgs).firstThat(function(arg) { + return o(arg).isFunction(); + }); + mostRecentlyUsed = root.subsequentThen; + mostRecentExpectations = expectations = [expectationFunction]; + mostRecentStacks = stacks = [errorWithRemovedLines("failed expectation", 3)]; + itFunction("then " + (label != null ? label : stringifyExpectation(expectations)), doneWrapperFor(expectationFunction, function(jasmineDone) { + var userCommands; + userCommands = [].concat(whenList, invariantList, wrapAsExpectations(expectations, stacks)); + return new Waterfall(userCommands, jasmineDone).flow(); + })); + return { + Then: subsequentThen, + And: subsequentThen + }; + }; + wrapAsExpectations = function(expectations, stacks) { + var expectation, i, _i, _len, _results; + _results = []; + for (i = _i = 0, _len = expectations.length; _i < _len; i = ++_i) { + expectation = expectations[i]; + _results.push((function(expectation, i) { + return doneWrapperFor(expectation, function(maybeDone) { + return expect(expectation).not.toHaveReturnedFalseFromThen(currentSpec, i + 1, stacks[i], maybeDone); + }); + })(expectation, i)); + } + return _results; + }; + doneWrapperFor = function(func, toWrap) { + if (func.length === 0) { + return function() { + return toWrap(); + }; + } else { + return function(done) { + return toWrap(done); + }; + } + }; + root.Then = function() { + return declareJasmineSpec(arguments); + }; + root.Then.only = function() { + return declareJasmineSpec(arguments, it.only); + }; + root.subsequentThen = function(additionalExpectation) { + mostRecentExpectations.push(additionalExpectation); + mostRecentStacks.push(errorWithRemovedLines("failed expectation", 3)); + return this; + }; + errorWithRemovedLines = function(msg, n) { + var error, lines, stack, _ref; + if (stack = new Error(msg).stack) { + _ref = stack.split("\n"), error = _ref[0], lines = 2 <= _ref.length ? __slice.call(_ref, 1) : []; + return "" + error + "\n" + (lines.slice(n).join("\n")); + } + }; + mostRecentlyUsed = root.Given; + root.And = function() { + return mostRecentlyUsed.apply(this, jasmine.util.argsToArray(arguments)); + }; + o = function(thing) { + return { + isFunction: function() { + return Object.prototype.toString.call(thing) === "[object Function]"; + }, + isString: function() { + return Object.prototype.toString.call(thing) === "[object String]"; + }, + firstThat: function(test) { + var i; + i = 0; + while (i < thing.length) { + if (test(thing[i]) === true) { + return thing[i]; + } + i++; + } + return void 0; + } + }; + }; + Waterfall = (function() { + function Waterfall(functions, finalCallback) { + if (functions == null) { + functions = []; + } + this.finalCallback = finalCallback != null ? finalCallback : function() {}; + this.functions = cloneArray(functions); + } + + Waterfall.prototype.flow = function() { + var func, + _this = this; + if (this.functions.length === 0) { + return this.finalCallback(); + } + func = this.functions.shift(); + if (func.length > 0) { + return func(function() { + return _this.flow(); + }); + } else { + func(); + return this.flow(); + } + }; + + return Waterfall; + + })(); + cloneArray = function(a) { + return a.slice(0); + }; + jasmine._given = { + matchers: { + toHaveReturnedFalseFromThen: function(context, n, stackTrace, done) { + var e, exception, result; + result = false; + exception = void 0; + try { + result = this.actual.call(context, done); + } catch (_error) { + e = _error; + exception = e; + } + this.message = function() { + var msg, stringyExpectation; + stringyExpectation = stringifyExpectation(this.actual); + msg = "Then clause" + (n > 1 ? " #" + n : "") + " `" + stringyExpectation + "` failed by "; + if (exception) { + msg += "throwing: " + exception.toString(); + } else { + msg += "returning false"; + } + msg += additionalInsightsForErrorMessage(stringyExpectation); + if (stackTrace != null) { + msg += "\n\n" + stackTrace; + } + return msg; + }; + return result === false; + } + }, + __Waterfall__: Waterfall + }; + stringifyExpectation = function(expectation) { + var matches; + matches = expectation.toString().replace(/\n/g, '').match(/function\s?\(.*\)\s?{\s*(return\s+)?(.*?)(;)?\s*}/i); + if (matches && matches.length >= 3) { + return matches[2].replace(/\s+/g, ' '); + } else { + return ""; + } + }; + additionalInsightsForErrorMessage = function(expectationString) { + var comparison, expectation; + expectation = finalStatementFrom(expectationString); + if (comparison = wasComparison(expectation)) { + return comparisonInsight(expectation, comparison); + } else { + return ""; + } + }; + finalStatementFrom = function(expectationString) { + var multiStatement; + if (multiStatement = expectationString.match(/.*return (.*)/)) { + return multiStatement[multiStatement.length - 1]; + } else { + return expectationString; + } + }; + wasComparison = function(expectation) { + var comparator, comparison, left, right, s; + if (comparison = expectation.match(/(.*) (===|!==|==|!=|>|>=|<|<=) (.*)/)) { + s = comparison[0], left = comparison[1], comparator = comparison[2], right = comparison[3]; + return { + left: left, + comparator: comparator, + right: right + }; + } + }; + comparisonInsight = function(expectation, comparison) { + var left, msg, right; + left = evalInContextOfSpec(comparison.left); + right = evalInContextOfSpec(comparison.right); + if (apparentReferenceError(left) && apparentReferenceError(right)) { + return ""; + } + msg = "\n\nThis comparison was detected:\n " + expectation + "\n " + left + " " + comparison.comparator + " " + right; + if (attemptedEquality(left, right, comparison.comparator)) { + msg += "\n\n" + (deepEqualsNotice(comparison.left, comparison.right)); + } + return msg; + }; + apparentReferenceError = function(result) { + return /^"; + } + }; + attemptedEquality = function(left, right, comparator) { + var _ref; + if (!(comparator === "==" || comparator === "===")) { + return false; + } + if (((_ref = jasmine.matchersUtil) != null ? _ref.equals : void 0) != null) { + return jasmine.matchersUtil.equals(left, right); + } else { + return jasmine.getEnv().equals_(left, right); + } + }; + deepEqualsNotice = function(left, right) { + return "However, these items are deeply equal! Try an expectation like this instead:\n expect(" + left + ").toEqual(" + right + ")"; + }; + return beforeEach(function() { + if (jasmine.addMatchers != null) { + return jasmine.addMatchers(jasmine.matcherWrapper.wrap(jasmine._given.matchers)); + } else { + return this.addMatchers(jasmine._given.matchers); + } + }); + })(jasmine); + +}).call(this); diff --git a/frontend/spec/helpers/jasmine-only.js b/frontend/spec/helpers/jasmine-only.js new file mode 100644 index 0000000..c60fb0b --- /dev/null +++ b/frontend/spec/helpers/jasmine-only.js @@ -0,0 +1,98 @@ +/* jasmine-only - 0.1.1 + * Exclusivity spec helpers for jasmine: `describe.only` and `it.only` + * https://github.com/davemo/jasmine-only + */ +(function() { + var __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + + (function(jasmine) { + var describeOnly, env, itOnly, root; + root = (1, eval)('this'); + env = jasmine.getEnv(); + describeOnly = function(description, specDefinitions) { + var suite; + suite = new jasmine.Suite(this, description, null, this.currentSuite); + suite.exclusive_ = 1; + this.exclusive_ = Math.max(this.exclusive_, 1); + return this.describe_(suite, specDefinitions); + }; + itOnly = function(description, func) { + var spec; + spec = this.it(description, func); + spec.exclusive_ = 2; + this.exclusive_ = 2; + return spec; + }; + env.exclusive_ = 0; + env.describe = function(description, specDefinitions) { + var suite; + suite = new jasmine.Suite(this, description, null, this.currentSuite); + return this.describe_(suite, specDefinitions); + }; + env.describe_ = function(suite, specDefinitions) { + var declarationError, e, parentSuite; + parentSuite = this.currentSuite; + if (parentSuite) { + parentSuite.add(suite); + } else { + this.currentRunner_.add(suite); + } + this.currentSuite = suite; + declarationError = null; + try { + specDefinitions.call(suite); + } catch (_error) { + e = _error; + declarationError = e; + } + if (declarationError) { + this.it("encountered a declaration exception", function() { + throw declarationError; + }); + } + this.currentSuite = parentSuite; + return suite; + }; + env.specFilter = function(spec) { + return this.exclusive_ <= spec.exclusive_; + }; + env.describe.only = function() { + return describeOnly.apply(env, arguments); + }; + env.it.only = function() { + return itOnly.apply(env, arguments); + }; + root.describe.only = function(description, specDefinitions) { + return env.describe.only(description, specDefinitions); + }; + root.it.only = function(description, func) { + return env.it.only(description, func); + }; + root.iit = root.it.only; + root.ddescribe = root.describe.only; + jasmine.Spec = (function(_super) { + __extends(Spec, _super); + + function Spec(env, suite, description) { + this.exclusive_ = suite.exclusive_; + Spec.__super__.constructor.call(this, env, suite, description); + } + + return Spec; + + })(jasmine.Spec); + return jasmine.Suite = (function(_super) { + __extends(Suite, _super); + + function Suite(env, suite, specDefinitions, parentSuite) { + this.exclusive_ = parentSuite && parentSuite.exclusive_ || 0; + Suite.__super__.constructor.call(this, env, suite, specDefinitions, parentSuite); + } + + return Suite; + + })(jasmine.Suite); + })(jasmine); + +}).call(this); diff --git a/frontend/spec/helpers/jasmine-stealth.js b/frontend/spec/helpers/jasmine-stealth.js new file mode 100644 index 0000000..774afc6 --- /dev/null +++ b/frontend/spec/helpers/jasmine-stealth.js @@ -0,0 +1,214 @@ +/* jasmine-stealth - 0.0.17 + * Makes Jasmine spies a bit more robust + * https://github.com/searls/jasmine-stealth + */ +(function() { + var __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + + (function() { + var Captor, fake, root, stubChainer, unfakes, whatToDoWhenTheSpyGetsCalled, _; + root = (1, eval)('this'); + _ = function(obj) { + return { + each: function(iterator) { + var item, _i, _len, _results; + _results = []; + for (_i = 0, _len = obj.length; _i < _len; _i++) { + item = obj[_i]; + _results.push(iterator(item)); + } + return _results; + }, + isFunction: function() { + return Object.prototype.toString.call(obj) === "[object Function]"; + }, + isString: function() { + return Object.prototype.toString.call(obj) === "[object String]"; + } + }; + }; + root.spyOnConstructor = function(owner, classToFake, methodsToSpy) { + var fakeClass, spies; + if (methodsToSpy == null) { + methodsToSpy = []; + } + if (_(methodsToSpy).isString()) { + methodsToSpy = [methodsToSpy]; + } + spies = { + constructor: jasmine.createSpy("" + classToFake + "'s constructor") + }; + fakeClass = (function() { + function _Class() { + spies.constructor.apply(this, arguments); + } + + return _Class; + + })(); + _(methodsToSpy).each(function(methodName) { + spies[methodName] = jasmine.createSpy("" + classToFake + "#" + methodName); + return fakeClass.prototype[methodName] = function() { + return spies[methodName].apply(this, arguments); + }; + }); + fake(owner, classToFake, fakeClass); + return spies; + }; + unfakes = []; + afterEach(function() { + _(unfakes).each(function(u) { + return u(); + }); + return unfakes = []; + }); + fake = function(owner, thingToFake, newThing) { + var originalThing; + originalThing = owner[thingToFake]; + owner[thingToFake] = newThing; + return unfakes.push(function() { + return owner[thingToFake] = originalThing; + }); + }; + root.stubFor = root.spyOn; + jasmine.createStub = jasmine.createSpy; + jasmine.createStubObj = function(baseName, stubbings) { + var name, obj, stubbing; + if (stubbings.constructor === Array) { + return jasmine.createSpyObj(baseName, stubbings); + } else { + obj = {}; + for (name in stubbings) { + stubbing = stubbings[name]; + obj[name] = jasmine.createSpy(baseName + "." + name); + if (_(stubbing).isFunction()) { + obj[name].andCallFake(stubbing); + } else { + obj[name].andReturn(stubbing); + } + } + return obj; + } + }; + whatToDoWhenTheSpyGetsCalled = function(spy) { + var matchesStub, priorPlan; + matchesStub = function(stubbing, args, context) { + switch (stubbing.type) { + case "args": + return jasmine.getEnv().equals_(stubbing.ifThis, jasmine.util.argsToArray(args)); + case "context": + return jasmine.getEnv().equals_(stubbing.ifThis, context); + } + }; + priorPlan = spy.plan; + return spy.andCallFake(function() { + var i, stubbing; + i = 0; + while (i < spy._stealth_stubbings.length) { + stubbing = spy._stealth_stubbings[i]; + if (matchesStub(stubbing, arguments, this)) { + if (stubbing.satisfaction === "callFake") { + return stubbing.thenThat.apply(stubbing, arguments); + } else { + return stubbing.thenThat; + } + } + i++; + } + return priorPlan.apply(spy, arguments); + }); + }; + jasmine.Spy.prototype.whenContext = function(context) { + var spy; + spy = this; + spy._stealth_stubbings || (spy._stealth_stubbings = []); + whatToDoWhenTheSpyGetsCalled(spy); + return stubChainer(spy, "context", context); + }; + jasmine.Spy.prototype.when = function() { + var ifThis, spy; + spy = this; + ifThis = jasmine.util.argsToArray(arguments); + spy._stealth_stubbings || (spy._stealth_stubbings = []); + whatToDoWhenTheSpyGetsCalled(spy); + return stubChainer(spy, "args", ifThis); + }; + stubChainer = function(spy, type, ifThis) { + var addStubbing; + addStubbing = function(satisfaction) { + return function(thenThat) { + spy._stealth_stubbings.unshift({ + type: type, + ifThis: ifThis, + satisfaction: satisfaction, + thenThat: thenThat + }); + return spy; + }; + }; + return { + thenReturn: addStubbing("return"), + thenCallFake: addStubbing("callFake") + }; + }; + jasmine.Spy.prototype.mostRecentCallThat = function(callThat, context) { + var i; + i = this.calls.length - 1; + while (i >= 0) { + if (callThat.call(context || this, this.calls[i]) === true) { + return this.calls[i]; + } + i--; + } + }; + jasmine.Matchers.ArgThat = (function(_super) { + __extends(ArgThat, _super); + + function ArgThat(matcher) { + this.matcher = matcher; + } + + ArgThat.prototype.jasmineMatches = function(actual) { + return this.matcher(actual); + }; + + return ArgThat; + + })(jasmine.Matchers.Any); + jasmine.Matchers.ArgThat.prototype.matches = jasmine.Matchers.ArgThat.prototype.jasmineMatches; + jasmine.argThat = function(expected) { + return new jasmine.Matchers.ArgThat(expected); + }; + jasmine.Matchers.Capture = (function(_super) { + __extends(Capture, _super); + + function Capture(captor) { + this.captor = captor; + } + + Capture.prototype.jasmineMatches = function(actual) { + this.captor.value = actual; + return true; + }; + + return Capture; + + })(jasmine.Matchers.Any); + jasmine.Matchers.Capture.prototype.matches = jasmine.Matchers.Capture.prototype.jasmineMatches; + Captor = (function() { + function Captor() {} + + Captor.prototype.capture = function() { + return new jasmine.Matchers.Capture(this); + }; + + return Captor; + + })(); + return jasmine.captor = function() { + return new Captor(); + }; + })(); + +}).call(this); diff --git a/frontend/tasks/.keep b/frontend/tasks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/frontend/vendor/css/.keep b/frontend/vendor/css/.keep new file mode 100644 index 0000000..e69de29 diff --git a/frontend/vendor/img/.keep b/frontend/vendor/img/.keep new file mode 100644 index 0000000..e69de29 diff --git a/frontend/vendor/js/underscore.js b/frontend/vendor/js/underscore.js new file mode 100644 index 0000000..9a4cabe --- /dev/null +++ b/frontend/vendor/js/underscore.js @@ -0,0 +1,1343 @@ +// Underscore.js 1.6.0 +// http://underscorejs.org +// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. + +(function() { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `exports` on the server. + var root = this; + + // Save the previous value of the `_` variable. + var previousUnderscore = root._; + + // Establish the object that gets returned to break out of a loop iteration. + var breaker = {}; + + // Save bytes in the minified (but not gzipped) version: + var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; + + // Create quick reference variables for speed access to core prototypes. + var + push = ArrayProto.push, + slice = ArrayProto.slice, + concat = ArrayProto.concat, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty; + + // All **ECMAScript 5** native function implementations that we hope to use + // are declared here. + var + nativeForEach = ArrayProto.forEach, + nativeMap = ArrayProto.map, + nativeReduce = ArrayProto.reduce, + nativeReduceRight = ArrayProto.reduceRight, + nativeFilter = ArrayProto.filter, + nativeEvery = ArrayProto.every, + nativeSome = ArrayProto.some, + nativeIndexOf = ArrayProto.indexOf, + nativeLastIndexOf = ArrayProto.lastIndexOf, + nativeIsArray = Array.isArray, + nativeKeys = Object.keys, + nativeBind = FuncProto.bind; + + // Create a safe reference to the Underscore object for use below. + var _ = function(obj) { + if (obj instanceof _) return obj; + if (!(this instanceof _)) return new _(obj); + this._wrapped = obj; + }; + + // Export the Underscore object for **Node.js**, with + // backwards-compatibility for the old `require()` API. If we're in + // the browser, add `_` as a global object via a string identifier, + // for Closure Compiler "advanced" mode. + if (typeof exports !== 'undefined') { + if (typeof module !== 'undefined' && module.exports) { + exports = module.exports = _; + } + exports._ = _; + } else { + root._ = _; + } + + // Current version. + _.VERSION = '1.6.0'; + + // Collection Functions + // -------------------- + + // The cornerstone, an `each` implementation, aka `forEach`. + // Handles objects with the built-in `forEach`, arrays, and raw objects. + // Delegates to **ECMAScript 5**'s native `forEach` if available. + var each = _.each = _.forEach = function(obj, iterator, context) { + if (obj == null) return obj; + if (nativeForEach && obj.forEach === nativeForEach) { + obj.forEach(iterator, context); + } else if (obj.length === +obj.length) { + for (var i = 0, length = obj.length; i < length; i++) { + if (iterator.call(context, obj[i], i, obj) === breaker) return; + } + } else { + var keys = _.keys(obj); + for (var i = 0, length = keys.length; i < length; i++) { + if (iterator.call(context, obj[keys[i]], keys[i], obj) === breaker) return; + } + } + return obj; + }; + + // Return the results of applying the iterator to each element. + // Delegates to **ECMAScript 5**'s native `map` if available. + _.map = _.collect = function(obj, iterator, context) { + var results = []; + if (obj == null) return results; + if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); + each(obj, function(value, index, list) { + results.push(iterator.call(context, value, index, list)); + }); + return results; + }; + + var reduceError = 'Reduce of empty array with no initial value'; + + // **Reduce** builds up a single result from a list of values, aka `inject`, + // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. + _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { + var initial = arguments.length > 2; + if (obj == null) obj = []; + if (nativeReduce && obj.reduce === nativeReduce) { + if (context) iterator = _.bind(iterator, context); + return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); + } + each(obj, function(value, index, list) { + if (!initial) { + memo = value; + initial = true; + } else { + memo = iterator.call(context, memo, value, index, list); + } + }); + if (!initial) throw new TypeError(reduceError); + return memo; + }; + + // The right-associative version of reduce, also known as `foldr`. + // Delegates to **ECMAScript 5**'s native `reduceRight` if available. + _.reduceRight = _.foldr = function(obj, iterator, memo, context) { + var initial = arguments.length > 2; + if (obj == null) obj = []; + if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { + if (context) iterator = _.bind(iterator, context); + return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); + } + var length = obj.length; + if (length !== +length) { + var keys = _.keys(obj); + length = keys.length; + } + each(obj, function(value, index, list) { + index = keys ? keys[--length] : --length; + if (!initial) { + memo = obj[index]; + initial = true; + } else { + memo = iterator.call(context, memo, obj[index], index, list); + } + }); + if (!initial) throw new TypeError(reduceError); + return memo; + }; + + // Return the first value which passes a truth test. Aliased as `detect`. + _.find = _.detect = function(obj, predicate, context) { + var result; + any(obj, function(value, index, list) { + if (predicate.call(context, value, index, list)) { + result = value; + return true; + } + }); + return result; + }; + + // Return all the elements that pass a truth test. + // Delegates to **ECMAScript 5**'s native `filter` if available. + // Aliased as `select`. + _.filter = _.select = function(obj, predicate, context) { + var results = []; + if (obj == null) return results; + if (nativeFilter && obj.filter === nativeFilter) return obj.filter(predicate, context); + each(obj, function(value, index, list) { + if (predicate.call(context, value, index, list)) results.push(value); + }); + return results; + }; + + // Return all the elements for which a truth test fails. + _.reject = function(obj, predicate, context) { + return _.filter(obj, function(value, index, list) { + return !predicate.call(context, value, index, list); + }, context); + }; + + // Determine whether all of the elements match a truth test. + // Delegates to **ECMAScript 5**'s native `every` if available. + // Aliased as `all`. + _.every = _.all = function(obj, predicate, context) { + predicate || (predicate = _.identity); + var result = true; + if (obj == null) return result; + if (nativeEvery && obj.every === nativeEvery) return obj.every(predicate, context); + each(obj, function(value, index, list) { + if (!(result = result && predicate.call(context, value, index, list))) return breaker; + }); + return !!result; + }; + + // Determine if at least one element in the object matches a truth test. + // Delegates to **ECMAScript 5**'s native `some` if available. + // Aliased as `any`. + var any = _.some = _.any = function(obj, predicate, context) { + predicate || (predicate = _.identity); + var result = false; + if (obj == null) return result; + if (nativeSome && obj.some === nativeSome) return obj.some(predicate, context); + each(obj, function(value, index, list) { + if (result || (result = predicate.call(context, value, index, list))) return breaker; + }); + return !!result; + }; + + // Determine if the array or object contains a given value (using `===`). + // Aliased as `include`. + _.contains = _.include = function(obj, target) { + if (obj == null) return false; + if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; + return any(obj, function(value) { + return value === target; + }); + }; + + // Invoke a method (with arguments) on every item in a collection. + _.invoke = function(obj, method) { + var args = slice.call(arguments, 2); + var isFunc = _.isFunction(method); + return _.map(obj, function(value) { + return (isFunc ? method : value[method]).apply(value, args); + }); + }; + + // Convenience version of a common use case of `map`: fetching a property. + _.pluck = function(obj, key) { + return _.map(obj, _.property(key)); + }; + + // Convenience version of a common use case of `filter`: selecting only objects + // containing specific `key:value` pairs. + _.where = function(obj, attrs) { + return _.filter(obj, _.matches(attrs)); + }; + + // Convenience version of a common use case of `find`: getting the first object + // containing specific `key:value` pairs. + _.findWhere = function(obj, attrs) { + return _.find(obj, _.matches(attrs)); + }; + + // Return the maximum element or (element-based computation). + // Can't optimize arrays of integers longer than 65,535 elements. + // See [WebKit Bug 80797](https://bugs.webkit.org/show_bug.cgi?id=80797) + _.max = function(obj, iterator, context) { + if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { + return Math.max.apply(Math, obj); + } + var result = -Infinity, lastComputed = -Infinity; + each(obj, function(value, index, list) { + var computed = iterator ? iterator.call(context, value, index, list) : value; + if (computed > lastComputed) { + result = value; + lastComputed = computed; + } + }); + return result; + }; + + // Return the minimum element (or element-based computation). + _.min = function(obj, iterator, context) { + if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { + return Math.min.apply(Math, obj); + } + var result = Infinity, lastComputed = Infinity; + each(obj, function(value, index, list) { + var computed = iterator ? iterator.call(context, value, index, list) : value; + if (computed < lastComputed) { + result = value; + lastComputed = computed; + } + }); + return result; + }; + + // Shuffle an array, using the modern version of the + // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). + _.shuffle = function(obj) { + var rand; + var index = 0; + var shuffled = []; + each(obj, function(value) { + rand = _.random(index++); + shuffled[index - 1] = shuffled[rand]; + shuffled[rand] = value; + }); + return shuffled; + }; + + // Sample **n** random values from a collection. + // If **n** is not specified, returns a single random element. + // The internal `guard` argument allows it to work with `map`. + _.sample = function(obj, n, guard) { + if (n == null || guard) { + if (obj.length !== +obj.length) obj = _.values(obj); + return obj[_.random(obj.length - 1)]; + } + return _.shuffle(obj).slice(0, Math.max(0, n)); + }; + + // An internal function to generate lookup iterators. + var lookupIterator = function(value) { + if (value == null) return _.identity; + if (_.isFunction(value)) return value; + return _.property(value); + }; + + // Sort the object's values by a criterion produced by an iterator. + _.sortBy = function(obj, iterator, context) { + iterator = lookupIterator(iterator); + return _.pluck(_.map(obj, function(value, index, list) { + return { + value: value, + index: index, + criteria: iterator.call(context, value, index, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index - right.index; + }), 'value'); + }; + + // An internal function used for aggregate "group by" operations. + var group = function(behavior) { + return function(obj, iterator, context) { + var result = {}; + iterator = lookupIterator(iterator); + each(obj, function(value, index) { + var key = iterator.call(context, value, index, obj); + behavior(result, key, value); + }); + return result; + }; + }; + + // Groups the object's values by a criterion. Pass either a string attribute + // to group by, or a function that returns the criterion. + _.groupBy = group(function(result, key, value) { + _.has(result, key) ? result[key].push(value) : result[key] = [value]; + }); + + // Indexes the object's values by a criterion, similar to `groupBy`, but for + // when you know that your index values will be unique. + _.indexBy = group(function(result, key, value) { + result[key] = value; + }); + + // Counts instances of an object that group by a certain criterion. Pass + // either a string attribute to count by, or a function that returns the + // criterion. + _.countBy = group(function(result, key) { + _.has(result, key) ? result[key]++ : result[key] = 1; + }); + + // Use a comparator function to figure out the smallest index at which + // an object should be inserted so as to maintain order. Uses binary search. + _.sortedIndex = function(array, obj, iterator, context) { + iterator = lookupIterator(iterator); + var value = iterator.call(context, obj); + var low = 0, high = array.length; + while (low < high) { + var mid = (low + high) >>> 1; + iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; + } + return low; + }; + + // Safely create a real, live array from anything iterable. + _.toArray = function(obj) { + if (!obj) return []; + if (_.isArray(obj)) return slice.call(obj); + if (obj.length === +obj.length) return _.map(obj, _.identity); + return _.values(obj); + }; + + // Return the number of elements in an object. + _.size = function(obj) { + if (obj == null) return 0; + return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; + }; + + // Array Functions + // --------------- + + // Get the first element of an array. Passing **n** will return the first N + // values in the array. Aliased as `head` and `take`. The **guard** check + // allows it to work with `_.map`. + _.first = _.head = _.take = function(array, n, guard) { + if (array == null) return void 0; + if ((n == null) || guard) return array[0]; + if (n < 0) return []; + return slice.call(array, 0, n); + }; + + // Returns everything but the last entry of the array. Especially useful on + // the arguments object. Passing **n** will return all the values in + // the array, excluding the last N. The **guard** check allows it to work with + // `_.map`. + _.initial = function(array, n, guard) { + return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); + }; + + // Get the last element of an array. Passing **n** will return the last N + // values in the array. The **guard** check allows it to work with `_.map`. + _.last = function(array, n, guard) { + if (array == null) return void 0; + if ((n == null) || guard) return array[array.length - 1]; + return slice.call(array, Math.max(array.length - n, 0)); + }; + + // Returns everything but the first entry of the array. Aliased as `tail` and `drop`. + // Especially useful on the arguments object. Passing an **n** will return + // the rest N values in the array. The **guard** + // check allows it to work with `_.map`. + _.rest = _.tail = _.drop = function(array, n, guard) { + return slice.call(array, (n == null) || guard ? 1 : n); + }; + + // Trim out all falsy values from an array. + _.compact = function(array) { + return _.filter(array, _.identity); + }; + + // Internal implementation of a recursive `flatten` function. + var flatten = function(input, shallow, output) { + if (shallow && _.every(input, _.isArray)) { + return concat.apply(output, input); + } + each(input, function(value) { + if (_.isArray(value) || _.isArguments(value)) { + shallow ? push.apply(output, value) : flatten(value, shallow, output); + } else { + output.push(value); + } + }); + return output; + }; + + // Flatten out an array, either recursively (by default), or just one level. + _.flatten = function(array, shallow) { + return flatten(array, shallow, []); + }; + + // Return a version of the array that does not contain the specified value(s). + _.without = function(array) { + return _.difference(array, slice.call(arguments, 1)); + }; + + // Split an array into two arrays: one whose elements all satisfy the given + // predicate, and one whose elements all do not satisfy the predicate. + _.partition = function(array, predicate) { + var pass = [], fail = []; + each(array, function(elem) { + (predicate(elem) ? pass : fail).push(elem); + }); + return [pass, fail]; + }; + + // Produce a duplicate-free version of the array. If the array has already + // been sorted, you have the option of using a faster algorithm. + // Aliased as `unique`. + _.uniq = _.unique = function(array, isSorted, iterator, context) { + if (_.isFunction(isSorted)) { + context = iterator; + iterator = isSorted; + isSorted = false; + } + var initial = iterator ? _.map(array, iterator, context) : array; + var results = []; + var seen = []; + each(initial, function(value, index) { + if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { + seen.push(value); + results.push(array[index]); + } + }); + return results; + }; + + // Produce an array that contains the union: each distinct element from all of + // the passed-in arrays. + _.union = function() { + return _.uniq(_.flatten(arguments, true)); + }; + + // Produce an array that contains every item shared between all the + // passed-in arrays. + _.intersection = function(array) { + var rest = slice.call(arguments, 1); + return _.filter(_.uniq(array), function(item) { + return _.every(rest, function(other) { + return _.contains(other, item); + }); + }); + }; + + // Take the difference between one array and a number of other arrays. + // Only the elements present in just the first array will remain. + _.difference = function(array) { + var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); + return _.filter(array, function(value){ return !_.contains(rest, value); }); + }; + + // Zip together multiple lists into a single array -- elements that share + // an index go together. + _.zip = function() { + var length = _.max(_.pluck(arguments, 'length').concat(0)); + var results = new Array(length); + for (var i = 0; i < length; i++) { + results[i] = _.pluck(arguments, '' + i); + } + return results; + }; + + // Converts lists into objects. Pass either a single array of `[key, value]` + // pairs, or two parallel arrays of the same length -- one of keys, and one of + // the corresponding values. + _.object = function(list, values) { + if (list == null) return {}; + var result = {}; + for (var i = 0, length = list.length; i < length; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } + } + return result; + }; + + // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), + // we need this function. Return the position of the first occurrence of an + // item in an array, or -1 if the item is not included in the array. + // Delegates to **ECMAScript 5**'s native `indexOf` if available. + // If the array is large and already in sort order, pass `true` + // for **isSorted** to use binary search. + _.indexOf = function(array, item, isSorted) { + if (array == null) return -1; + var i = 0, length = array.length; + if (isSorted) { + if (typeof isSorted == 'number') { + i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted); + } else { + i = _.sortedIndex(array, item); + return array[i] === item ? i : -1; + } + } + if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); + for (; i < length; i++) if (array[i] === item) return i; + return -1; + }; + + // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. + _.lastIndexOf = function(array, item, from) { + if (array == null) return -1; + var hasIndex = from != null; + if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { + return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); + } + var i = (hasIndex ? from : array.length); + while (i--) if (array[i] === item) return i; + return -1; + }; + + // Generate an integer Array containing an arithmetic progression. A port of + // the native Python `range()` function. See + // [the Python documentation](http://docs.python.org/library/functions.html#range). + _.range = function(start, stop, step) { + if (arguments.length <= 1) { + stop = start || 0; + start = 0; + } + step = arguments[2] || 1; + + var length = Math.max(Math.ceil((stop - start) / step), 0); + var idx = 0; + var range = new Array(length); + + while(idx < length) { + range[idx++] = start; + start += step; + } + + return range; + }; + + // Function (ahem) Functions + // ------------------ + + // Reusable constructor function for prototype setting. + var ctor = function(){}; + + // Create a function bound to a given object (assigning `this`, and arguments, + // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if + // available. + _.bind = function(func, context) { + var args, bound; + if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); + if (!_.isFunction(func)) throw new TypeError; + args = slice.call(arguments, 2); + return bound = function() { + if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); + ctor.prototype = func.prototype; + var self = new ctor; + ctor.prototype = null; + var result = func.apply(self, args.concat(slice.call(arguments))); + if (Object(result) === result) return result; + return self; + }; + }; + + // Partially apply a function by creating a version that has had some of its + // arguments pre-filled, without changing its dynamic `this` context. _ acts + // as a placeholder, allowing any combination of arguments to be pre-filled. + _.partial = function(func) { + var boundArgs = slice.call(arguments, 1); + return function() { + var position = 0; + var args = boundArgs.slice(); + for (var i = 0, length = args.length; i < length; i++) { + if (args[i] === _) args[i] = arguments[position++]; + } + while (position < arguments.length) args.push(arguments[position++]); + return func.apply(this, args); + }; + }; + + // Bind a number of an object's methods to that object. Remaining arguments + // are the method names to be bound. Useful for ensuring that all callbacks + // defined on an object belong to it. + _.bindAll = function(obj) { + var funcs = slice.call(arguments, 1); + if (funcs.length === 0) throw new Error('bindAll must be passed function names'); + each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); + return obj; + }; + + // Memoize an expensive function by storing its results. + _.memoize = function(func, hasher) { + var memo = {}; + hasher || (hasher = _.identity); + return function() { + var key = hasher.apply(this, arguments); + return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); + }; + }; + + // Delays a function for the given number of milliseconds, and then calls + // it with the arguments supplied. + _.delay = function(func, wait) { + var args = slice.call(arguments, 2); + return setTimeout(function(){ return func.apply(null, args); }, wait); + }; + + // Defers a function, scheduling it to run after the current call stack has + // cleared. + _.defer = function(func) { + return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); + }; + + // Returns a function, that, when invoked, will only be triggered at most once + // during a given window of time. Normally, the throttled function will run + // as much as it can, without ever going more than once per `wait` duration; + // but if you'd like to disable the execution on the leading edge, pass + // `{leading: false}`. To disable execution on the trailing edge, ditto. + _.throttle = function(func, wait, options) { + var context, args, result; + var timeout = null; + var previous = 0; + options || (options = {}); + var later = function() { + previous = options.leading === false ? 0 : _.now(); + timeout = null; + result = func.apply(context, args); + context = args = null; + }; + return function() { + var now = _.now(); + if (!previous && options.leading === false) previous = now; + var remaining = wait - (now - previous); + context = this; + args = arguments; + if (remaining <= 0) { + clearTimeout(timeout); + timeout = null; + previous = now; + result = func.apply(context, args); + context = args = null; + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + }; + + // Returns a function, that, as long as it continues to be invoked, will not + // be triggered. The function will be called after it stops being called for + // N milliseconds. If `immediate` is passed, trigger the function on the + // leading edge, instead of the trailing. + _.debounce = function(func, wait, immediate) { + var timeout, args, context, timestamp, result; + + var later = function() { + var last = _.now() - timestamp; + if (last < wait) { + timeout = setTimeout(later, wait - last); + } else { + timeout = null; + if (!immediate) { + result = func.apply(context, args); + context = args = null; + } + } + }; + + return function() { + context = this; + args = arguments; + timestamp = _.now(); + var callNow = immediate && !timeout; + if (!timeout) { + timeout = setTimeout(later, wait); + } + if (callNow) { + result = func.apply(context, args); + context = args = null; + } + + return result; + }; + }; + + // Returns a function that will be executed at most one time, no matter how + // often you call it. Useful for lazy initialization. + _.once = function(func) { + var ran = false, memo; + return function() { + if (ran) return memo; + ran = true; + memo = func.apply(this, arguments); + func = null; + return memo; + }; + }; + + // Returns the first function passed as an argument to the second, + // allowing you to adjust arguments, run code before and after, and + // conditionally execute the original function. + _.wrap = function(func, wrapper) { + return _.partial(wrapper, func); + }; + + // Returns a function that is the composition of a list of functions, each + // consuming the return value of the function that follows. + _.compose = function() { + var funcs = arguments; + return function() { + var args = arguments; + for (var i = funcs.length - 1; i >= 0; i--) { + args = [funcs[i].apply(this, args)]; + } + return args[0]; + }; + }; + + // Returns a function that will only be executed after being called N times. + _.after = function(times, func) { + return function() { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + }; + + // Object Functions + // ---------------- + + // Retrieve the names of an object's properties. + // Delegates to **ECMAScript 5**'s native `Object.keys` + _.keys = function(obj) { + if (!_.isObject(obj)) return []; + if (nativeKeys) return nativeKeys(obj); + var keys = []; + for (var key in obj) if (_.has(obj, key)) keys.push(key); + return keys; + }; + + // Retrieve the values of an object's properties. + _.values = function(obj) { + var keys = _.keys(obj); + var length = keys.length; + var values = new Array(length); + for (var i = 0; i < length; i++) { + values[i] = obj[keys[i]]; + } + return values; + }; + + // Convert an object into a list of `[key, value]` pairs. + _.pairs = function(obj) { + var keys = _.keys(obj); + var length = keys.length; + var pairs = new Array(length); + for (var i = 0; i < length; i++) { + pairs[i] = [keys[i], obj[keys[i]]]; + } + return pairs; + }; + + // Invert the keys and values of an object. The values must be serializable. + _.invert = function(obj) { + var result = {}; + var keys = _.keys(obj); + for (var i = 0, length = keys.length; i < length; i++) { + result[obj[keys[i]]] = keys[i]; + } + return result; + }; + + // Return a sorted list of the function names available on the object. + // Aliased as `methods` + _.functions = _.methods = function(obj) { + var names = []; + for (var key in obj) { + if (_.isFunction(obj[key])) names.push(key); + } + return names.sort(); + }; + + // Extend a given object with all the properties in passed-in object(s). + _.extend = function(obj) { + each(slice.call(arguments, 1), function(source) { + if (source) { + for (var prop in source) { + obj[prop] = source[prop]; + } + } + }); + return obj; + }; + + // Return a copy of the object only containing the whitelisted properties. + _.pick = function(obj) { + var copy = {}; + var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); + each(keys, function(key) { + if (key in obj) copy[key] = obj[key]; + }); + return copy; + }; + + // Return a copy of the object without the blacklisted properties. + _.omit = function(obj) { + var copy = {}; + var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); + for (var key in obj) { + if (!_.contains(keys, key)) copy[key] = obj[key]; + } + return copy; + }; + + // Fill in a given object with default properties. + _.defaults = function(obj) { + each(slice.call(arguments, 1), function(source) { + if (source) { + for (var prop in source) { + if (obj[prop] === void 0) obj[prop] = source[prop]; + } + } + }); + return obj; + }; + + // Create a (shallow-cloned) duplicate of an object. + _.clone = function(obj) { + if (!_.isObject(obj)) return obj; + return _.isArray(obj) ? obj.slice() : _.extend({}, obj); + }; + + // Invokes interceptor with the obj, and then returns obj. + // The primary purpose of this method is to "tap into" a method chain, in + // order to perform operations on intermediate results within the chain. + _.tap = function(obj, interceptor) { + interceptor(obj); + return obj; + }; + + // Internal recursive comparison function for `isEqual`. + var eq = function(a, b, aStack, bStack) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) return a !== 0 || 1 / a == 1 / b; + // A strict comparison is necessary because `null == undefined`. + if (a == null || b == null) return a === b; + // Unwrap any wrapped objects. + if (a instanceof _) a = a._wrapped; + if (b instanceof _) b = b._wrapped; + // Compare `[[Class]]` names. + var className = toString.call(a); + if (className != toString.call(b)) return false; + switch (className) { + // Strings, numbers, dates, and booleans are compared by value. + case '[object String]': + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is + // equivalent to `new String("5")`. + return a == String(b); + case '[object Number]': + // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for + // other numeric values. + return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); + case '[object Date]': + case '[object Boolean]': + // Coerce dates and booleans to numeric primitive values. Dates are compared by their + // millisecond representations. Note that invalid dates with millisecond representations + // of `NaN` are not equivalent. + return +a == +b; + // RegExps are compared by their source patterns and flags. + case '[object RegExp]': + return a.source == b.source && + a.global == b.global && + a.multiline == b.multiline && + a.ignoreCase == b.ignoreCase; + } + if (typeof a != 'object' || typeof b != 'object') return false; + // Assume equality for cyclic structures. The algorithm for detecting cyclic + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. + var length = aStack.length; + while (length--) { + // Linear search. Performance is inversely proportional to the number of + // unique nested structures. + if (aStack[length] == a) return bStack[length] == b; + } + // Objects with different constructors are not equivalent, but `Object`s + // from different frames are. + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && + _.isFunction(bCtor) && (bCtor instanceof bCtor)) + && ('constructor' in a && 'constructor' in b)) { + return false; + } + // Add the first object to the stack of traversed objects. + aStack.push(a); + bStack.push(b); + var size = 0, result = true; + // Recursively compare objects and arrays. + if (className == '[object Array]') { + // Compare array lengths to determine if a deep comparison is necessary. + size = a.length; + result = size == b.length; + if (result) { + // Deep compare the contents, ignoring non-numeric properties. + while (size--) { + if (!(result = eq(a[size], b[size], aStack, bStack))) break; + } + } + } else { + // Deep compare objects. + for (var key in a) { + if (_.has(a, key)) { + // Count the expected number of properties. + size++; + // Deep compare each member. + if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; + } + } + // Ensure that both objects contain the same number of properties. + if (result) { + for (key in b) { + if (_.has(b, key) && !(size--)) break; + } + result = !size; + } + } + // Remove the first object from the stack of traversed objects. + aStack.pop(); + bStack.pop(); + return result; + }; + + // Perform a deep comparison to check if two objects are equal. + _.isEqual = function(a, b) { + return eq(a, b, [], []); + }; + + // Is a given array, string, or object empty? + // An "empty" object has no enumerable own-properties. + _.isEmpty = function(obj) { + if (obj == null) return true; + if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; + for (var key in obj) if (_.has(obj, key)) return false; + return true; + }; + + // Is a given value a DOM element? + _.isElement = function(obj) { + return !!(obj && obj.nodeType === 1); + }; + + // Is a given value an array? + // Delegates to ECMA5's native Array.isArray + _.isArray = nativeIsArray || function(obj) { + return toString.call(obj) == '[object Array]'; + }; + + // Is a given variable an object? + _.isObject = function(obj) { + return obj === Object(obj); + }; + + // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp. + each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { + _['is' + name] = function(obj) { + return toString.call(obj) == '[object ' + name + ']'; + }; + }); + + // Define a fallback version of the method in browsers (ahem, IE), where + // there isn't any inspectable "Arguments" type. + if (!_.isArguments(arguments)) { + _.isArguments = function(obj) { + return !!(obj && _.has(obj, 'callee')); + }; + } + + // Optimize `isFunction` if appropriate. + if (typeof (/./) !== 'function') { + _.isFunction = function(obj) { + return typeof obj === 'function'; + }; + } + + // Is a given object a finite number? + _.isFinite = function(obj) { + return isFinite(obj) && !isNaN(parseFloat(obj)); + }; + + // Is the given value `NaN`? (NaN is the only number which does not equal itself). + _.isNaN = function(obj) { + return _.isNumber(obj) && obj != +obj; + }; + + // Is a given value a boolean? + _.isBoolean = function(obj) { + return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; + }; + + // Is a given value equal to null? + _.isNull = function(obj) { + return obj === null; + }; + + // Is a given variable undefined? + _.isUndefined = function(obj) { + return obj === void 0; + }; + + // Shortcut function for checking if an object has a given property directly + // on itself (in other words, not on a prototype). + _.has = function(obj, key) { + return hasOwnProperty.call(obj, key); + }; + + // Utility Functions + // ----------------- + + // Run Underscore.js in *noConflict* mode, returning the `_` variable to its + // previous owner. Returns a reference to the Underscore object. + _.noConflict = function() { + root._ = previousUnderscore; + return this; + }; + + // Keep the identity function around for default iterators. + _.identity = function(value) { + return value; + }; + + _.constant = function(value) { + return function () { + return value; + }; + }; + + _.property = function(key) { + return function(obj) { + return obj[key]; + }; + }; + + // Returns a predicate for checking whether an object has a given set of `key:value` pairs. + _.matches = function(attrs) { + return function(obj) { + if (obj === attrs) return true; //avoid comparing an object to itself. + for (var key in attrs) { + if (attrs[key] !== obj[key]) + return false; + } + return true; + } + }; + + // Run a function **n** times. + _.times = function(n, iterator, context) { + var accum = Array(Math.max(0, n)); + for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); + return accum; + }; + + // Return a random integer between min and max (inclusive). + _.random = function(min, max) { + if (max == null) { + max = min; + min = 0; + } + return min + Math.floor(Math.random() * (max - min + 1)); + }; + + // A (possibly faster) way to get the current timestamp as an integer. + _.now = Date.now || function() { return new Date().getTime(); }; + + // List of HTML entities for escaping. + var entityMap = { + escape: { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + } + }; + entityMap.unescape = _.invert(entityMap.escape); + + // Regexes containing the keys and values listed immediately above. + var entityRegexes = { + escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), + unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') + }; + + // Functions for escaping and unescaping strings to/from HTML interpolation. + _.each(['escape', 'unescape'], function(method) { + _[method] = function(string) { + if (string == null) return ''; + return ('' + string).replace(entityRegexes[method], function(match) { + return entityMap[method][match]; + }); + }; + }); + + // If the value of the named `property` is a function then invoke it with the + // `object` as context; otherwise, return it. + _.result = function(object, property) { + if (object == null) return void 0; + var value = object[property]; + return _.isFunction(value) ? value.call(object) : value; + }; + + // Add your own custom functions to the Underscore object. + _.mixin = function(obj) { + each(_.functions(obj), function(name) { + var func = _[name] = obj[name]; + _.prototype[name] = function() { + var args = [this._wrapped]; + push.apply(args, arguments); + return result.call(this, func.apply(_, args)); + }; + }); + }; + + // Generate a unique integer id (unique within the entire client session). + // Useful for temporary DOM ids. + var idCounter = 0; + _.uniqueId = function(prefix) { + var id = ++idCounter + ''; + return prefix ? prefix + id : id; + }; + + // By default, Underscore uses ERB-style template delimiters, change the + // following template settings to use alternative delimiters. + _.templateSettings = { + evaluate : /<%([\s\S]+?)%>/g, + interpolate : /<%=([\s\S]+?)%>/g, + escape : /<%-([\s\S]+?)%>/g + }; + + // When customizing `templateSettings`, if you don't want to define an + // interpolation, evaluation or escaping regex, we need one that is + // guaranteed not to match. + var noMatch = /(.)^/; + + // Certain characters need to be escaped so that they can be put into a + // string literal. + var escapes = { + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', + '\t': 't', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; + + // JavaScript micro-templating, similar to John Resig's implementation. + // Underscore templating handles arbitrary delimiters, preserves whitespace, + // and correctly escapes quotes within interpolated code. + _.template = function(text, data, settings) { + var render; + settings = _.defaults({}, settings, _.templateSettings); + + // Combine delimiters into one regular expression via alternation. + var matcher = new RegExp([ + (settings.escape || noMatch).source, + (settings.interpolate || noMatch).source, + (settings.evaluate || noMatch).source + ].join('|') + '|$', 'g'); + + // Compile the template source, escaping string literals appropriately. + var index = 0; + var source = "__p+='"; + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset) + .replace(escaper, function(match) { return '\\' + escapes[match]; }); + + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } + if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } + if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + index = offset + match.length; + return match; + }); + source += "';\n"; + + // If a variable is not specified, place data values in local scope. + if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; + + source = "var __t,__p='',__j=Array.prototype.join," + + "print=function(){__p+=__j.call(arguments,'');};\n" + + source + "return __p;\n"; + + try { + render = new Function(settings.variable || 'obj', '_', source); + } catch (e) { + e.source = source; + throw e; + } + + if (data) return render(data, _); + var template = function(data) { + return render.call(this, data, _); + }; + + // Provide the compiled function source as a convenience for precompilation. + template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; + + return template; + }; + + // Add a "chain" function, which will delegate to the wrapper. + _.chain = function(obj) { + return _(obj).chain(); + }; + + // OOP + // --------------- + // If Underscore is called as a function, it returns a wrapped object that + // can be used OO-style. This wrapper holds altered versions of all the + // underscore functions. Wrapped objects may be chained. + + // Helper function to continue chaining intermediate results. + var result = function(obj) { + return this._chain ? _(obj).chain() : obj; + }; + + // Add all of the Underscore functions to the wrapper object. + _.mixin(_); + + // Add all mutator Array functions to the wrapper. + each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + method.apply(obj, arguments); + if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; + return result.call(this, obj); + }; + }); + + // Add all accessor Array functions to the wrapper. + each(['concat', 'join', 'slice'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + return result.call(this, method.apply(this._wrapped, arguments)); + }; + }); + + _.extend(_.prototype, { + + // Start chaining a wrapped Underscore object. + chain: function() { + this._chain = true; + return this; + }, + + // Extracts the result from a wrapped and chained object. + value: function() { + return this._wrapped; + } + + }); + + // AMD registration happens at the end for compatibility with AMD loaders + // that may not enforce next-turn semantics on modules. Even though general + // practice for AMD registration is to be anonymous, underscore registers + // as a named module because, like jQuery, it is a base library that is + // popular enough to be bundled in a third party lib, but not be part of + // an AMD load request. Those cases could generate an error when an + // anonymous define() is called outside of a loader request. + if (typeof define === 'function' && define.amd) { + define('underscore', [], function() { + return _; + }); + } +}).call(this); diff --git a/frontend/vendor/static/.keep b/frontend/vendor/static/.keep new file mode 100644 index 0000000..e69de29 From 2d3aa1b76018cc3eae8ceb02bb6c9018f0c1371e Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 10 Feb 2016 17:46:16 +0000 Subject: [PATCH 05/46] Set up api for development --- frontend/app/pages/index.us | 1 - frontend/config/application.js | 14 +++++++------- frontend/package.json | 3 +-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index 365a292..ee2bc1d 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -7,6 +7,5 @@ -

Test

diff --git a/frontend/config/application.js b/frontend/config/application.js index 43bbe4e..ef41e20 100644 --- a/frontend/config/application.js +++ b/frontend/config/application.js @@ -22,13 +22,13 @@ module.exports = function(lineman) { // requests for paths that don't match a static asset in ./generated will be forwarded to // whatever service might be running on the specified port. // - // server: { - // apiProxy: { - // enabled: true, - // host: 'localhost', - // port: 3000 - // } - // }, + server: { + apiProxy: { + enabled: true, + host: 'localhost', + port: 8080 + } + }, // Sass // diff --git a/frontend/package.json b/frontend/package.json index b58aa98..2d7f4c0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -5,8 +5,7 @@ "private": true, "author": "John Doe", "devDependencies": { - "lineman": "~0.36.6", - "lineman-rails": "^0.1.0" + "lineman": "~0.36.6" }, "scripts": { "start": "lineman run", From 8c08b5a47f411cd3d48e0f91ff22a975d91f0834 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Thu, 18 Feb 2016 07:49:49 -0500 Subject: [PATCH 06/46] Added memcahced to test deploy --- deploy/docker-compose-test.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/deploy/docker-compose-test.yml b/deploy/docker-compose-test.yml index 9a8919c..46bd2d5 100644 --- a/deploy/docker-compose-test.yml +++ b/deploy/docker-compose-test.yml @@ -10,10 +10,14 @@ app: - WRESTLINGDEV_DB_PORT=3306 - WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa - WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2 - + - MEMCACHIER_SERVERS=memcached:11211 + - MEMCACHIER_USERNAME= + - MEMCACHIER_PASSWORD= links: - db + - memcached restart: always + db: extends: file: docker-compose-common.yml @@ -21,6 +25,7 @@ db: environment: - MYSQL_ROOT_PASSWORD=password restart: always + worker: extends: file: docker-compose-common.yml @@ -33,7 +38,17 @@ worker: - WRESTLINGDEV_DB_PORT=3306 - WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa - WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2 - + - MEMCACHIER_SERVERS=memcached:11211 + - MEMCACHIER_USERNAME= + - MEMCACHIER_PASSWORD= links: - db + - memcached restart: always + +memcached: + extends: + file: docker-compose-common.yml + service: memcached + restart: always + From fae5b310a2dd3b48270be3c6b06e97339d8952bf Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 18 Feb 2016 12:51:00 +0000 Subject: [PATCH 07/46] Changed port lineman runs on --- frontend/config/application.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/config/application.js b/frontend/config/application.js index ef41e20..6a7ddf8 100644 --- a/frontend/config/application.js +++ b/frontend/config/application.js @@ -27,6 +27,9 @@ module.exports = function(lineman) { enabled: true, host: 'localhost', port: 8080 + }, + web: { + port: 8081 } }, From 33529cb9fe9d1208a39a2708049416ee178cb48f Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 18 Feb 2016 12:51:22 +0000 Subject: [PATCH 08/46] Added description and author --- frontend/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 2d7f4c0..f70fe33 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,9 +1,9 @@ { "name": "frontend", - "description": "An HTML/JS/CSS app", + "description": "Frontend for wrestlingdev", "version": "0.0.1", "private": true, - "author": "John Doe", + "author": "Jacob Cody Wimer", "devDependencies": { "lineman": "~0.36.6" }, From 3504c54ed4312dc5f7ab30b661c703c146366b0a Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Thu, 18 Feb 2016 08:24:24 -0500 Subject: [PATCH 09/46] Added a script to run tests --- run-all-tests.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 run-all-tests.sh diff --git a/run-all-tests.sh b/run-all-tests.sh new file mode 100755 index 0000000..80e44f5 --- /dev/null +++ b/run-all-tests.sh @@ -0,0 +1,6 @@ +#!/bin/bash -e + +docker build -t wrestlingdev-dev -f rails-dev-Dockerfile . + +docker run -it -v $(pwd):/rails wrestlingdev-dev bash rails-dev-db.sh +docker run -it -v $(pwd):/rails wrestlingdev-dev rake test From 4a90165514fbbc8543cdcdd29c16363ddc3ff1b8 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 18 Feb 2016 15:13:33 +0000 Subject: [PATCH 10/46] Added bootstrap and angularjs --- frontend/app/js/app.js | 30 ++++++++++++++++++++++++++ frontend/app/js/hello.js | 14 ------------ frontend/app/pages/index.us | 43 +++++++++++++++++++++++++++++-------- 3 files changed, 64 insertions(+), 23 deletions(-) create mode 100644 frontend/app/js/app.js delete mode 100644 frontend/app/js/hello.js diff --git a/frontend/app/js/app.js b/frontend/app/js/app.js new file mode 100644 index 0000000..34d039c --- /dev/null +++ b/frontend/app/js/app.js @@ -0,0 +1,30 @@ +function ctrl($scope){ + $scope.rows = ['Paul','John','Lucie']; + $scope.temp = false; + + $scope.addRow = function(){ + $scope.temp = false; + $scope.addName=""; + }; + + $scope.deleteRow = function(row){ + $scope.rows.splice($scope.rows.indexOf(row),1); + }; + + $scope.plural = function (tab){ + return tab.length > 1 ? 's': ''; + }; + + $scope.addTemp = function(){ + if($scope.temp) $scope.rows.pop(); + else if($scope.addName) $scope.temp = true; + + if($scope.addName) $scope.rows.push($scope.addName); + else $scope.temp = false; + }; + + $scope.isTemp = function(i){ + return i==$scope.rows.length-1 && $scope.temp; + }; + +} \ No newline at end of file diff --git a/frontend/app/js/hello.js b/frontend/app/js/hello.js deleted file mode 100644 index 4a9d1e5..0000000 --- a/frontend/app/js/hello.js +++ /dev/null @@ -1,14 +0,0 @@ -window.helloText = function() { - return 'Hello, World!'; -}; - -window.hello = function() { - html = JST['app/templates/hello.us']({text: helloText()}); - document.body.innerHTML += html; -}; - -if(window.addEventListener) { - window.addEventListener('DOMContentLoaded', hello, false); -} else { - window.attachEvent('onload', hello); -} diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index ee2bc1d..fdd4042 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -1,11 +1,36 @@ - - - <%= pkg.name %> + + + + + + + +Angular JS Demo + + +

{{rows.length}} Friend{{plural(rows)}} ? (only {{rows.length-1}} actually....)

+
+ + + + - - - - - - + + + + + +
+ + + + + + +
{{$index+1}}{{row}} + +
+ + + \ No newline at end of file From 305d45960b6b7f0983b2a513ef7cb46f7a172456 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Thu, 18 Feb 2016 12:54:06 -0500 Subject: [PATCH 11/46] Changed tmux script to better suite needs --- tmux.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tmux.sh b/tmux.sh index c045a80..c51fc80 100755 --- a/tmux.sh +++ b/tmux.sh @@ -1,11 +1,13 @@ #!/bin/bash -CURRENT_SESSION=${PWD##*/} +CURRENT_SESSION=wrestlingdev tmux new-session -d -s $CURRENT_SESSION tmux send-keys 'vim' 'C-m' -tmux rename-window vim +tmux send-keys ':NERDTree' 'C-m' +tmux rename-window rails-vim tmux new-window -tmux rename-window docker +tmux rename-window rails +tmux send-keys 'bash rails-dev.sh wrestlingdev' 'C-m' tmux new-window -tmux rename-window git +tmux rename-window rails-git tmux select-window -t 0 tmux attach -t $CURRENT_SESSION From db2e9a1c65aef3a5b274322e6dfc9212fc64c9f5 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Tue, 23 Feb 2016 14:12:26 -0500 Subject: [PATCH 12/46] making navbar mobile friendly --- app/views/devise/sessions/new.html.erb | 14 +++++++------- app/views/layouts/_cdn.html.erb | 7 +++---- app/views/layouts/_header.html.erb | 24 ++++++++++++++++-------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 831957e..87df9d2 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,17 +1,17 @@ -

Sign in

+ <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> -
<%= f.label :email %>
- <%= f.email_field :email, :autofocus => true %>
+
<%= f.label :email ,:class=>"sr-only"%>
+ <%= f.email_field :email, :autofocus => true,:class=>"form-control",:placeholder=>"Email Address" %>
-
<%= f.label :password %>
- <%= f.password_field :password %>
+
<%= f.label :password,:class=>"sr-only" %>
+ <%= f.password_field :password,:class=>"form-control",:placeholder=>"Password" %>
<% if devise_mapping.rememberable? -%> -
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
+
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
<% end -%> -
<%= f.submit "Sign in" ,:class=>"btn btn-success"%>
+
<%= f.submit "Sign in" ,:class=>"btn btn-lg btn-primary btn-block" %>
<% end %>

diff --git a/app/views/layouts/_cdn.html.erb b/app/views/layouts/_cdn.html.erb index 18a559a..70538f0 100644 --- a/app/views/layouts/_cdn.html.erb +++ b/app/views/layouts/_cdn.html.erb @@ -1,11 +1,10 @@ - + - - + - + diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index e3d7f94..9ccd9f0 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -1,9 +1,16 @@ - From c03402bcdb0e7a4bb2f8e2c61e44518605d405bd Mon Sep 17 00:00:00 2001 From: jcwimer Date: Tue, 1 Mar 2016 16:15:19 +0000 Subject: [PATCH 13/46] Added a mock layout and an api call for angular --- app/views/api/tournaments.jbuilder | 2 +- frontend/app/js/app.js | 31 +------- frontend/app/js/homeController.js | 17 +++++ frontend/app/pages/index.us | 117 ++++++++++++++++++++--------- 4 files changed, 102 insertions(+), 65 deletions(-) create mode 100644 frontend/app/js/homeController.js diff --git a/app/views/api/tournaments.jbuilder b/app/views/api/tournaments.jbuilder index a0487e3..c9f6ee7 100644 --- a/app/views/api/tournaments.jbuilder +++ b/app/views/api/tournaments.jbuilder @@ -1,3 +1,3 @@ json.array!(@tournaments) do |tournament| - json.extract! tournament, :id, :name, :address, :director, :director_email + json.extract! tournament, :id, :name, :address, :director, :director_email, :date end \ No newline at end of file diff --git a/frontend/app/js/app.js b/frontend/app/js/app.js index 34d039c..899b26e 100644 --- a/frontend/app/js/app.js +++ b/frontend/app/js/app.js @@ -1,30 +1 @@ -function ctrl($scope){ - $scope.rows = ['Paul','John','Lucie']; - $scope.temp = false; - - $scope.addRow = function(){ - $scope.temp = false; - $scope.addName=""; - }; - - $scope.deleteRow = function(row){ - $scope.rows.splice($scope.rows.indexOf(row),1); - }; - - $scope.plural = function (tab){ - return tab.length > 1 ? 's': ''; - }; - - $scope.addTemp = function(){ - if($scope.temp) $scope.rows.pop(); - else if($scope.addName) $scope.temp = true; - - if($scope.addName) $scope.rows.push($scope.addName); - else $scope.temp = false; - }; - - $scope.isTemp = function(i){ - return i==$scope.rows.length-1 && $scope.temp; - }; - -} \ No newline at end of file +var app = angular.module("wrestlingdev", []); \ No newline at end of file diff --git a/frontend/app/js/homeController.js b/frontend/app/js/homeController.js new file mode 100644 index 0000000..4e261b4 --- /dev/null +++ b/frontend/app/js/homeController.js @@ -0,0 +1,17 @@ +app.controller("homeController", function($scope, $http) { + $scope.message = "Test message in scope."; + + + $http({ + method: 'GET', + url: '/api/tournaments/' + }).then(function successCallback(response) { + // this callback will be called asynchronously + // when the response is available + $scope.query = response.data; + }, function errorCallback(response) { + // called asynchronously if an error occurs + // or server returns response with an error status. + $scope.query = "Nothing there"; + }); +}); \ No newline at end of file diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index fdd4042..b380a2f 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -1,36 +1,85 @@ - - - - - - - -Angular JS Demo - - -

{{rows.length}} Friend{{plural(rows)}} ? (only {{rows.length-1}} actually....)

-
- - - - + + + WrestlingDev + + + + + + + +
+ + + +
+
+
+ +
+
+
+

All Tournaments

+
+ + + + + + + + + + + + + + + + + + + +
NameAddressDirectorDirector EmailDate
{{ tournament.name }}{{ tournament.address }}{{ tournament.director }}{{ tournament.director_email }}{{ tournament.date }}
+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + - - - - - -
- - - - - - -
{{$index+1}}{{row}} - -
- - - \ No newline at end of file From 459585fce2495e159e4f329da7e350047e80c360 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Tue, 1 Mar 2016 16:22:34 +0000 Subject: [PATCH 14/46] Fixed navbar with rails navbar changes --- frontend/app/pages/index.us | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index b380a2f..5d7d471 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -9,21 +9,26 @@ -
- - - +
From 817e1fb0c11ce8826c532f3ecf7c8d68be03a386 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 2 Mar 2016 13:34:41 +0000 Subject: [PATCH 15/46] Moved api call to a service --- app/controllers/api_controller.rb | 5 +++++ config/routes.rb | 1 + frontend/app/js/homeController.js | 17 ----------------- frontend/app/js/tournaments-controller.js | 10 ++++++++++ frontend/app/js/tournaments-service.js | 17 +++++++++++++++++ frontend/app/pages/index.us | 5 ++--- 6 files changed, 35 insertions(+), 20 deletions(-) delete mode 100644 frontend/app/js/homeController.js create mode 100644 frontend/app/js/tournaments-controller.js create mode 100644 frontend/app/js/tournaments-service.js diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 6e74089..50d6e89 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -12,4 +12,9 @@ class ApiController < ApplicationController def tournament @tournament = Tournament.where(:id => params[:tournament]).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first end + + def newTournament + @tournament = Tournament.new(JSON.parse(params[:tournament])) + @tournament.save + end end diff --git a/config/routes.rb b/config/routes.rb index a4008fb..30007fe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -56,6 +56,7 @@ Wrestling::Application.routes.draw do get "/api/tournaments" => "api#tournaments" get "/api/tournaments/:tournament" => "api#tournament" get "/api/index" => "api#index" + post "/api/tournaments/new" => "newTournament" # Example of regular route: # get 'products/:id' => 'catalog#view' diff --git a/frontend/app/js/homeController.js b/frontend/app/js/homeController.js deleted file mode 100644 index 4e261b4..0000000 --- a/frontend/app/js/homeController.js +++ /dev/null @@ -1,17 +0,0 @@ -app.controller("homeController", function($scope, $http) { - $scope.message = "Test message in scope."; - - - $http({ - method: 'GET', - url: '/api/tournaments/' - }).then(function successCallback(response) { - // this callback will be called asynchronously - // when the response is available - $scope.query = response.data; - }, function errorCallback(response) { - // called asynchronously if an error occurs - // or server returns response with an error status. - $scope.query = "Nothing there"; - }); -}); \ No newline at end of file diff --git a/frontend/app/js/tournaments-controller.js b/frontend/app/js/tournaments-controller.js new file mode 100644 index 0000000..bc79971 --- /dev/null +++ b/frontend/app/js/tournaments-controller.js @@ -0,0 +1,10 @@ +app.controller("tournamentsController", function($scope, tournamentsService) { + $scope.message = "Test message in scope."; + tournamentsService.getAllTournaments().then(function(data) { + //this will execute when the + //AJAX call completes. + console.log(data); + $scope.allTournaments = data; + }); + +}); \ No newline at end of file diff --git a/frontend/app/js/tournaments-service.js b/frontend/app/js/tournaments-service.js new file mode 100644 index 0000000..b301cf6 --- /dev/null +++ b/frontend/app/js/tournaments-service.js @@ -0,0 +1,17 @@ +app.factory('tournamentsService', function($http){ + + + return { + getAllTournaments: function() { + //since $http.get returns a promise, + //and promise.then() also returns a promise + //that resolves to whatever value is returned in it's + //callback argument, we can return that. + return $http.get('/api/tournaments/').then(function(result) { + return result.data; + }); + } + }; + +}); + diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index 5d7d471..3693a53 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -35,7 +35,7 @@
-
+

All Tournaments


@@ -49,7 +49,7 @@ - + @@ -65,7 +65,6 @@ - From 9bd36d2cb07c00b93c806b74dbaf79c5e0982a2a Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 2 Mar 2016 14:08:14 +0000 Subject: [PATCH 16/46] Added a search to both api and frontend --- app/controllers/api_controller.rb | 6 +++++- frontend/app/js/tournaments-controller.js | 13 ++++++++++++- frontend/app/js/tournaments-service.js | 20 +++++++++++++++++++- frontend/app/pages/index.us | 17 ++++++++++------- 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 50d6e89..679c84f 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -6,7 +6,11 @@ class ApiController < ApplicationController end def tournaments - @tournaments = Tournament.all + if params[:search] + @tournaments = Tournament.search(params[:search]).order("created_at DESC") + else + @tournaments = Tournament.all.sort_by{|t| t.daysUntil}.first(20) + end end def tournament diff --git a/frontend/app/js/tournaments-controller.js b/frontend/app/js/tournaments-controller.js index bc79971..92bf66f 100644 --- a/frontend/app/js/tournaments-controller.js +++ b/frontend/app/js/tournaments-controller.js @@ -1,10 +1,21 @@ app.controller("tournamentsController", function($scope, tournamentsService) { $scope.message = "Test message in scope."; + tournamentsService.getAllTournaments().then(function(data) { //this will execute when the //AJAX call completes. console.log(data); $scope.allTournaments = data; - }); + }); + + $scope.searchTournaments = function (){ + console.log("Tried search"); + tournamentsService.searchTournaments($scope.searchTerms).then(function(data) { + //this will execute when the + //AJAX call completes. + console.log(data); + $scope.allTournaments = data; + }); + } }); \ No newline at end of file diff --git a/frontend/app/js/tournaments-service.js b/frontend/app/js/tournaments-service.js index b301cf6..6f2e0e8 100644 --- a/frontend/app/js/tournaments-service.js +++ b/frontend/app/js/tournaments-service.js @@ -1,6 +1,6 @@ app.factory('tournamentsService', function($http){ - + return { getAllTournaments: function() { //since $http.get returns a promise, @@ -10,6 +10,24 @@ app.factory('tournamentsService', function($http){ return $http.get('/api/tournaments/').then(function(result) { return result.data; }); + }, + + searchTournaments: function(search){ + return $http({ + method: 'GET', + url: '/api/tournaments/', + params: { + search: search + } + }).then(function successCallback(response) { + // this callback will be called asynchronously + // when the response is available + return response.data + }, function errorCallback(response) { + // called asynchronously if an error occurs + // or server returns response with an error status. + return response; + }); } }; diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index 3693a53..23a13d6 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -36,24 +36,27 @@
-

All Tournaments

+

Upcoming Tournaments

+
+
+
+ + + + +
+
{{ tournament.name }} {{ tournament.address }} {{ tournament.director }}
- - - - - - From 85f9346001c5851ff46e96cf53ecd03129218677 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 2 Mar 2016 15:54:38 +0000 Subject: [PATCH 17/46] Removed console.log on frontend tournamentsController, also fixed frontend syntax errors in tournamentsController and tournamentsService --- frontend/app/js/tournaments-controller.js | 5 +---- frontend/app/js/tournaments-service.js | 2 +- frontend/app/static/favicon.ico | Bin 1150 -> 1406 bytes 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/frontend/app/js/tournaments-controller.js b/frontend/app/js/tournaments-controller.js index 92bf66f..1efcb89 100644 --- a/frontend/app/js/tournaments-controller.js +++ b/frontend/app/js/tournaments-controller.js @@ -4,18 +4,15 @@ app.controller("tournamentsController", function($scope, tournamentsService) { tournamentsService.getAllTournaments().then(function(data) { //this will execute when the //AJAX call completes. - console.log(data); $scope.allTournaments = data; }); $scope.searchTournaments = function (){ - console.log("Tried search"); tournamentsService.searchTournaments($scope.searchTerms).then(function(data) { //this will execute when the //AJAX call completes. - console.log(data); $scope.allTournaments = data; }); - } + }; }); \ No newline at end of file diff --git a/frontend/app/js/tournaments-service.js b/frontend/app/js/tournaments-service.js index 6f2e0e8..4e426bd 100644 --- a/frontend/app/js/tournaments-service.js +++ b/frontend/app/js/tournaments-service.js @@ -22,7 +22,7 @@ app.factory('tournamentsService', function($http){ }).then(function successCallback(response) { // this callback will be called asynchronously // when the response is available - return response.data + return response.data; }, function errorCallback(response) { // called asynchronously if an error occurs // or server returns response with an error status. diff --git a/frontend/app/static/favicon.ico b/frontend/app/static/favicon.ico index 70de606140dd3f4a4eb64e224e50675a20db8a33..bd63207474d4a6847e69d5ea3a8b494496140b93 100644 GIT binary patch literal 1406 zcmeH{%TH556vltIZz#~xLV5VYH$Fgxdt~KfY2r$ve}M~hW&Af>m|zLGK#jUm0*UU_ zO%3r;T^Pek6SOfAV`6V_YkILQ?RAE0wX$6#7ionVHmn>@cAnCsEBv@Vihch) z)!a)eAD@w*9#eN6r}p(7#lRVL)0rtH~ zYTs6vYhz#zuJz@P!dKp~(AL>x#lFaYI<1pk5Ruwg>lKj6>@HtRnS zK;^NS1D5ORXoso6puc_n3NivF4mZQq)wKg;E|MHrjjxY4Of8rOD}d_f Date: Thu, 3 Mar 2016 13:39:56 +0000 Subject: [PATCH 18/46] Set up frontend on docker images --- rails-dev-Dockerfile | 5 +++++ rails-prod-Dockerfile | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/rails-dev-Dockerfile b/rails-dev-Dockerfile index 564a628..e34c624 100644 --- a/rails-dev-Dockerfile +++ b/rails-dev-Dockerfile @@ -13,8 +13,13 @@ ADD Gemfile* /tmp/ WORKDIR /tmp RUN bundle install --without production +RUN npm install -g lineman +ADD frontend/package.json /tmp/ +RUN npm install + RUN mkdir /rails WORKDIR /rails +RUN cp -a /tmp/node_modules /rails/frontend/node_modules VOLUME ["/rails"] EXPOSE 3000 diff --git a/rails-prod-Dockerfile b/rails-prod-Dockerfile index 385ef79..7570a87 100644 --- a/rails-prod-Dockerfile +++ b/rails-prod-Dockerfile @@ -50,6 +50,10 @@ COPY Gemfile Gemfile COPY Gemfile.lock Gemfile.lock RUN bundle install --without test +#Cache node_modules +WORKDIR /tmp +COPY frontend/package.json package.json +RUN npm install # Copy site into place. RUN rm -rf /var/www @@ -74,7 +78,8 @@ RUN echo PassengerMaxPoolSize 3 >> /etc/apache2/apache2.conf RUN echo PassengerMinInstances 3 >> /etc/apache2/apache2.conf RUN echo PassengerPreStart *:443 >> /etc/apache2/apache2.conf - +#Copy node_modules to /var/www +RUN cp -a /tmp/node_modules /var/www/frontend/node_modules # By default, simply start apache. CMD /usr/sbin/apache2ctl -D FOREGROUND From 621813a015c2f94d9b9fdd7a74d66e6f064c1b6d Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 3 Mar 2016 13:55:27 +0000 Subject: [PATCH 19/46] Using a more lightweight image and using rvm for ruby --- rails-dev-Dockerfile | 14 ++++++++++++-- rails-prod-Dockerfile | 17 +++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/rails-dev-Dockerfile b/rails-dev-Dockerfile index e34c624..4075fc3 100644 --- a/rails-dev-Dockerfile +++ b/rails-dev-Dockerfile @@ -1,13 +1,23 @@ -FROM ruby:2.3.0 +FROM phusion/baseimage +ENV RUBYVERSION 2.3.0 RUN apt-get update RUN apt-get install -y build-essential -RUN apt-get install -y nodejs sqlite3 +RUN apt-get install -y nodejs sqlite3 curl ENV WRESTLINGDEV_SECRET_KEY_BASE 077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2 ENV WRESTLINGDEV_DEVISE_SECRET_KEY 2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa +#Install ruby +RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 +RUN \curl -sSL https://get.rvm.io | bash -s stable +RUN source /usr/local/rvm/scripts/rvm +RUN rvm install $RUBYVERSION +RUN rvm rvm --default use $RUBYVERSION +ENV PATH /usr/local/rvm/bin:$PATH + + RUN gem install --no-rdoc --no-ri bundler ADD Gemfile* /tmp/ WORKDIR /tmp diff --git a/rails-prod-Dockerfile b/rails-prod-Dockerfile index 7570a87..a0b4be6 100644 --- a/rails-prod-Dockerfile +++ b/rails-prod-Dockerfile @@ -1,17 +1,18 @@ -FROM ruby:2.3.0 - +FROM phusion/baseimage +ENV RUBYVERSION 2.3.0 RUN apt-get update RUN apt-get -y upgrade RUN DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential libssl-dev libyaml-dev libreadline-dev openssl curl git-core zlib1g-dev bison libxml2-dev libxslt1-dev libcurl4-openssl-dev libsqlite3-dev sqlite3 wget apache2 apt-transport-https nodejs mysql-client postfix -#New Relic -#RUN echo deb http://apt.newrelic.com/debian/ newrelic non-free >> /etc/apt/sources.list.d/newrelic.list -#RUN wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - -#RUN apt-get update -#RUN apt-get install newrelic-sysmond -y -#RUN nrsysmond-config --set license_key=$NEW_RELIC_LICENSE_KEY +#Install ruby +RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 +RUN \curl -sSL https://get.rvm.io | bash -s stable +RUN source /usr/local/rvm/scripts/rvm +RUN rvm install $RUBYVERSION +RUN rvm rvm --default use $RUBYVERSION +ENV PATH /usr/local/rvm/bin:$PATH #Passenger RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7 From c8a09956f442bfa83641b8df96b8136e68ef9811 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Thu, 3 Mar 2016 09:56:24 -0500 Subject: [PATCH 20/46] Revert "Using a more lightweight image and using rvm for ruby" This reverts commit 621813a015c2f94d9b9fdd7a74d66e6f064c1b6d. I could not get the lightweight docker image working correctly with rvm. I will most likely switch back to this image in the future when I have more time to work on it. --- rails-dev-Dockerfile | 14 ++------------ rails-prod-Dockerfile | 17 ++++++++--------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/rails-dev-Dockerfile b/rails-dev-Dockerfile index 4075fc3..e34c624 100644 --- a/rails-dev-Dockerfile +++ b/rails-dev-Dockerfile @@ -1,23 +1,13 @@ -FROM phusion/baseimage -ENV RUBYVERSION 2.3.0 +FROM ruby:2.3.0 RUN apt-get update RUN apt-get install -y build-essential -RUN apt-get install -y nodejs sqlite3 curl +RUN apt-get install -y nodejs sqlite3 ENV WRESTLINGDEV_SECRET_KEY_BASE 077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2 ENV WRESTLINGDEV_DEVISE_SECRET_KEY 2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa -#Install ruby -RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 -RUN \curl -sSL https://get.rvm.io | bash -s stable -RUN source /usr/local/rvm/scripts/rvm -RUN rvm install $RUBYVERSION -RUN rvm rvm --default use $RUBYVERSION -ENV PATH /usr/local/rvm/bin:$PATH - - RUN gem install --no-rdoc --no-ri bundler ADD Gemfile* /tmp/ WORKDIR /tmp diff --git a/rails-prod-Dockerfile b/rails-prod-Dockerfile index a0b4be6..7570a87 100644 --- a/rails-prod-Dockerfile +++ b/rails-prod-Dockerfile @@ -1,18 +1,17 @@ -FROM phusion/baseimage -ENV RUBYVERSION 2.3.0 +FROM ruby:2.3.0 + RUN apt-get update RUN apt-get -y upgrade RUN DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential libssl-dev libyaml-dev libreadline-dev openssl curl git-core zlib1g-dev bison libxml2-dev libxslt1-dev libcurl4-openssl-dev libsqlite3-dev sqlite3 wget apache2 apt-transport-https nodejs mysql-client postfix -#Install ruby -RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 -RUN \curl -sSL https://get.rvm.io | bash -s stable -RUN source /usr/local/rvm/scripts/rvm -RUN rvm install $RUBYVERSION -RUN rvm rvm --default use $RUBYVERSION -ENV PATH /usr/local/rvm/bin:$PATH +#New Relic +#RUN echo deb http://apt.newrelic.com/debian/ newrelic non-free >> /etc/apt/sources.list.d/newrelic.list +#RUN wget -O- https://download.newrelic.com/548C16BF.gpg | apt-key add - +#RUN apt-get update +#RUN apt-get install newrelic-sysmond -y +#RUN nrsysmond-config --set license_key=$NEW_RELIC_LICENSE_KEY #Passenger RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7 From 4ae5e66b66673d1f16a70e5a5facc9183d979b30 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Wed, 9 Mar 2016 09:09:18 -0500 Subject: [PATCH 21/46] Fixed dockerfiles for prod and dev with new frontend --- rails-dev-Dockerfile | 5 +---- rails-prod-Dockerfile | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/rails-dev-Dockerfile b/rails-dev-Dockerfile index e34c624..f442e13 100644 --- a/rails-dev-Dockerfile +++ b/rails-dev-Dockerfile @@ -3,7 +3,7 @@ FROM ruby:2.3.0 RUN apt-get update RUN apt-get install -y build-essential -RUN apt-get install -y nodejs sqlite3 +RUN apt-get install -y nodejs-legacy nodejs sqlite3 npm ENV WRESTLINGDEV_SECRET_KEY_BASE 077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2 ENV WRESTLINGDEV_DEVISE_SECRET_KEY 2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa @@ -14,12 +14,9 @@ WORKDIR /tmp RUN bundle install --without production RUN npm install -g lineman -ADD frontend/package.json /tmp/ -RUN npm install RUN mkdir /rails WORKDIR /rails -RUN cp -a /tmp/node_modules /rails/frontend/node_modules VOLUME ["/rails"] EXPOSE 3000 diff --git a/rails-prod-Dockerfile b/rails-prod-Dockerfile index 7570a87..db3326a 100644 --- a/rails-prod-Dockerfile +++ b/rails-prod-Dockerfile @@ -4,7 +4,7 @@ FROM ruby:2.3.0 RUN apt-get update RUN apt-get -y upgrade -RUN DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential libssl-dev libyaml-dev libreadline-dev openssl curl git-core zlib1g-dev bison libxml2-dev libxslt1-dev libcurl4-openssl-dev libsqlite3-dev sqlite3 wget apache2 apt-transport-https nodejs mysql-client postfix +RUN DEBIAN_FRONTEND=noninteractive apt-get -y install build-essential libssl-dev libyaml-dev libreadline-dev openssl curl git-core zlib1g-dev bison libxml2-dev libxslt1-dev libcurl4-openssl-dev libsqlite3-dev sqlite3 wget apache2 apt-transport-https nodejs nodejs-legacy npm mysql-client postfix #New Relic #RUN echo deb http://apt.newrelic.com/debian/ newrelic non-free >> /etc/apt/sources.list.d/newrelic.list @@ -54,6 +54,7 @@ RUN bundle install --without test WORKDIR /tmp COPY frontend/package.json package.json RUN npm install +RUN npm install -g lineman # Copy site into place. RUN rm -rf /var/www @@ -79,7 +80,7 @@ RUN echo PassengerMinInstances 3 >> /etc/apache2/apache2.conf RUN echo PassengerPreStart *:443 >> /etc/apache2/apache2.conf #Copy node_modules to /var/www -RUN cp -a /tmp/node_modules /var/www/frontend/node_modules +RUN mv /tmp/node_modules /var/www/frontend/node_modules # By default, simply start apache. CMD /usr/sbin/apache2ctl -D FOREGROUND From dc1c955485564e17a2540d52058290aa10742a6b Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 10 Mar 2016 12:46:03 +0000 Subject: [PATCH 22/46] Workers have a different command --- deploy/docker-compose-prod-full-stack.yml | 1 + frontend/app/js/auth-service.js | 49 +++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 frontend/app/js/auth-service.js diff --git a/deploy/docker-compose-prod-full-stack.yml b/deploy/docker-compose-prod-full-stack.yml index ed3e280..2bc49d9 100644 --- a/deploy/docker-compose-prod-full-stack.yml +++ b/deploy/docker-compose-prod-full-stack.yml @@ -23,3 +23,4 @@ worker: restart: always env_file: - ./prod.env + command: bundle exec rake jobs:work RAILS_ENV=production diff --git a/frontend/app/js/auth-service.js b/frontend/app/js/auth-service.js new file mode 100644 index 0000000..db0c7d9 --- /dev/null +++ b/frontend/app/js/auth-service.js @@ -0,0 +1,49 @@ +app.factory('AuthenticationService', + ['Base64', '$http', '$cookieStore', '$rootScope', '$timeout', + function (Base64, $http, $cookieStore, $rootScope, $timeout) { + var service = {}; + + service.Login = function (username, password, callback) { + + /* Dummy authentication for testing, uses $timeout to simulate api call + ----------------------------------------------*/ + // $timeout(function(){ + // var response = { success: username === 'test' && password === 'test' }; + // if(!response.success) { + // response.message = 'Username or password is incorrect'; + // } + // callback(response); + // }, 1000); + + + /* Use this for real authentication + ----------------------------------------------*/ + $http.post('/api/authenticate', { username: username, password: password }) + .success(function (response) { + callback(response); + }); + + }; + + service.SetCredentials = function (username, password) { + var authdata = Base64.encode(username + ':' + password); + + $rootScope.globals = { + currentUser: { + username: username, + authdata: authdata + } + }; + + $http.defaults.headers.common['Authorization'] = 'Basic ' + authdata; // jshint ignore:line + $cookieStore.put('globals', $rootScope.globals); + }; + + service.ClearCredentials = function () { + $rootScope.globals = {}; + $cookieStore.remove('globals'); + $http.defaults.headers.common.Authorization = 'Basic '; + }; + + return service; + }]); \ No newline at end of file From 97ec2971a5d9883301d6474c9a40a6a3a6fc63d7 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 10 Mar 2016 12:47:46 +0000 Subject: [PATCH 23/46] Added memcached to production docker compose, also added worker command for test compose --- deploy/docker-compose-prod-full-stack.yml | 6 ++++++ deploy/docker-compose-test.yml | 1 + 2 files changed, 7 insertions(+) diff --git a/deploy/docker-compose-prod-full-stack.yml b/deploy/docker-compose-prod-full-stack.yml index 2bc49d9..4bc765a 100644 --- a/deploy/docker-compose-prod-full-stack.yml +++ b/deploy/docker-compose-prod-full-stack.yml @@ -24,3 +24,9 @@ worker: env_file: - ./prod.env command: bundle exec rake jobs:work RAILS_ENV=production + +memcached: + extends: + file: docker-compose-common.yml + service: memcached + restart: always diff --git a/deploy/docker-compose-test.yml b/deploy/docker-compose-test.yml index 46bd2d5..294829e 100644 --- a/deploy/docker-compose-test.yml +++ b/deploy/docker-compose-test.yml @@ -45,6 +45,7 @@ worker: - db - memcached restart: always + command: bundle exec rake jobs:work RAILS_ENV=production memcached: extends: From 2c44bc9845f14bf127c5f069f6007fec995467f7 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Tue, 22 Mar 2016 11:29:32 +0000 Subject: [PATCH 24/46] Trying to get routes working but they are not working at the moment. Also moved the tournaments search and table to its own page --- frontend/app/js/app.js | 11 ++++++++- frontend/app/js/routes.js | 30 ++++++++++++++++++++++++ frontend/app/pages/index.us | 31 ++----------------------- frontend/app/templates/tournaments.html | 29 +++++++++++++++++++++++ frontend/config/application.js | 3 ++- 5 files changed, 73 insertions(+), 31 deletions(-) create mode 100644 frontend/app/js/routes.js create mode 100644 frontend/app/templates/tournaments.html diff --git a/frontend/app/js/app.js b/frontend/app/js/app.js index 899b26e..62abfd5 100644 --- a/frontend/app/js/app.js +++ b/frontend/app/js/app.js @@ -1 +1,10 @@ -var app = angular.module("wrestlingdev", []); \ No newline at end of file +var app = angular.module("wrestlingdev", ["ngRoute"]).run(function($rootScope) { + // adds some basic utilities to the $rootScope for debugging purposes + $rootScope.log = function(thing) { + console.log(thing); + }; + + $rootScope.alert = function(thing) { + alert(thing); + }; +}); \ No newline at end of file diff --git a/frontend/app/js/routes.js b/frontend/app/js/routes.js new file mode 100644 index 0000000..1b2f71b --- /dev/null +++ b/frontend/app/js/routes.js @@ -0,0 +1,30 @@ + + +// $routeProvider.when('/list-of-books', { +// templateUrl: 'angular/books.html', +// controller: 'BooksController' +// // uncomment if you want to see an example of a route that resolves a request prior to rendering +// // resolve: { +// // books : function(BookService) { +// // return BookService.get(); +// // } +// // } +// }); + + + +app.config(['$routeProvider', + function($routeProvider) { + $routeProvider. + when('/tournaments', { + templateUrl: 'tournaments.html', + controller: 'tournamentsController' + }). + // when('/phones/:phoneId', { + // templateUrl: 'partials/phone-detail.html', + // controller: 'PhoneDetailCtrl' + // }). + otherwise({ + redirectTo: '/tournaments' + }); + }]); \ No newline at end of file diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index 23a13d6..0e2a372 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -34,35 +34,8 @@
-
-
-

Upcoming Tournaments

-
-
-
- - - - -
- -
-
NameAddressDirectorDirector Email Date
{{ tournament.name }}{{ tournament.address }}{{ tournament.director }}{{ tournament.director_email }} {{ tournament.date }}
- - - - - - - - - - - - -
NameDate
{{ tournament.name }}{{ tournament.date }}
-
-
+ +
diff --git a/frontend/app/templates/tournaments.html b/frontend/app/templates/tournaments.html new file mode 100644 index 0000000..d8fab1f --- /dev/null +++ b/frontend/app/templates/tournaments.html @@ -0,0 +1,29 @@ +
+
+

Upcoming Tournaments

+
+
+
+ + + + +
+
+
+ + + + + + + + + + + + + +
NameDate
{{ tournament.name }}{{ tournament.date }}
+
+
\ No newline at end of file diff --git a/frontend/config/application.js b/frontend/config/application.js index 6a7ddf8..88b807f 100644 --- a/frontend/config/application.js +++ b/frontend/config/application.js @@ -26,7 +26,8 @@ module.exports = function(lineman) { apiProxy: { enabled: true, host: 'localhost', - port: 8080 + port: 8080, + prefix: 'api' }, web: { port: 8081 From ddcf2d807e22b5a432de5c57fb83db2b84646cf6 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Sat, 26 Mar 2016 03:54:31 +0000 Subject: [PATCH 25/46] Speeding up tests and renaming a few methods in generateMatchups --- Gemfile | 1 + app/models/generates_tournament_matches.rb | 12 +- app/models/match.rb | 4 + app/models/pool.rb | 9 +- app/models/weight.rb | 2 +- test/controllers/matches_controller_test.rb | 6 +- test/controllers/mats_controller_test.rb | 2 +- test/controllers/schools_controller_test.rb | 2 +- .../static_pages_controller_test.rb | 2 +- .../tournaments_controller_test.rb | 2 +- test/controllers/weights_controller_test.rb | 2 +- test/controllers/wrestlers_controller_test.rb | 2 +- test/fixtures/matches.yml | 2035 ++++++++++++++++- test/fixtures/wrestlers.yml | 1010 ++++---- test/integration/pool_advancement_test.rb | 399 ++-- test/integration/single_test_test.rb | 52 + test/models/tournament_test.rb | 1 + 17 files changed, 2814 insertions(+), 729 deletions(-) diff --git a/Gemfile b/Gemfile index 21bcd48..a742ddd 100644 --- a/Gemfile +++ b/Gemfile @@ -60,3 +60,4 @@ gem 'spring', :group => :development #gem 'bullet' end + diff --git a/app/models/generates_tournament_matches.rb b/app/models/generates_tournament_matches.rb index 1e19323..7661a64 100644 --- a/app/models/generates_tournament_matches.rb +++ b/app/models/generates_tournament_matches.rb @@ -8,7 +8,6 @@ module GeneratesTournamentMatches poolToBracket() if tournament_type == "Pool to bracket" self.curently_generating_matches = nil self.save - matches end if Rails.env.production? handle_asynchronously :generateMatchups @@ -16,13 +15,11 @@ module GeneratesTournamentMatches def poolToBracket destroyAllMatches - buildTournamentWeights - generateMatches - # This is not working for pool order and I cannot get tests working - movePoolSeedsToFinalPoolRound + generatePoolToBracketMatches + poolToBracketPostMatchCreation end - def buildTournamentWeights + def generatePoolToBracketMatches weights.order(:max).each do |weight| Pool.new(weight).generatePools() last_match = matches.where(weight: weight).order(round: :desc).limit(1).first @@ -31,11 +28,12 @@ module GeneratesTournamentMatches end end - def generateMatches + def poolToBracketPostMatchCreation moveFinalsMatchesToLastRound assignBouts assignLoserNames assignFirstMatchesToMats + movePoolSeedsToFinalPoolRound end def moveFinalsMatchesToLastRound diff --git a/app/models/match.rb b/app/models/match.rb index 962f993..549bc85 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -7,6 +7,10 @@ class Match < ActiveRecord::Base after_update do + after_update_actions + end + + def after_update_actions if self.finished == 1 && self.winner_id != nil if self.w1 && self.w2 wrestler1.touch diff --git a/app/models/pool.rb b/app/models/pool.rb index f9bdd37..8e7a3af 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -6,17 +6,14 @@ class Pool end def generatePools - matches = [] pools = @weight.pools while @pool <= pools - matches += roundRobin() + roundRobin @pool += 1 end - return matches end def roundRobin - matches = [] wrestlers = @weight.wrestlersForPool(@pool) poolMatches = RoundRobinTournament.schedule(wrestlers).reverse poolMatches.each_with_index do |b, index| @@ -24,16 +21,14 @@ class Pool bouts = b.map bouts.each do |bout| if bout[0] != nil and bout[1] != nil - match = @tournament.matches.create( + @tournament.matches.create( w1: bout[0].id, w2: bout[1].id, weight_id: @weight.id, bracket_position: "Pool", round: round) - matches << match end end end - matches end end diff --git a/app/models/weight.rb b/app/models/weight.rb index 34f7363..824a103 100644 --- a/app/models/weight.rb +++ b/app/models/weight.rb @@ -14,7 +14,7 @@ class Weight < ActiveRecord::Base end before_save do - self.tournament.destroyAllMatches + # self.tournament.destroyAllMatches end def wrestlersForPool(pool) diff --git a/test/controllers/matches_controller_test.rb b/test/controllers/matches_controller_test.rb index d9bd562..12d6ca0 100644 --- a/test/controllers/matches_controller_test.rb +++ b/test/controllers/matches_controller_test.rb @@ -5,12 +5,12 @@ class MatchesControllerTest < ActionController::TestCase setup do @tournament = Tournament.find(1) - @tournament.generateMatchups - @match = @tournament.matches.first + # @tournament.generateMatchups + @match = Match.where("tournament_id = ? and mat_id = ?",1,1).first end def post_update - patch :update, id: @match.id, match: {w1: @match.w1, w2: @match.w2} + patch :update, id: @match.id, match: {tournament_id: 1, mat_id: 1} end def get_edit diff --git a/test/controllers/mats_controller_test.rb b/test/controllers/mats_controller_test.rb index 7ebf6c4..38de270 100644 --- a/test/controllers/mats_controller_test.rb +++ b/test/controllers/mats_controller_test.rb @@ -5,7 +5,7 @@ class MatsControllerTest < ActionController::TestCase setup do @tournament = Tournament.find(1) - @tournament.generateMatchups + # @tournament.generateMatchups @mat = mats(:one) end diff --git a/test/controllers/schools_controller_test.rb b/test/controllers/schools_controller_test.rb index f788822..eee17d7 100644 --- a/test/controllers/schools_controller_test.rb +++ b/test/controllers/schools_controller_test.rb @@ -5,7 +5,7 @@ class SchoolsControllerTest < ActionController::TestCase setup do @tournament = Tournament.find(1) - @tournament.generateMatchups + # @tournament.generateMatchups @school = @tournament.schools.first end diff --git a/test/controllers/static_pages_controller_test.rb b/test/controllers/static_pages_controller_test.rb index ba2a24b..2eb9388 100644 --- a/test/controllers/static_pages_controller_test.rb +++ b/test/controllers/static_pages_controller_test.rb @@ -5,7 +5,7 @@ class StaticPagesControllerTest < ActionController::TestCase setup do @tournament = Tournament.find(1) - @tournament.generateMatchups + # @tournament.generateMatchups @school = @tournament.schools.first end diff --git a/test/controllers/tournaments_controller_test.rb b/test/controllers/tournaments_controller_test.rb index 1e0512b..707c6b3 100644 --- a/test/controllers/tournaments_controller_test.rb +++ b/test/controllers/tournaments_controller_test.rb @@ -5,7 +5,7 @@ include Devise::TestHelpers setup do @tournament = Tournament.find(1) - @tournament.generateMatchups + # @tournament.generateMatchups @school = @tournament.schools.first @wrestlers = @tournament.weights.first.wrestlers @adjust = Teampointadjust.find(1) diff --git a/test/controllers/weights_controller_test.rb b/test/controllers/weights_controller_test.rb index ba2a152..f3e7882 100644 --- a/test/controllers/weights_controller_test.rb +++ b/test/controllers/weights_controller_test.rb @@ -5,7 +5,7 @@ class WeightsControllerTest < ActionController::TestCase setup do @tournament = Tournament.find(1) - @tournament.generateMatchups + # @tournament.generateMatchups @weight = @tournament.weights.first end diff --git a/test/controllers/wrestlers_controller_test.rb b/test/controllers/wrestlers_controller_test.rb index 9ef496f..2193113 100644 --- a/test/controllers/wrestlers_controller_test.rb +++ b/test/controllers/wrestlers_controller_test.rb @@ -5,7 +5,7 @@ class WrestlersControllerTest < ActionController::TestCase setup do @tournament = Tournament.find(1) - @tournament.generateMatchups + # @tournament.generateMatchups @school = @tournament.schools.first @wrestler = @school.wrestlers.first end diff --git a/test/fixtures/matches.yml b/test/fixtures/matches.yml index ddd43a1..09e08a5 100644 --- a/test/fixtures/matches.yml +++ b/test/fixtures/matches.yml @@ -1,19 +1,2024 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html +# http://chriskottom.com/blog/2014/11/fixing-fixtures/ + # t.integer "w1" + # t.integer "w2" + # t.text "w1_stat" + # t.text "w2_stat" + # t.integer "winner_id" + # t.string "win_type" + # t.string "score" + # t.datetime "created_at" + # t.datetime "updated_at" + # t.integer "tournament_id" + # t.integer "round" + # t.integer "finished" + # t.integer "bout_number" + # t.integer "weight_id" + # t.string "bracket_position" + # t.integer "bracket_position_number" + # t.string "loser1_name" + # t.string "loser2_name" + # t.integer "mat_id" + + +# default: &default +# tournament_id: 1 + # one: -# r_id: 1 -# g_id: 1 -# g_stat: MyText -# r_stat: MyText -# winner_id: 1 -# win_type: MyString -# score: MyString +# <<: *defaults -# two: -# r_id: 1 -# g_id: 1 -# g_stat: MyText -# r_stat: MyText -# winner_id: 1 -# win_type: MyString -# score: MyString +tournament_1_bout_3007: + tournament_id: 1 + weight_id: 2 + bout_number: 3007 + w1: 10 + w2: 7 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6000: + tournament_id: 1 + weight_id: 3 + bout_number: 6000 + w1: + w2: + bracket_position: 1/2 + bracket_position_number: 1 + loser1_name: Winner Pool 1 + loser2_name: Winner Pool 2 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3013: + tournament_id: 1 + weight_id: 5 + bout_number: 3013 + w1: 39 + w2: 35 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4001: + tournament_id: 1 + weight_id: 1 + bout_number: 4001 + w1: 1 + w2: 5 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1002: + tournament_id: 1 + weight_id: 3 + bout_number: 1002 + w1: 18 + w2: 19 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: 1 + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3002: + tournament_id: 1 + weight_id: 3 + bout_number: 3002 + w1: 19 + w2: 21 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2021: + tournament_id: 1 + weight_id: 6 + bout_number: 2021 + w1: 50 + w2: 51 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1007: + tournament_id: 1 + weight_id: 2 + bout_number: 1007 + w1: 11 + w2: 10 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2004: + tournament_id: 1 + weight_id: 3 + bout_number: 2004 + w1: 16 + w2: 14 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1011: + tournament_id: 1 + weight_id: 4 + bout_number: 1011 + w1: 25 + w2: 32 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4004: + tournament_id: 1 + weight_id: 2 + bout_number: 4004 + w1: + w2: + bracket_position: Semis + bracket_position_number: 1 + loser1_name: Winner Pool 1 + loser2_name: Runner Up Pool 2 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4014: + tournament_id: 1 + weight_id: 6 + bout_number: 4014 + w1: 49 + w2: 50 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6002: + tournament_id: 1 + weight_id: 2 + bout_number: 6002 + w1: + w2: + bracket_position: 1/2 + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4007: + tournament_id: 1 + weight_id: 4 + bout_number: 4007 + w1: + w2: + bracket_position: Quarter + bracket_position_number: 2 + loser1_name: Winner Pool 4 + loser2_name: Runner Up Pool 3 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4013: + tournament_id: 1 + weight_id: 5 + bout_number: 4013 + w1: + w2: + bracket_position: Conso Semis + bracket_position_number: 2 + loser1_name: Runner Up Pool 2 + loser2_name: Runner Up Pool 3 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1019: + tournament_id: 1 + weight_id: 5 + bout_number: 1019 + w1: 38 + w2: 48 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2001: + tournament_id: 1 + weight_id: 1 + bout_number: 2001 + w1: 2 + w2: 3 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1017: + tournament_id: 1 + weight_id: 5 + bout_number: 1017 + w1: 34 + w2: 47 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1014: + tournament_id: 1 + weight_id: 5 + bout_number: 1014 + w1: 45 + w2: 39 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6011: + tournament_id: 1 + weight_id: 5 + bout_number: 6011 + w1: + w2: + bracket_position: 7/8 + bracket_position_number: 1 + loser1_name: Loser of 4012 + loser2_name: Loser of 4013 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3018: + tournament_id: 1 + weight_id: 5 + bout_number: 3018 + w1: 40 + w2: 48 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2014: + tournament_id: 1 + weight_id: 5 + bout_number: 2014 + w1: 37 + w2: 33 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6005: + tournament_id: 1 + weight_id: 4 + bout_number: 6005 + w1: + w2: + bracket_position: 3/4 + bracket_position_number: 1 + loser1_name: Loser of 5004 + loser2_name: Loser of 5005 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5002: + tournament_id: 1 + weight_id: 3 + bout_number: 5002 + w1: 21 + w2: 13 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3009: + tournament_id: 1 + weight_id: 4 + bout_number: 3009 + w1: 27 + w2: 30 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5005: + tournament_id: 1 + weight_id: 4 + bout_number: 5005 + w1: + w2: + bracket_position: Semis + bracket_position_number: 2 + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3021: + tournament_id: 1 + weight_id: 6 + bout_number: 3021 + w1: 52 + w2: 50 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2009: + tournament_id: 1 + weight_id: 4 + bout_number: 2009 + w1: 30 + w2: 28 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3011: + tournament_id: 1 + weight_id: 4 + bout_number: 3011 + w1: 32 + w2: 24 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6001: + tournament_id: 1 + weight_id: 3 + bout_number: 6001 + w1: + w2: + bracket_position: 3/4 + bracket_position_number: 1 + loser1_name: Runner Up Pool 1 + loser2_name: Runner Up Pool 2 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6008: + tournament_id: 1 + weight_id: 5 + bout_number: 6008 + w1: + w2: + bracket_position: 1/2 + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3017: + tournament_id: 1 + weight_id: 5 + bout_number: 3017 + w1: 41 + w2: 34 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4000: + tournament_id: 1 + weight_id: 1 + bout_number: 4000 + w1: 4 + w2: 2 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3015: + tournament_id: 1 + weight_id: 5 + bout_number: 3015 + w1: 37 + w2: 44 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2012: + tournament_id: 1 + weight_id: 5 + bout_number: 2012 + w1: 39 + w2: 46 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2000: + tournament_id: 1 + weight_id: 1 + bout_number: 2000 + w1: 5 + w2: 4 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1021: + tournament_id: 1 + weight_id: 6 + bout_number: 1021 + w1: 50 + w2: 53 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2019: + tournament_id: 1 + weight_id: 5 + bout_number: 2019 + w1: 38 + w2: 40 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1016: + tournament_id: 1 + weight_id: 5 + bout_number: 1016 + w1: 36 + w2: 37 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6006: + tournament_id: 1 + weight_id: 4 + bout_number: 6006 + w1: + w2: + bracket_position: 5/6 + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5009: + tournament_id: 1 + weight_id: 6 + bout_number: 5009 + w1: 49 + w2: 53 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3010: + tournament_id: 1 + weight_id: 4 + bout_number: 3010 + w1: 22 + w2: 31 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4008: + tournament_id: 1 + weight_id: 4 + bout_number: 4008 + w1: + w2: + bracket_position: Quarter + bracket_position_number: 3 + loser1_name: Winner Pool 2 + loser2_name: Runner Up Pool 1 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3008: + tournament_id: 1 + weight_id: 2 + bout_number: 3008 + w1: 6 + w2: 9 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2005: + tournament_id: 1 + weight_id: 3 + bout_number: 2005 + w1: 17 + w2: 15 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1003: + tournament_id: 1 + weight_id: 3 + bout_number: 1003 + w1: 21 + w2: 20 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: 1 + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2017: + tournament_id: 1 + weight_id: 5 + bout_number: 2017 + w1: 34 + w2: 43 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4011: + tournament_id: 1 + weight_id: 5 + bout_number: 4011 + w1: + w2: + bracket_position: Semis + bracket_position_number: 2 + loser1_name: Winner Pool 2 + loser2_name: Winner Pool 3 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3003: + tournament_id: 1 + weight_id: 3 + bout_number: 3003 + w1: 13 + w2: 18 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5006: + tournament_id: 1 + weight_id: 4 + bout_number: 5006 + w1: + w2: + bracket_position: Conso Semis + bracket_position_number: 1 + loser1_name: Loser of 4006 + loser2_name: Loser of 4007 + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3006: + tournament_id: 1 + weight_id: 2 + bout_number: 3006 + w1: 11 + w2: 12 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5003: + tournament_id: 1 + weight_id: 3 + bout_number: 5003 + w1: 20 + w2: 19 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5008: + tournament_id: 1 + weight_id: 6 + bout_number: 5008 + w1: 51 + w2: 52 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2010: + tournament_id: 1 + weight_id: 4 + bout_number: 2010 + w1: 31 + w2: 23 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4009: + tournament_id: 1 + weight_id: 4 + bout_number: 4009 + w1: + w2: + bracket_position: Quarter + bracket_position_number: 4 + loser1_name: Winner Pool 3 + loser2_name: Runner Up Pool 4 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1001: + tournament_id: 1 + weight_id: 1 + bout_number: 1001 + w1: 3 + w2: 4 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: 1 + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1022: + tournament_id: 1 + weight_id: 6 + bout_number: 1022 + w1: 51 + w2: 49 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2018: + tournament_id: 1 + weight_id: 5 + bout_number: 2018 + w1: 42 + w2: 48 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1015: + tournament_id: 1 + weight_id: 5 + bout_number: 1015 + w1: 44 + w2: 33 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6007: + tournament_id: 1 + weight_id: 4 + bout_number: 6007 + w1: + w2: + bracket_position: 7/8 + bracket_position_number: 1 + loser1_name: Loser of 5006 + loser2_name: Loser of 5007 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6009: + tournament_id: 1 + weight_id: 5 + bout_number: 6009 + w1: + w2: + bracket_position: 3/4 + bracket_position_number: 1 + loser1_name: Loser of 4010 + loser2_name: Loser of 4011 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3016: + tournament_id: 1 + weight_id: 5 + bout_number: 3016 + w1: 43 + w2: 47 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3001: + tournament_id: 1 + weight_id: 1 + bout_number: 3001 + w1: 5 + w2: 2 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3014: + tournament_id: 1 + weight_id: 5 + bout_number: 3014 + w1: 36 + w2: 33 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2013: + tournament_id: 1 + weight_id: 5 + bout_number: 2013 + w1: 35 + w2: 45 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1006: + tournament_id: 1 + weight_id: 2 + bout_number: 1006 + w1: 7 + w2: 12 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3020: + tournament_id: 1 + weight_id: 6 + bout_number: 3020 + w1: 53 + w2: 51 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1009: + tournament_id: 1 + weight_id: 4 + bout_number: 1009 + w1: 28 + w2: 27 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1012: + tournament_id: 1 + weight_id: 4 + bout_number: 1012 + w1: 26 + w2: 29 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2007: + tournament_id: 1 + weight_id: 2 + bout_number: 2007 + w1: 7 + w2: 11 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1004: + tournament_id: 1 + weight_id: 3 + bout_number: 1004 + w1: 17 + w2: 14 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5007: + tournament_id: 1 + weight_id: 4 + bout_number: 5007 + w1: + w2: + bracket_position: Conso Semis + bracket_position_number: 2 + loser1_name: Loser of 4008 + loser2_name: Loser of 4009 + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4002: + tournament_id: 1 + weight_id: 3 + bout_number: 4002 + w1: 20 + w2: 18 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4010: + tournament_id: 1 + weight_id: 5 + bout_number: 4010 + w1: + w2: + bracket_position: Semis + bracket_position_number: 1 + loser1_name: Winner Pool 1 + loser2_name: Winner Pool 4 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2016: + tournament_id: 1 + weight_id: 5 + bout_number: 2016 + w1: 41 + w2: 47 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2002: + tournament_id: 1 + weight_id: 3 + bout_number: 2002 + w1: 13 + w2: 20 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2008: + tournament_id: 1 + weight_id: 2 + bout_number: 2008 + w1: 9 + w2: 8 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3004: + tournament_id: 1 + weight_id: 3 + bout_number: 3004 + w1: 15 + w2: 14 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2011: + tournament_id: 1 + weight_id: 4 + bout_number: 2011 + w1: 24 + w2: 25 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2006: + tournament_id: 1 + weight_id: 2 + bout_number: 2006 + w1: 10 + w2: 12 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1005: + tournament_id: 1 + weight_id: 3 + bout_number: 1005 + w1: 15 + w2: 16 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2020: + tournament_id: 1 + weight_id: 6 + bout_number: 2020 + w1: 52 + w2: 49 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2003: + tournament_id: 1 + weight_id: 3 + bout_number: 2003 + w1: 18 + w2: 21 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5001: + tournament_id: 1 + weight_id: 1 + bout_number: 5001 + w1: 4 + w2: 1 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3012: + tournament_id: 1 + weight_id: 5 + bout_number: 3012 + w1: 45 + w2: 46 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5000: + tournament_id: 1 + weight_id: 1 + bout_number: 5000 + w1: 3 + w2: 5 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1008: + tournament_id: 1 + weight_id: 2 + bout_number: 1008 + w1: 8 + w2: 6 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3005: + tournament_id: 1 + weight_id: 3 + bout_number: 3005 + w1: 16 + w2: 17 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1010: + tournament_id: 1 + weight_id: 4 + bout_number: 1010 + w1: 23 + w2: 22 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5004: + tournament_id: 1 + weight_id: 4 + bout_number: 5004 + w1: + w2: + bracket_position: Semis + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4003: + tournament_id: 1 + weight_id: 3 + bout_number: 4003 + w1: 19 + w2: 13 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1000: + tournament_id: 1 + weight_id: 1 + bout_number: 1000 + w1: 2 + w2: 1 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: 1 + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6010: + tournament_id: 1 + weight_id: 5 + bout_number: 6010 + w1: + w2: + bracket_position: 5/6 + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3019: + tournament_id: 1 + weight_id: 5 + bout_number: 3019 + w1: 42 + w2: 38 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2015: + tournament_id: 1 + weight_id: 5 + bout_number: 2015 + w1: 44 + w2: 36 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6004: + tournament_id: 1 + weight_id: 4 + bout_number: 6004 + w1: + w2: + bracket_position: 1/2 + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4012: + tournament_id: 1 + weight_id: 5 + bout_number: 4012 + w1: + w2: + bracket_position: Conso Semis + bracket_position_number: 1 + loser1_name: Runner Up Pool 1 + loser2_name: Runner Up Pool 4 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1020: + tournament_id: 1 + weight_id: 5 + bout_number: 1020 + w1: 40 + w2: 42 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3000: + tournament_id: 1 + weight_id: 1 + bout_number: 3000 + w1: 1 + w2: 3 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1018: + tournament_id: 1 + weight_id: 5 + bout_number: 1018 + w1: 43 + w2: 41 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1013: + tournament_id: 1 + weight_id: 5 + bout_number: 1013 + w1: 35 + w2: 46 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4015: + tournament_id: 1 + weight_id: 6 + bout_number: 4015 + w1: 53 + w2: 52 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6003: + tournament_id: 1 + weight_id: 2 + bout_number: 6003 + w1: + w2: + bracket_position: 3/4 + bracket_position_number: 1 + loser1_name: Loser of 4004 + loser2_name: Loser of 4005 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4006: + tournament_id: 1 + weight_id: 4 + bout_number: 4006 + w1: + w2: + bracket_position: Quarter + bracket_position_number: 1 + loser1_name: Winner Pool 1 + loser2_name: Runner Up Pool 2 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4005: + tournament_id: 1 + weight_id: 2 + bout_number: 4005 + w1: + w2: + bracket_position: Semis + bracket_position_number: 2 + loser1_name: Winner Pool 2 + loser2_name: Runner Up Pool 1 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: diff --git a/test/fixtures/wrestlers.yml b/test/fixtures/wrestlers.yml index e07dd47..d2f48af 100644 --- a/test/fixtures/wrestlers.yml +++ b/test/fixtures/wrestlers.yml @@ -1,487 +1,531 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -one: - name: Zach Collins - school_id: 1 - weight_id: 1 - original_seed: 4 - season_loss: 8 - season_win: 30 - criteria: DP 5th - -two: - name: Jaden Mattox - school_id: 1 - weight_id: 1 - original_seed: 1 - season_loss: 3 - season_win: 49 - criteria: SP 2nd - -three: - name: Jackson Lakso - school_id: 1 - weight_id: 1 - original_seed: 3 - season_loss: 8 - season_win: 30 - criteria: SQ - -four: - name: JD Woods - school_id: 1 - weight_id: 1 - original_seed: 5 - season_loss: 12 - season_win: 30 - criteria: DP 6th - -five: - name: James Wimer - school_id: 1 - weight_id: 1 - original_seed: 2 - season_loss: 12 - season_win: 49 - criteria: SP 5th - -six: - name: Derek Wurzauf - school_id: 1 - weight_id: 2 - original_seed: 6 - season_loss: 15 - season_win: 16 - criteria: - -seven: - name: Casey Davis - school_id: 1 - weight_id: 2 - original_seed: 5 - season_loss: 15 - season_win: 16 - criteria: DQ - -eight: - name: Ethan Leapley - school_id: 1 - weight_id: 2 - original_seed: 4 - season_loss: 15 - season_win: 20 - criteria: DP 6th - -nine: - name: Clayton Ray - school_id: 1 - weight_id: 2 - original_seed: 1 - season_loss: 4 - season_win: 30 - criteria: SP 7th - -ten: - name: Robbie Fusner - school_id: 1 - weight_id: 2 - original_seed: 3 - season_loss: 5 - season_win: 40 - criteria: SQ - -eleven: - name: Kameron Teacher - school_id: 1 - weight_id: 2 - original_seed: 2 - season_loss: 2 - season_win: 50 - criteria: SQ - -twelve: - name: Guy1 - school_id: 1 - weight_id: 2 - original_seed: 7 - season_loss: 2 - season_win: 50 - criteria: - -thirteen: - name: Guy2 - school_id: 1 - weight_id: 3 - original_seed: 1 - season_loss: 2 - season_win: 50 - criteria: - -fourteen: - name: Guy3 - school_id: 1 - weight_id: 3 - original_seed: 2 - season_loss: 2 - season_win: 50 - criteria: - -fifteen: - name: Guy4 - school_id: 1 - weight_id: 3 - original_seed: 3 - season_loss: 2 - season_win: 50 - criteria: - -sixteen: - name: Guy5 - school_id: 1 - weight_id: 3 - original_seed: 4 - season_loss: 2 - season_win: 50 - criteria: - -seventeen: - name: Guy6 - school_id: 1 - weight_id: 3 - original_seed: 5 - season_loss: 2 - season_win: 50 - criteria: - -eighteen: - name: Guy7 - school_id: 1 - weight_id: 3 - original_seed: 6 - season_loss: 2 - season_win: 50 - criteria: - -ninteen: - name: Guy8 - school_id: 1 - weight_id: 3 - original_seed: 7 - season_loss: 2 - season_win: 50 - criteria: - -twenty: - name: Guy9 - school_id: 1 - weight_id: 3 - original_seed: 8 - season_loss: 2 - season_win: 50 - criteria: - -twentyone: - name: Guy10 - school_id: 1 - weight_id: 3 - original_seed: 9 - season_loss: 2 - season_win: 50 - criteria: +wrestler1: + id: 1 + name: Jackson Lakso + school_id: 1 + weight_id: 1 + original_seed: 3 + season_loss: 8 + season_win: 30 + criteria: SQ -twentytwo: - name: Guy11 - school_id: 1 - weight_id: 4 - original_seed: 1 - season_loss: 2 - season_win: 50 - criteria: - -twentythree: - name: Guy12 - school_id: 1 - weight_id: 4 - original_seed: 2 - season_loss: 2 - season_win: 50 - criteria: - -twentyfour: - name: Guy13 - school_id: 1 - weight_id: 4 - original_seed: 3 - season_loss: 2 - season_win: 50 - criteria: - -twentyfive: - name: Guy14 - school_id: 1 - weight_id: 4 - original_seed: 4 - season_loss: 2 - season_win: 50 - criteria: - -twentysix: - name: Guy15 - school_id: 1 - weight_id: 4 - original_seed: 5 - season_loss: 2 - season_win: 50 - criteria: - -twnetyseven: - name: Guy16 - school_id: 1 - weight_id: 4 - original_seed: 6 - season_loss: 2 - season_win: 50 - criteria: - -twentyeight: - name: Guy17 - school_id: 1 - weight_id: 4 - original_seed: 7 - season_loss: 2 - season_win: 50 - criteria: - -twentynine: - name: Guy18 - school_id: 1 - weight_id: 4 - original_seed: 8 - season_loss: 2 - season_win: 50 - criteria: - -thirty: - name: Guy19 - school_id: 1 - weight_id: 4 - original_seed: 9 - season_loss: 2 - season_win: 50 - criteria: - -thrityone: - name: Guy20 - school_id: 1 - weight_id: 4 - original_seed: 10 - season_loss: 2 - season_win: 50 - criteria: - -thirtytwo: - name: Guy21 - school_id: 1 - weight_id: 4 - original_seed: 11 - season_loss: 2 - season_win: 50 - criteria: - -thirtythree: - name: Guy22 - school_id: 1 - weight_id: 5 - original_seed: 1 - season_loss: 2 - season_win: 50 - criteria: - -thirtyfour: - name: Guy23 - school_id: 1 - weight_id: 5 - original_seed: 2 - season_loss: 2 - season_win: 50 - criteria: - -thirtyfive: - name: Guy24 - school_id: 1 - weight_id: 5 - original_seed: 3 - season_loss: 2 - season_win: 50 - criteria: - -thirtysix: - name: Guy25 - school_id: 1 - weight_id: 5 - original_seed: 4 - season_loss: 2 - season_win: 50 - criteria: - -thirtyseven: - name: Guy26 - school_id: 1 - weight_id: 5 - original_seed: 5 - season_loss: 2 - season_win: 50 - criteria: - -thirtyeight: - name: Guy27 - school_id: 1 - weight_id: 5 - original_seed: 6 - season_loss: 2 - season_win: 50 - criteria: - -thirtynine: - name: Guy28 - school_id: 1 - weight_id: 5 - original_seed: 7 - season_loss: 2 - season_win: 50 - criteria: - -fourty: - name: Guy29 - school_id: 1 - weight_id: 5 - original_seed: 8 - season_loss: 2 - season_win: 50 - criteria: - -fourtyone: - name: Guy30 - school_id: 1 - weight_id: 5 - original_seed: 9 - season_loss: 2 - season_win: 50 - criteria: - -fourtytwo: - name: Guy31 - school_id: 1 - weight_id: 5 - original_seed: 10 - season_loss: 2 - season_win: 50 - criteria: - -fourtythree: - name: Guy32 - school_id: 1 - weight_id: 5 - original_seed: 11 - season_loss: 2 - season_win: 50 - criteria: +wrestler2: + id: 2 + name: JD Woods + school_id: 1 + weight_id: 1 + original_seed: 5 + season_loss: 12 + season_win: 30 + criteria: DP 6th -fourtyfour: - name: Guy33 - school_id: 1 - weight_id: 5 - original_seed: 12 - season_loss: 2 - season_win: 50 - criteria: - -fourtyfive: - name: Guy34 - school_id: 1 - weight_id: 5 - original_seed: 13 - season_loss: 2 - season_win: 50 - criteria: - -fourtysix: - name: Guy35 - school_id: 1 - weight_id: 5 - original_seed: 14 - season_loss: 2 - season_win: 50 - criteria: - -fourtyseven: - name: Guy36 - school_id: 1 - weight_id: 5 - original_seed: 15 - season_loss: 2 - season_win: 50 - criteria: - -fourtyeight: - name: Guy37 - school_id: 1 - weight_id: 5 - original_seed: 16 - season_loss: 2 - season_win: 50 - criteria: - -fourtynine: - name: Guy38 - school_id: 1 - weight_id: 6 - original_seed: 1 - season_loss: 2 - season_win: 50 - criteria: - -fourtynine: - name: Guy39 - school_id: 1 - weight_id: 6 - original_seed: 2 - season_loss: 2 - season_win: 50 - criteria: - -fifty: - name: Guy40 - school_id: 1 - weight_id: 6 - original_seed: - season_loss: 2 - season_win: 50 - criteria: - -fiftyone: - name: Guy41 - school_id: 1 - weight_id: 6 - original_seed: - season_loss: 2 - season_win: 50 - criteria: - -fiftytwo: - name: Guy42 - school_id: 1 - weight_id: 6 - original_seed: - season_loss: 2 - season_win: 50 - criteria: - -fiftythree: - name: Guy43 - school_id: 1 - weight_id: 6 - original_seed: - season_loss: 2 - season_win: 50 - criteria: \ No newline at end of file +wrestler3: + id: 3 + name: Jaden Mattox + school_id: 1 + weight_id: 1 + original_seed: 1 + season_loss: 3 + season_win: 49 + criteria: SP 2nd + +wrestler4: + id: 4 + name: Zach Collins + school_id: 1 + weight_id: 1 + original_seed: 4 + season_loss: 8 + season_win: 30 + criteria: DP 5th + +wrestler5: + id: 5 + name: James Wimer + school_id: 1 + weight_id: 1 + original_seed: 2 + season_loss: 12 + season_win: 49 + criteria: SP 5th + +wrestler6: + id: 6 + name: Derek Wurzauf + school_id: 1 + weight_id: 2 + original_seed: 6 + season_loss: 15 + season_win: 16 + criteria: + +wrestler7: + id: 7 + name: Casey Davis + school_id: 1 + weight_id: 2 + original_seed: 5 + season_loss: 15 + season_win: 16 + criteria: DQ + +wrestler8: + id: 8 + name: Kameron Teacher + school_id: 1 + weight_id: 2 + original_seed: 2 + season_loss: 2 + season_win: 50 + criteria: SQ + +wrestler9: + id: 9 + name: Robbie Fusner + school_id: 1 + weight_id: 2 + original_seed: 3 + season_loss: 5 + season_win: 40 + criteria: SQ + +wrestler10: + id: 10 + name: Guy1 + school_id: 1 + weight_id: 2 + original_seed: 7 + season_loss: 2 + season_win: 50 + criteria: + +wrestler11: + id: 11 + name: Ethan Leapley + school_id: 1 + weight_id: 2 + original_seed: 4 + season_loss: 15 + season_win: 20 + criteria: DP 6th + +wrestler12: + id: 12 + name: Clayton Ray + school_id: 1 + weight_id: 2 + original_seed: 1 + season_loss: 4 + season_win: 30 + criteria: SP 7th + +wrestler13: + id: 13 + name: Guy2 + school_id: 1 + weight_id: 3 + original_seed: 1 + season_loss: 2 + season_win: 50 + criteria: + +wrestler14: + id: 14 + name: Guy9 + school_id: 1 + weight_id: 3 + original_seed: 8 + season_loss: 2 + season_win: 50 + criteria: + +wrestler15: + id: 15 + name: Guy7 + school_id: 1 + weight_id: 3 + original_seed: 6 + season_loss: 2 + season_win: 50 + criteria: + +wrestler16: + id: 16 + name: Guy3 + school_id: 1 + weight_id: 3 + original_seed: 2 + season_loss: 2 + season_win: 50 + criteria: + +wrestler17: + id: 17 + name: Guy4 + school_id: 1 + weight_id: 3 + original_seed: 3 + season_loss: 2 + season_win: 50 + criteria: + +wrestler18: + id: 18 + name: Guy8 + school_id: 1 + weight_id: 3 + original_seed: 7 + season_loss: 2 + season_win: 50 + criteria: + +wrestler19: + id: 19 + name: Guy10 + school_id: 1 + weight_id: 3 + original_seed: 9 + season_loss: 2 + season_win: 50 + criteria: + +wrestler20: + id: 20 + name: Guy6 + school_id: 1 + weight_id: 3 + original_seed: 5 + season_loss: 2 + season_win: 50 + criteria: + +wrestler21: + id: 21 + name: Guy5 + school_id: 1 + weight_id: 3 + original_seed: 4 + season_loss: 2 + season_win: 50 + criteria: + +wrestler22: + id: 22 + name: Guy20 + school_id: 1 + weight_id: 4 + original_seed: 10 + season_loss: 2 + season_win: 50 + criteria: + +wrestler23: + id: 23 + name: Guy12 + school_id: 1 + weight_id: 4 + original_seed: 2 + season_loss: 2 + season_win: 50 + criteria: + +wrestler24: + id: 24 + name: Guy16 + school_id: 1 + weight_id: 4 + original_seed: 6 + season_loss: 2 + season_win: 50 + criteria: + +wrestler25: + id: 25 + name: Guy13 + school_id: 1 + weight_id: 4 + original_seed: 3 + season_loss: 2 + season_win: 50 + criteria: + +wrestler26: + id: 26 + name: Guy15 + school_id: 1 + weight_id: 4 + original_seed: 5 + season_loss: 2 + season_win: 50 + criteria: + +wrestler27: + id: 27 + name: Guy21 + school_id: 1 + weight_id: 4 + original_seed: 11 + season_loss: 2 + season_win: 50 + criteria: + +wrestler28: + id: 28 + name: Guy11 + school_id: 1 + weight_id: 4 + original_seed: 1 + season_loss: 2 + season_win: 50 + criteria: + +wrestler29: + id: 29 + name: Guy14 + school_id: 1 + weight_id: 4 + original_seed: 4 + season_loss: 2 + season_win: 50 + criteria: + +wrestler30: + id: 30 + name: Guy18 + school_id: 1 + weight_id: 4 + original_seed: 8 + season_loss: 2 + season_win: 50 + criteria: + +wrestler31: + id: 31 + name: Guy17 + school_id: 1 + weight_id: 4 + original_seed: 7 + season_loss: 2 + season_win: 50 + criteria: + +wrestler32: + id: 32 + name: Guy19 + school_id: 1 + weight_id: 4 + original_seed: 9 + season_loss: 2 + season_win: 50 + criteria: + +wrestler33: + id: 33 + name: Guy36 + school_id: 1 + weight_id: 5 + original_seed: 15 + season_loss: 2 + season_win: 50 + criteria: + +wrestler34: + id: 34 + name: Guy31 + school_id: 1 + weight_id: 5 + original_seed: 10 + season_loss: 2 + season_win: 50 + criteria: + +wrestler35: + id: 35 + name: Guy22 + school_id: 1 + weight_id: 5 + original_seed: 1 + season_loss: 2 + season_win: 50 + criteria: + +wrestler36: + id: 36 + name: Guy32 + school_id: 1 + weight_id: 5 + original_seed: 11 + season_loss: 2 + season_win: 50 + criteria: + +wrestler37: + id: 37 + name: Guy23 + school_id: 1 + weight_id: 5 + original_seed: 2 + season_loss: 2 + season_win: 50 + criteria: + +wrestler38: + id: 38 + name: Guy34 + school_id: 1 + weight_id: 5 + original_seed: 13 + season_loss: 2 + season_win: 50 + criteria: + +wrestler39: + id: 39 + name: Guy29 + school_id: 1 + weight_id: 5 + original_seed: 8 + season_loss: 2 + season_win: 50 + criteria: + +wrestler40: + id: 40 + name: Guy26 + school_id: 1 + weight_id: 5 + original_seed: 5 + season_loss: 2 + season_win: 50 + criteria: + +wrestler41: + id: 41 + name: Guy35 + school_id: 1 + weight_id: 5 + original_seed: 14 + season_loss: 2 + season_win: 50 + criteria: + +wrestler42: + id: 42 + name: Guy30 + school_id: 1 + weight_id: 5 + original_seed: 9 + season_loss: 2 + season_win: 50 + criteria: + +wrestler43: + id: 43 + name: Guy27 + school_id: 1 + weight_id: 5 + original_seed: 6 + season_loss: 2 + season_win: 50 + criteria: + +wrestler44: + id: 44 + name: Guy28 + school_id: 1 + weight_id: 5 + original_seed: 7 + season_loss: 2 + season_win: 50 + criteria: + +wrestler45: + id: 45 + name: Guy37 + school_id: 1 + weight_id: 5 + original_seed: 16 + season_loss: 2 + season_win: 50 + criteria: + +wrestler46: + id: 46 + name: Guy33 + school_id: 1 + weight_id: 5 + original_seed: 12 + season_loss: 2 + season_win: 50 + criteria: + +wrestler47: + id: 47 + name: Guy24 + school_id: 1 + weight_id: 5 + original_seed: 3 + season_loss: 2 + season_win: 50 + criteria: + +wrestler48: + id: 48 + name: Guy25 + school_id: 1 + weight_id: 5 + original_seed: 4 + season_loss: 2 + season_win: 50 + criteria: + +wrestler49: + id: 49 + name: Guy42 + school_id: 1 + weight_id: 6 + original_seed: + season_loss: 2 + season_win: 50 + criteria: + +wrestler50: + id: 50 + name: Guy39 + school_id: 1 + weight_id: 6 + original_seed: 2 + season_loss: 2 + season_win: 50 + criteria: + +wrestler51: + id: 51 + name: Guy41 + school_id: 1 + weight_id: 6 + original_seed: + season_loss: 2 + season_win: 50 + criteria: + +wrestler52: + id: 52 + name: Guy43 + school_id: 1 + weight_id: 6 + original_seed: + season_loss: 2 + season_win: 50 + criteria: + +wrestler53: + id: 53 + name: Guy40 + school_id: 1 + weight_id: 6 + original_seed: + season_loss: 2 + season_win: 50 + criteria: \ No newline at end of file diff --git a/test/integration/pool_advancement_test.rb b/test/integration/pool_advancement_test.rb index 14c526c..3b033ac 100644 --- a/test/integration/pool_advancement_test.rb +++ b/test/integration/pool_advancement_test.rb @@ -3,129 +3,127 @@ require 'test_helper' class PoolAdvancementTest < ActionDispatch::IntegrationTest def setup - @tournament = Tournament.find(1) - @tournament.generateMatchups - @matches = @tournament.matches + tournament = Tournament.find(1) + tournament.generateMatchups end - def showMatches - matches = Weight.where("id = ?", 4).first.matches - # matches = @matches.select{|m| m.weight_id == 4} - matches.each do |m| - puts "Bout: #{m.bout_number} #{m.w1_name} vs #{m.w2_name} #{m.bracket_position} #{m.poolNumber}" - end - end + # def showMatches + # matches = Weight.where("id = ?", 4).first.matches + # matches.each do |m| + # puts "Bout: #{m.bout_number} #{m.w1_name} vs #{m.w2_name} #{m.bracket_position} #{m.poolNumber}" + # end + # end def singlePoolNotFinished - matches = @matches - endMatch(1000,"Jackson Lakso",matches) - endMatch(1001,"Jaden Mattox",matches) - endMatch(2000,"James Wimer",matches) - endMatch(2001,"Jaden Mattox",matches) - endMatch(3000,"Jaden Mattox",matches) - endMatch(3001,"James Wimer",matches) - endMatch(4000,"JD Woods",matches) - endMatch(4001,"James Wimer",matches) - endMatch(5000,"James Wimer",matches) + + endMatch(1000,"Jackson Lakso") + endMatch(1001,"Jaden Mattox") + endMatch(2000,"James Wimer") + endMatch(2001,"Jaden Mattox") + endMatch(3000,"Jaden Mattox") + endMatch(3001,"James Wimer") + endMatch(4000,"JD Woods") + endMatch(4001,"James Wimer") + endMatch(5000,"James Wimer") end def singlePoolFinished singlePoolNotFinished - matches = @matches - endMatch(5001,"Jackson Lakso",matches) + + endMatch(5001,"Jackson Lakso") end def sixteenManToSemi - matches = @matches - endMatch(1013,"Guy22",matches) - endMatch(1014,"Guy29",matches) - endMatch(2012,"Guy29",matches) - endMatch(2013,"Guy22",matches) - endMatch(3012,"Guy37",matches) - endMatch(3013,"Guy22",matches) - endMatch(1015,"Guy36",matches) - endMatch(1016,"Guy32",matches) - endMatch(2014,"Guy36",matches) - endMatch(2015,"Guy32",matches) - endMatch(3014,"Guy36",matches) - endMatch(3015,"Guy23",matches) - endMatch(1017,"Guy31",matches) - endMatch(1018,"Guy35",matches) - endMatch(2016,"Guy35",matches) - endMatch(2017,"Guy31",matches) - endMatch(3016,"Guy27",matches) - endMatch(3017,"Guy31",matches) - endMatch(1019,"Guy34",matches) - endMatch(1020,"Guy26",matches) - endMatch(2018,"Guy30",matches) - endMatch(2019,"Guy34",matches) - endMatch(3018,"Guy26",matches) - endMatch(3019,"Guy34",matches) + + endMatch(1013,"Guy22") + endMatch(1014,"Guy29") + endMatch(2012,"Guy29") + endMatch(2013,"Guy22") + endMatch(3012,"Guy37") + endMatch(3013,"Guy22") + endMatch(1015,"Guy36") + endMatch(1016,"Guy32") + endMatch(2014,"Guy36") + endMatch(2015,"Guy32") + endMatch(3014,"Guy36") + endMatch(3015,"Guy23") + endMatch(1017,"Guy31") + endMatch(1018,"Guy35") + endMatch(2016,"Guy35") + endMatch(2017,"Guy31") + endMatch(3016,"Guy27") + endMatch(3017,"Guy31") + endMatch(1019,"Guy34") + endMatch(1020,"Guy26") + endMatch(2018,"Guy30") + endMatch(2019,"Guy34") + endMatch(3018,"Guy26") + endMatch(3019,"Guy34") end def sevenManTwoPoolToSemi - matches = @matches - endMatch(1006,"Casey Davis",matches) - endMatch(1007,"Ethan Leapley",matches) - endMatch(2006,"Clayton Ray",matches) - endMatch(2007,"Ethan Leapley",matches) - endMatch(3006,"Ethan Leapley",matches) - endMatch(3007,"Casey Davis",matches) - endMatch(1008,"Kameron Teacher",matches) - endMatch(2008,"Kameron Teacher",matches) - endMatch(3008,"Robbie Fusner",matches) + + endMatch(1006,"Casey Davis") + endMatch(1007,"Ethan Leapley") + endMatch(2006,"Clayton Ray") + endMatch(2007,"Ethan Leapley") + endMatch(3006,"Ethan Leapley") + endMatch(3007,"Casey Davis") + endMatch(1008,"Kameron Teacher") + endMatch(2008,"Kameron Teacher") + endMatch(3008,"Robbie Fusner") end def sevenManTwoPoolSemiToFinals sevenManTwoPoolToSemi - matches = @matches - endMatch(4005,"Casey Davis",matches) - endMatch(4004,"Ethan Leapley",matches) + + endMatch(4005,"Casey Davis") + endMatch(4004,"Ethan Leapley") end def nineManBracketPoolOneOutrightWinnerGuyTwo - matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"} - endMatch(1002,"Guy8",matches) - endMatch(1003,"Guy5",matches) - endMatch(2002,"Guy2",matches) - endMatch(2003,"Guy8",matches) - endMatch(3002,"Guy5",matches) - endMatch(3003,"Guy2",matches) - endMatch(4002,"Guy8",matches) - endMatch(4003,"Guy2",matches) - endMatch(5002,"Guy2",matches) - endMatch(5003,"Guy10",matches) + + endMatch(1002,"Guy8") + endMatch(1003,"Guy5") + endMatch(2002,"Guy2") + endMatch(2003,"Guy8") + endMatch(3002,"Guy5") + endMatch(3003,"Guy2") + endMatch(4002,"Guy8") + endMatch(4003,"Guy2") + endMatch(5002,"Guy2") + endMatch(5003,"Guy10") end def nineManBracketPoolTwoGuyNineHeadToHead - matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"} - endMatch(1004,"Guy4",matches) - endMatch(1005,"Guy3",matches) - endMatch(2004,"Guy9",matches) - endMatch(2005,"Guy7",matches) - endMatch(3004,"Guy9",matches) - endMatch(3005,"Guy3",matches) + + endMatch(1004,"Guy4") + endMatch(1005,"Guy3") + endMatch(2004,"Guy9") + endMatch(2005,"Guy7") + endMatch(3004,"Guy9") + endMatch(3005,"Guy3") end def nineManBracketPoolTwoGuyThreeHeadToHead - matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"} - endMatch(1004,"Guy9",matches) - endMatch(1005,"Guy3",matches) - endMatch(2004,"Guy3",matches) - endMatch(2005,"Guy7",matches) - endMatch(3004,"Guy9",matches) - endMatch(3005,"Guy4",matches) + + endMatch(1004,"Guy9") + endMatch(1005,"Guy3") + endMatch(2004,"Guy3") + endMatch(2005,"Guy7") + endMatch(3004,"Guy9") + endMatch(3005,"Guy4") end def nineManBracketPoolTwoGuyThreeDeductedPoints - matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"} - endMatch(1004,"Guy9",matches) - endMatch(1005,"Guy7",matches) - endMatch(2004,"Guy3",matches) - endMatch(2005,"Guy7",matches) - endMatch(3004,"Guy9",matches) - endMatch(3005,"Guy3",matches) + + endMatch(1004,"Guy9") + endMatch(1005,"Guy7") + endMatch(2004,"Guy3") + endMatch(2005,"Guy7") + endMatch(3004,"Guy9") + endMatch(3005,"Guy3") deduct = Teampointadjust.new deduct.wrestler_id = translateNameToId("Guy7") deduct.points = 1 @@ -133,175 +131,162 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end def nineManBracketPoolTwoGuyThreeMostDecisionPoints - matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"} - endMatchExtraPoints(1004,"Guy9",matches) - endMatch(1005,"Guy7",matches) - endMatchExtraPoints(2004,"Guy3",matches) - endMatch(2005,"Guy7",matches) - endMatch(3004,"Guy9",matches) - endMatchExtraPoints(3005,"Guy3",matches) + + endMatchExtraPoints(1004,"Guy9") + endMatch(1005,"Guy7") + endMatchExtraPoints(2004,"Guy3") + endMatch(2005,"Guy7") + endMatch(3004,"Guy9") + endMatchExtraPoints(3005,"Guy3") end def nineManBracketPoolTwoGuyThreeQuickestPin - matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"} - endMatchWithQuickPin(1004,"Guy9",matches) - endMatchWithPin(1005,"Guy7",matches) - endMatchWithQuickPin(2004,"Guy3",matches) - endMatchWithPin(2005,"Guy7",matches) - endMatchWithPin(3004,"Guy9",matches) - endMatchWithQuickestPin(3005,"Guy3",matches) + + endMatchWithQuickPin(1004,"Guy9") + endMatchWithPin(1005,"Guy7") + endMatchWithQuickPin(2004,"Guy3") + endMatchWithPin(2005,"Guy7") + endMatchWithPin(3004,"Guy9") + endMatchWithQuickestPin(3005,"Guy3") end def nineManBracketPoolTwoGuyThreeTeamPoints - matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"} - endMatch(1004,"Guy9",matches) - endMatch(1005,"Guy7",matches) - endMatchWithMajor(2004,"Guy3",matches) - endMatch(2005,"Guy7",matches) - endMatch(3004,"Guy9",matches) - endMatch(3005,"Guy3",matches) + + endMatch(1004,"Guy9") + endMatch(1005,"Guy7") + endMatchWithMajor(2004,"Guy3") + endMatch(2005,"Guy7") + endMatch(3004,"Guy9") + endMatch(3005,"Guy3") end def nineManBracketPoolTwoGuyThreeMostPins - matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"} - endMatchWithMajor(1004,"Guy9",matches) - endMatch(1005,"Guy7",matches) - endMatchWithPin(2004,"Guy3",matches) - endMatchWithMajor(2005,"Guy7",matches) - endMatch(3004,"Guy9",matches) - endMatch(3005,"Guy3",matches) + + endMatchWithMajor(1004,"Guy9") + endMatch(1005,"Guy7") + endMatchWithPin(2004,"Guy3") + endMatchWithMajor(2005,"Guy7") + endMatch(3004,"Guy9") + endMatch(3005,"Guy3") end def nineManBracketPoolOneGuyEightMostTechs - matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"} - endMatchWithTech(1002,"Guy8",matches) - endMatch(1003,"Guy5",matches) - endMatchWithMajor(2002,"Guy2",matches) - endMatchWithTech(2003,"Guy8",matches) - endMatchWithMajor(3002,"Guy10",matches) - endMatchWithMajor(3003,"Guy2",matches) - endMatch(4002,"Guy8",matches) - endMatchWithMajor(4003,"Guy10",matches) - endMatchWithMajor(5002,"Guy2",matches) - endMatchWithMajor(5003,"Guy10",matches) + + endMatchWithTech(1002,"Guy8") + endMatch(1003,"Guy5") + endMatchWithMajor(2002,"Guy2") + endMatchWithTech(2003,"Guy8") + endMatchWithMajor(3002,"Guy10") + endMatchWithMajor(3003,"Guy2") + endMatch(4002,"Guy8") + endMatchWithMajor(4003,"Guy10") + endMatchWithMajor(5002,"Guy2") + endMatchWithMajor(5003,"Guy10") end def elevenManBracketToQuarter - matches = @matches - endMatch(1009,"Guy11",matches) - endMatch(2009,"Guy11",matches) - endMatch(3009,"Guy18",matches) - endMatch(1010,"Guy12",matches) - endMatch(2010,"Guy12",matches) - endMatch(3010,"Guy17",matches) - endMatch(1011,"Guy13",matches) - endMatch(2011,"Guy13",matches) - endMatch(3011,"Guy19",matches) - endMatch(1012,"Guy14",matches) + + endMatch(1009,"Guy11") + endMatch(2009,"Guy11") + endMatch(3009,"Guy18") + endMatch(1010,"Guy12") + endMatch(2010,"Guy12") + endMatch(3010,"Guy17") + endMatch(1011,"Guy13") + endMatch(2011,"Guy13") + endMatch(3011,"Guy19") + endMatch(1012,"Guy14") end def elevenManBracketToSemis elevenManBracketToQuarter - matches = @matches - endMatch(4006,"Guy11",matches) - endMatch(4007,"Guy14",matches) - endMatch(4008,"Guy12",matches) - endMatch(4009,"Guy13",matches) + + endMatch(4006,"Guy11") + endMatch(4007,"Guy14") + endMatch(4008,"Guy12") + endMatch(4009,"Guy13") end def elevenManBracketToFinals elevenManBracketToSemis - matches = @matches - endMatch(5004,"Guy11",matches) - endMatch(5005,"Guy12",matches) - endMatch(5006,"Guy17",matches) - endMatch(5007,"Guy18",matches) + + endMatch(5004,"Guy11") + endMatch(5005,"Guy12") + endMatch(5006,"Guy17") + endMatch(5007,"Guy18") end def elevenManBracketFinished elevenManBracketToFinals - matches = @matches - endMatch(6004,"Guy11",matches) - endMatch(6005,"Guy14",matches) - endMatch(6006,"Guy17",matches) - endMatch(6007,"Guy19",matches) + + endMatch(6004,"Guy11") + endMatch(6005,"Guy14") + endMatch(6006,"Guy17") + endMatch(6007,"Guy19") end def extraDoesNotScoreTeamPoints - matches = @matches + wrestlerName = "Guy22" wrestler = Wrestler.find(translateNameToId(wrestlerName)) wrestler.extra = true wrestler.save - endMatch(1013,"Guy22",matches) + endMatch(1013,"Guy22") end - def endMatch(bout,winner,matches) - match = Match.where(bout_number: bout).first - match.finished = 1 - match.winner_id = translateNameToId(winner) + def endMatch(bout,winner) + match = Match.where(bout_number: bout).first + # match = @matches.select{|m| m.bout_number == bout}.first match.win_type = "Decision" match.score = 1-0 - - match.save + saveMatch(match,winner) end - def endMatchExtraPoints(bout,winner,matches) + def endMatchExtraPoints(bout,winner) match = Match.where(bout_number: bout).first - match.finished = 1 - match.winner_id = translateNameToId(winner) match.win_type = "Decision" match.score = 0-2 - - match.save + saveMatch(match,winner) end - def endMatchWithMajor(bout,winner,matches) + def endMatchWithMajor(bout,winner) match = Match.where(bout_number: bout).first - match.finished = 1 - match.winner_id = translateNameToId(winner) match.win_type = "Major" match.score = 8-0 - - match.save + saveMatch(match,winner) end - def endMatchWithTech(bout,winner,matches) + def endMatchWithTech(bout,winner) match = Match.where(bout_number: bout).first - match.finished = 1 - match.winner_id = translateNameToId(winner) match.win_type = "Tech Fall" - - match.save + match.score = 15-0 + saveMatch(match,winner) end - def endMatchWithPin(bout,winner,matches) + def endMatchWithPin(bout,winner) match = Match.where(bout_number: bout).first - match.finished = 1 - match.winner_id = translateNameToId(winner) match.win_type = "Pin" match.score = "5:00" - - match.save + saveMatch(match,winner) end - def endMatchWithQuickestPin(bout,winner,matches) + def endMatchWithQuickestPin(bout,winner) match = Match.where(bout_number: bout).first - match.finished = 1 - match.winner_id = translateNameToId(winner) match.win_type = "Pin" match.score = "0:20" - - match.save + saveMatch(match,winner) end - def endMatchWithQuickPin(bout,winner,matches) + def endMatchWithQuickPin(bout,winner) match = Match.where(bout_number: bout).first - match.finished = 1 - match.winner_id = translateNameToId(winner) match.win_type = "Pin" match.score = "1:20" - - match.save + saveMatch(match,winner) + end + + def saveMatch(match,winner) + match.finished = 1 + match.winner_id = translateNameToId(winner) + match.save end def translateNameToId(wrestler) @@ -458,7 +443,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest test "advancement points winner 1/2" do nineManBracketPoolOneOutrightWinnerGuyTwo nineManBracketPoolTwoGuyThreeHeadToHead - endMatch(6000,"Guy2",@matches) + endMatch(6000,"Guy2") wrestler1 = Wrestler.where("name = ?", "Guy2").first assert_equal 16, wrestler1.placementPoints end @@ -466,7 +451,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest test "advancement points winner 3/4" do nineManBracketPoolOneOutrightWinnerGuyTwo nineManBracketPoolTwoGuyThreeHeadToHead - endMatch(6001,"Guy8",@matches) + endMatch(6001,"Guy8") wrestler1 = Wrestler.where("name = ?", "Guy8").first assert_equal 10, wrestler1.placementPoints end @@ -486,25 +471,25 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end test "bonus points major" do - endMatchWithMajor(2002,"Guy2",@matches) + endMatchWithMajor(2002,"Guy2") wrestler1 = Wrestler.where("name = ?", "Guy2").first assert_equal 3, wrestler1.teamPointsEarned end test "bonus points pin" do - endMatchWithPin(2002,"Guy2",@matches) + endMatchWithPin(2002,"Guy2") wrestler1 = Wrestler.where("name = ?", "Guy2").first assert_equal 4, wrestler1.teamPointsEarned end test "bonus points tech fall" do - endMatchWithTech(2002,"Guy2",@matches) + endMatchWithTech(2002,"Guy2") wrestler1 = Wrestler.where("name = ?", "Guy2").first assert_equal 3.5, wrestler1.teamPointsEarned end test "pool team points win" do - endMatch(2002,"Guy2",@matches) + endMatch(2002,"Guy2") wrestler1 = Wrestler.where("name = ?", "Guy2").first assert_equal 2, wrestler1.teamPointsEarned end @@ -570,19 +555,19 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest test "Championship bracket wins are 2pts" do elevenManBracketToQuarter assert_equal 7, Wrestler.where("name = ?", "Guy11").first.teamPointsEarned - matches = @matches - endMatch(4006,"Guy11",matches) + + endMatch(4006,"Guy11") assert_equal 15, Wrestler.where("name = ?", "Guy11").first.teamPointsEarned - endMatch(4007,"Guy14",matches) - endMatch(5004,"Guy11",matches) + endMatch(4007,"Guy14") + endMatch(5004,"Guy11") assert_equal 20, Wrestler.where("name = ?", "Guy11").first.teamPointsEarned end test "Conso bracket wins are 1pt" do elevenManBracketToSemis assert_equal 5, Wrestler.where("name = ?", "Guy17").first.teamPointsEarned - matches = @matches - endMatch(5006,"Guy17",matches) + + endMatch(5006,"Guy17") assert_equal 9, Wrestler.where("name = ?", "Guy17").first.teamPointsEarned end diff --git a/test/integration/single_test_test.rb b/test/integration/single_test_test.rb index 75b7ea5..3a3159e 100644 --- a/test/integration/single_test_test.rb +++ b/test/integration/single_test_test.rb @@ -1,8 +1,60 @@ require 'test_helper' class SingleTestTest < ActionDispatch::IntegrationTest + def setup + @tournament = Tournament.find(1) + # @tournament.generateMatchups + # @matches = @tournament.matches + end + + #rake test test/integration/single_test_test.rb > matches.txt + # Loser names need to be in quotes in yml file + def showMatches + # matches = Weight.where("id = ?", 4).first.matches + count = 1 + + # Yml for matches + # Match.where(tournament_id: 1).each do |m| + # puts "tournament_1_bout_#{m.bout_number}:" + # puts " tournament_id: #{m.tournament_id}" + # puts " weight_id: #{m.weight_id}" + # puts " bout_number: #{m.bout_number}" + # puts " w1: #{m.w1}" + # puts " w2: #{m.w2}" + # puts " bracket_position: #{m.bracket_position}" + # puts " bracket_position_number: #{m.bracket_position_number}" + # puts " loser1_name: #{m.loser1_name}" + # puts " loser2_name: #{m.loser2_name}" + # puts " round: #{m.round}" + # puts " mat_id: #{m.mat_id}" + # puts " finished: #{m.finished}" + # puts " w1_stat: " + # puts " w2_stat: " + # puts " score: " + # puts " winner_id: " + # puts " win_type: " + # puts "" + # count += 1 + # end + + # Yml for wrestlers + # @tournament.wrestlers.each do |w| + # puts "tournament_1_#{w.name}:" + # puts " id: #{count}" + # puts " name: #{w.name}" + # puts " school_id: #{w.school_id}" + # puts " weight_id: #{w.weight_id}" + # puts " original_seed: #{w.original_seed}" + # puts " season_loss: #{w.season_loss}" + # puts " season_win: #{w.season_win}" + # puts " criteria: #{w.criteria}" + # puts "" + # count += 1 + # end + end test "the truth" do + showMatches assert true end end diff --git a/test/models/tournament_test.rb b/test/models/tournament_test.rb index 2eb7ae9..ae89d0f 100644 --- a/test/models/tournament_test.rb +++ b/test/models/tournament_test.rb @@ -1,6 +1,7 @@ require 'test_helper' class TournamentTest < ActiveSupport::TestCase + test "the truth" do assert true end From 1fb38abf16f54051bd355594ca4669ecc9d9c2bb Mon Sep 17 00:00:00 2001 From: jcwimer Date: Sat, 26 Mar 2016 03:56:08 +0000 Subject: [PATCH 26/46] Added files to dev dockerfile --- rails-dev-Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rails-dev-Dockerfile b/rails-dev-Dockerfile index f442e13..21f3c7f 100644 --- a/rails-dev-Dockerfile +++ b/rails-dev-Dockerfile @@ -15,6 +15,8 @@ RUN bundle install --without production RUN npm install -g lineman +ADD . /rails + RUN mkdir /rails WORKDIR /rails VOLUME ["/rails"] From 8ebff0b37ad063e72343da672017123bbd542785 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Sat, 26 Mar 2016 04:10:57 +0000 Subject: [PATCH 27/46] Fixed dev dockerfile --- rails-dev-Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rails-dev-Dockerfile b/rails-dev-Dockerfile index 21f3c7f..6626f8b 100644 --- a/rails-dev-Dockerfile +++ b/rails-dev-Dockerfile @@ -15,10 +15,11 @@ RUN bundle install --without production RUN npm install -g lineman -ADD . /rails - RUN mkdir /rails WORKDIR /rails + +ADD . /rails + VOLUME ["/rails"] EXPOSE 3000 From e01fe5993a932760b53d8298adf13cb926627ad4 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Sat, 26 Mar 2016 04:15:39 +0000 Subject: [PATCH 28/46] Fixed run all tests script --- run-all-tests.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/run-all-tests.sh b/run-all-tests.sh index 80e44f5..7452d87 100755 --- a/run-all-tests.sh +++ b/run-all-tests.sh @@ -1,6 +1,2 @@ -#!/bin/bash -e - -docker build -t wrestlingdev-dev -f rails-dev-Dockerfile . - -docker run -it -v $(pwd):/rails wrestlingdev-dev bash rails-dev-db.sh -docker run -it -v $(pwd):/rails wrestlingdev-dev rake test +rake db:migrate RAILS_ENV=test +rake test \ No newline at end of file From 8f07bc2f82ac6ce6518d61a2098a9d8343eaa627 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Tue, 12 Apr 2016 21:09:57 +0000 Subject: [PATCH 29/46] Cleaned up tests --- test/integration/pool_advancement_test.rb | 33 +++++++++++------------ test/integration/single_test_test.rb | 3 --- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/test/integration/pool_advancement_test.rb b/test/integration/pool_advancement_test.rb index 3b033ac..5df311a 100644 --- a/test/integration/pool_advancement_test.rb +++ b/test/integration/pool_advancement_test.rb @@ -4,15 +4,11 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest def setup tournament = Tournament.find(1) + + # WHY DOES THIS NOT WORK WITHOUT GENERATING MATCHUPS BEFORE EVERY TEST? + # FIXTURES FOR MATCHES ARE FILLED OUT AND WORK FOR OTHER TESTS tournament.generateMatchups end - - # def showMatches - # matches = Weight.where("id = ?", 4).first.matches - # matches.each do |m| - # puts "Bout: #{m.bout_number} #{m.w1_name} vs #{m.w2_name} #{m.bracket_position} #{m.poolNumber}" - # end - # end def singlePoolNotFinished @@ -234,8 +230,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end def endMatch(bout,winner) - match = Match.where(bout_number: bout).first - # match = @matches.select{|m| m.bout_number == bout}.first + match = Match.where(bout_number: bout).first match.win_type = "Decision" match.score = 1-0 saveMatch(match,winner) @@ -286,7 +281,9 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest def saveMatch(match,winner) match.finished = 1 match.winner_id = translateNameToId(winner) - match.save + + match.save! + # match.after_update_actions end def translateNameToId(wrestler) @@ -541,15 +538,15 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest end test "Test mat assignment when adding a mat and when destroying a mat" do - @mat2 = Mat.new - @mat2.name = "2" - @mat2.tournament_id = 1 - @mat2.save - assert_equal 4, @mat2.matches.size + mat2 = Mat.new + mat2.name = "2" + mat2.tournament_id = 1 + mat2.save + assert_equal 4, mat2.matches.size elevenManBracketFinished - @mat2.destroy - @mat1 = Mat.find(1) - assert_equal 4, @mat1.matches.size + mat2.destroy + mat1 = Mat.find(1) + assert_equal 4, mat1.matches.size end test "Championship bracket wins are 2pts" do diff --git a/test/integration/single_test_test.rb b/test/integration/single_test_test.rb index 3a3159e..af56bca 100644 --- a/test/integration/single_test_test.rb +++ b/test/integration/single_test_test.rb @@ -4,13 +4,10 @@ class SingleTestTest < ActionDispatch::IntegrationTest def setup @tournament = Tournament.find(1) # @tournament.generateMatchups - # @matches = @tournament.matches end #rake test test/integration/single_test_test.rb > matches.txt - # Loser names need to be in quotes in yml file def showMatches - # matches = Weight.where("id = ?", 4).first.matches count = 1 # Yml for matches From 5b9f64b3f9c60c7f300d358556356f51ba68df59 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Tue, 12 Apr 2016 21:11:18 +0000 Subject: [PATCH 30/46] Created basic viewing pages in angular Can now search and view tournaments. Can now view team scores, weights and seeds, mats and bout board --- app/views/api/tournament.jbuilder | 44 ++++- frontend/app/js/app.js | 3 +- .../js/controllers/tournament-controller.js | 12 ++ .../tournaments-controller.js | 3 +- frontend/app/js/directives/loading.js | 24 +++ frontend/app/js/routes.js | 44 +++-- .../app/js/{ => services}/auth-service.js | 0 .../app/js/services/tournaments-service.js | 47 +++++ frontend/app/js/tournaments-service.js | 35 ---- frontend/app/pages/index.us | 12 +- frontend/app/pages/static_pages/about.html | 50 ++++++ frontend/app/pages/static_pages/home.html | 12 ++ .../app/pages/static_pages/tutorials.html | 21 +++ .../tournaments/tournaments-search.html} | 6 +- .../pages/tournaments/tournaments-show.html | 169 ++++++++++++++++++ frontend/config/files.js | 3 + 16 files changed, 423 insertions(+), 62 deletions(-) create mode 100644 frontend/app/js/controllers/tournament-controller.js rename frontend/app/js/{ => controllers}/tournaments-controller.js (91%) create mode 100644 frontend/app/js/directives/loading.js rename frontend/app/js/{ => services}/auth-service.js (100%) create mode 100644 frontend/app/js/services/tournaments-service.js delete mode 100644 frontend/app/js/tournaments-service.js create mode 100644 frontend/app/pages/static_pages/about.html create mode 100644 frontend/app/pages/static_pages/home.html create mode 100644 frontend/app/pages/static_pages/tutorials.html rename frontend/app/{templates/tournaments.html => pages/tournaments/tournaments-search.html} (82%) create mode 100644 frontend/app/pages/tournaments/tournaments-show.html diff --git a/app/views/api/tournament.jbuilder b/app/views/api/tournament.jbuilder index 171625c..9216cb7 100644 --- a/app/views/api/tournament.jbuilder +++ b/app/views/api/tournament.jbuilder @@ -1 +1,43 @@ -json.(@tournament, :id, :name, :address, :director, :director_email, :schools, :weights, :mats, :matches) \ No newline at end of file + +json.cache! ["api_tournament", @tournament] do + json.content(@tournament) + json.(@tournament, :id, :name, :address, :director, :director_email, :tournament_type, :created_at, :updated_at) + + json.schools @tournament.schools do |school| + json.name school.name + json.score school.score + end + + json.weights @tournament.weights do |weight| + json.id weight.id + json.max weight.max + json.bracket_size weight.bracket_size + json.wrestlers weight.wrestlers do |wrestler| + json.name wrestler.name + json.school wrestler.school.name + json.original_seed wrestler.original_seed + json.criteria wrestler.criteria + json.extra wrestler.extra + json.seasonWinPercentage wrestler.seasonWinPercentage + json.season_win wrestler.season_win + json.season_loss wrestler.season_loss + end + end + + json.mats @tournament.mats do |mat| + json.name mat.name + json.unfinishedMatches mat.unfinishedMatches do |match| + json.bout_number match.bout_number + json.w1_name match.w1_name + json.w2_name match.w2_name + end + end + + json.unassignedMatches @tournament.matches.select{|m| m.mat_id == nil}.sort_by{|m| m.bout_number}[0...9] do |match| + json.bout_number match.bout_number + json.w1_name match.w1_name + json.w2_name match.w2_name + json.weightClass match.weight.max + json.round match.round + end +end diff --git a/frontend/app/js/app.js b/frontend/app/js/app.js index 62abfd5..db68ef9 100644 --- a/frontend/app/js/app.js +++ b/frontend/app/js/app.js @@ -7,4 +7,5 @@ var app = angular.module("wrestlingdev", ["ngRoute"]).run(function($rootScope) $rootScope.alert = function(thing) { alert(thing); }; -}); \ No newline at end of file +}); + diff --git a/frontend/app/js/controllers/tournament-controller.js b/frontend/app/js/controllers/tournament-controller.js new file mode 100644 index 0000000..147281a --- /dev/null +++ b/frontend/app/js/controllers/tournament-controller.js @@ -0,0 +1,12 @@ +'use strict'; +app.controller("tournamentController", function($scope, tournamentsService, $routeParams) { + $scope.message = "Test message in scope."; + + // $scope.tournamentData = "test"; + tournamentsService.tournamentDetails($routeParams.id).then(function(data) { + //this will execute when the + //AJAX call completes. + $scope.tournament = data; + }); + +}); \ No newline at end of file diff --git a/frontend/app/js/tournaments-controller.js b/frontend/app/js/controllers/tournaments-controller.js similarity index 91% rename from frontend/app/js/tournaments-controller.js rename to frontend/app/js/controllers/tournaments-controller.js index 1efcb89..5054906 100644 --- a/frontend/app/js/tournaments-controller.js +++ b/frontend/app/js/controllers/tournaments-controller.js @@ -1,5 +1,6 @@ +'use strict'; + app.controller("tournamentsController", function($scope, tournamentsService) { - $scope.message = "Test message in scope."; tournamentsService.getAllTournaments().then(function(data) { //this will execute when the diff --git a/frontend/app/js/directives/loading.js b/frontend/app/js/directives/loading.js new file mode 100644 index 0000000..9635bea --- /dev/null +++ b/frontend/app/js/directives/loading.js @@ -0,0 +1,24 @@ +(function(){ + app.directive('usSpinner', ['$http', '$rootScope' ,function ($http, $rootScope){ + return { + link: function (scope, elm, attrs) + { + $rootScope.spinnerActive = false; + scope.isLoading = function () { + return $http.pendingRequests.length > 0; + }; + + scope.$watch(scope.isLoading, function (loading) + { + $rootScope.spinnerActive = loading; + if(loading){ + elm.removeClass('ng-hide'); + }else{ + elm.addClass('ng-hide'); + } + }); + } + }; + + }]); +}).call(this); \ No newline at end of file diff --git a/frontend/app/js/routes.js b/frontend/app/js/routes.js index 1b2f71b..2c97620 100644 --- a/frontend/app/js/routes.js +++ b/frontend/app/js/routes.js @@ -13,18 +13,32 @@ -app.config(['$routeProvider', - function($routeProvider) { - $routeProvider. - when('/tournaments', { - templateUrl: 'tournaments.html', - controller: 'tournamentsController' - }). - // when('/phones/:phoneId', { - // templateUrl: 'partials/phone-detail.html', - // controller: 'PhoneDetailCtrl' - // }). - otherwise({ - redirectTo: '/tournaments' - }); - }]); \ No newline at end of file +app.config(['$routeProvider', '$locationProvider', function($routeProvider,$locationProvider) { + + $routeProvider.when('/', { + templateUrl: 'home.html', + }); + + $routeProvider.when('/tournaments', { + templateUrl: 'tournaments-search.html', + controller: 'tournamentsController' + }); + + $routeProvider.when('/tournaments/:id', { + templateUrl: 'tournaments-show.html', + controller: 'tournamentController' + }); + + $routeProvider.when('/about', { + templateUrl: 'about.html', + }); + + $routeProvider.when('/tutorials', { + templateUrl: 'tutorials.html', + }); + + $routeProvider.otherwise({redirectTo: '/'}); + + //this give me normal routes instead of /#/ + $locationProvider.html5Mode(true); +}]); \ No newline at end of file diff --git a/frontend/app/js/auth-service.js b/frontend/app/js/services/auth-service.js similarity index 100% rename from frontend/app/js/auth-service.js rename to frontend/app/js/services/auth-service.js diff --git a/frontend/app/js/services/tournaments-service.js b/frontend/app/js/services/tournaments-service.js new file mode 100644 index 0000000..9e1083d --- /dev/null +++ b/frontend/app/js/services/tournaments-service.js @@ -0,0 +1,47 @@ + +app.factory('tournamentsService', tournamentsService); + +function tournamentsService($http){ + var service = {}; + + + + service.getAllTournaments = function(){ + return $http({ + url: '/api/tournaments/', + method: "GET" + }).then(successResponse, errorCallback); + }; + + service.searchTournaments = function(search){ + return $http({ + method: 'GET', + url: '/api/tournaments/', + params: { + search: search + } + }).then(successResponse, errorCallback); + }; + + service.tournamentDetails = function(tournamentId){ + return $http({ + url: '/api/tournaments/' + tournamentId, + method: "GET" + }).then(successResponse, errorCallback); + }; + + function successResponse(response){ + console.log("success log below"); + console.log(response); + return response.data; + } + + function errorCallback(err){ + console.log("error log below"); + console.log(err); + return err; + } + + return service; +} + diff --git a/frontend/app/js/tournaments-service.js b/frontend/app/js/tournaments-service.js deleted file mode 100644 index 4e426bd..0000000 --- a/frontend/app/js/tournaments-service.js +++ /dev/null @@ -1,35 +0,0 @@ -app.factory('tournamentsService', function($http){ - - - return { - getAllTournaments: function() { - //since $http.get returns a promise, - //and promise.then() also returns a promise - //that resolves to whatever value is returned in it's - //callback argument, we can return that. - return $http.get('/api/tournaments/').then(function(result) { - return result.data; - }); - }, - - searchTournaments: function(search){ - return $http({ - method: 'GET', - url: '/api/tournaments/', - params: { - search: search - } - }).then(function successCallback(response) { - // this callback will be called asynchronously - // when the response is available - return response.data; - }, function errorCallback(response) { - // called asynchronously if an error occurs - // or server returns response with an error status. - return response; - }); - } - }; - -}); - diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index 0e2a372..bf9c532 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -1,6 +1,7 @@ + WrestlingDev @@ -9,6 +10,8 @@ +
+
-
+
+
diff --git a/frontend/app/pages/static_pages/about.html b/frontend/app/pages/static_pages/about.html new file mode 100644 index 0000000..b4b7506 --- /dev/null +++ b/frontend/app/pages/static_pages/about.html @@ -0,0 +1,50 @@ +
+
+

About WrestlingDev

+
+

WrestlingDev was created to help bring wrestling into the 21st century for free. This site is open source and is supported by the ads on the sidebar.

+
+

Features

+
+

At this moment in time, WrestlingDev supports a pool to bracket type tournament for up to 16 teams. The bracket format follows OHSAA's 5 match per day rule. WrestlingDev will automatically generate brackets, generate bout numbers, generate and update a bout board, track team points, and update brackets.

+

For pool to bracket tournaments, pool tie breakers are the following:

+
    +
  • Least team points deducted
  • +
  • Head to head
  • +
  • Most team points scored
  • +
  • Most wins by fall, default, dq
  • +
  • Most wins by tech fall
  • +
  • Most wins by major
  • +
  • Most points scored in decisions
  • +
  • Quickest pin
  • +
  • Coin flip
  • +
+

If three wrestlers are tied, they will be put through this sequence until two wrestlers are left. Once two wrestlers are left, the pool runner up will be decided by head to head.

+

For pool to bracket tournaments, team points will be calculated as follows:

+
    +
  • Pool win: 2pt
  • +
  • Win in championship bracket: 2pt
  • +
  • Win in consolation bracket: 1pt
  • +
  • Win by major: 1pt extra
  • +
  • Win by tech fall: 1.5pt extra
  • +
  • Win by fall, default, dq: 2pt extra
  • +
  • 1st place: 16pt
  • +
  • 2nd place: 12pt
  • +
  • 3rd place: 10pt
  • +
  • 4th place: 9pt
  • +
  • 5th place: 7pt
  • +
  • 6th place: 6pt
  • +
  • 7th place: 4pt
  • +
  • 8th place: 3pt
  • +
+

Finals matches will only recieve extra placement points for placing higher and bonus points for pin, tech, major, etc. Please note, only brackets with four pools place up to 8. Brackets with 1 or 2 pools only place top 4.

+
+

Future Plans

+
+

Future development plans to support normal double elimination brackets are underway and are planned to be finished in time for the 2016-2017 wrestling season.

+
+

Contact

+
+

Suggestions, criticism, and kind words are welcomed. Please contact us.

+
+
\ No newline at end of file diff --git a/frontend/app/pages/static_pages/home.html b/frontend/app/pages/static_pages/home.html new file mode 100644 index 0000000..861983e --- /dev/null +++ b/frontend/app/pages/static_pages/home.html @@ -0,0 +1,12 @@ +
+
+

Welcome to WrestlingDev

+
+

This website was created to help wrestling coaches run their tournaments. It is 2015, why are we still running bout sheets to tables and why are we still using resources to push cards on a bout board? This website was created as a free way for coaches to run a tournament smoothly with as few workers as possible.

+
+

If you would like to run a tournament, please click log in and then click sign up.

+
+Browse Tournaments +

+
+
\ No newline at end of file diff --git a/frontend/app/pages/static_pages/tutorials.html b/frontend/app/pages/static_pages/tutorials.html new file mode 100644 index 0000000..05004b0 --- /dev/null +++ b/frontend/app/pages/static_pages/tutorials.html @@ -0,0 +1,21 @@ +
+
+

Tutorials

+
+

Unfortunately, I do not have tutorials available at this moment in time. If you would like to learn how to use this software, please email me at jacob.wimer@gmail.com and I will gladly provide an overview of how to use this software. I've done my best to make the software intuitive and easy to use.

+
+

Planning on using this software?

+
+

Here is a list of features available:

+
+
    +
  • Pool to bracket type bracket generation for up to 16 man brackets
  • +
  • Delegate control to coaches for lineup entry
  • +
  • Automatically updated bout board
  • +
  • Automatically updated brackets
  • +
  • Automatically updated team scores
  • +
  • Delegate director privileges to multiple people for tournament administration
  • +
  • Matches can be scored at the tables and submitted via computer or bout sheets can be brought to the head table and entered there
  • +
+
+
\ No newline at end of file diff --git a/frontend/app/templates/tournaments.html b/frontend/app/pages/tournaments/tournaments-search.html similarity index 82% rename from frontend/app/templates/tournaments.html rename to frontend/app/pages/tournaments/tournaments-search.html index d8fab1f..52d8282 100644 --- a/frontend/app/templates/tournaments.html +++ b/frontend/app/pages/tournaments/tournaments-search.html @@ -1,5 +1,3 @@ -
-

Upcoming Tournaments


@@ -20,10 +18,8 @@ - {{ tournament.name }} + {{ tournament.name }} {{ tournament.date }} -
-
\ No newline at end of file diff --git a/frontend/app/pages/tournaments/tournaments-show.html b/frontend/app/pages/tournaments/tournaments-show.html new file mode 100644 index 0000000..601d787 --- /dev/null +++ b/frontend/app/pages/tournaments/tournaments-show.html @@ -0,0 +1,169 @@ + Back to browse tournaments +

+ {{ tournament.name }} +

+

+ Address: + {{ tournament.address }} +

+

+ Director: + {{ tournament.director }} +

+

+ Director email: + {{ tournament.director_email }} +

+

+ Tournament Type: + {{ tournament.tournament_type }} +

+
+
+ +
+
+ + + + + + + + + + + + + + + +
NameScore
{{ school.name }}{{ school.score }}
+
+
+
+ +
+ +
+
+

Click weight class for seeds

+
+ + + + + + + + + + + + + + +
Weight ClassBracket Size
{{ weight.max }}{{ weight.bracket_size }}
+
+
+
+ +
+ +
+
+ + + + + + + + + + + + + + + + + + + + +
NameOn MatOn DeckIn The HoleWarm Up
{{ mat.name }}{{ mat.unfinishedMatches[0].bout_number }} {{ mat.unfinishedMatches[0].w1_name }} vs. {{ mat.unfinishedMatches[0].w2_name }}{{ mat.unfinishedMatches[1].bout_number }} {{ mat.unfinishedMatches[0].w1_name }} vs. {{ mat.unfinishedMatches[0].w2_name }}{{ mat.unfinishedMatches[2].bout_number }} {{ mat.unfinishedMatches[0].w1_name }} vs. {{ mat.unfinishedMatches[0].w2_name }}{{ mat.unfinishedMatches[3].bout_number }} {{ mat.unfinishedMatches[0].w1_name }} vs. {{ mat.unfinishedMatches[0].w2_name }}
+
+

Matches not assigned

+
+ + + + + + + + + + + + + + + + + + +
RoundBout NumberWeight ClassMatchup
Round {{ match.round }}{{ match.bout_number }}{{ match.weightClass }}{{ match.w1_name }} vs. {{ match.w2_name }}
+
+
+
+ + +
+ +
+ + + + + diff --git a/frontend/config/files.js b/frontend/config/files.js index a64ab32..255275a 100644 --- a/frontend/config/files.js +++ b/frontend/config/files.js @@ -18,6 +18,9 @@ module.exports = function(lineman) { // "vendor/js/**/*.js" // ] // } + + //Override file patterns here + }; }; From 84578d89dad59a6e3b0ca61698a34aec9c9321d7 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Tue, 26 Apr 2016 01:14:15 +0000 Subject: [PATCH 31/46] Added frontend pages and trying to model wrestlers on frontend --- app/views/api/tournament.jbuilder | 15 +++++ .../js/controllers/tournament-controller.js | 5 +- frontend/app/js/models/wrestler.js | 19 ++++++ .../app/js/services/tournaments-service.js | 4 +- frontend/app/pages/index.us | 61 +++++++++++-------- frontend/app/pages/static_pages/about.html | 4 +- frontend/app/pages/static_pages/home.html | 4 +- .../app/pages/static_pages/tutorials.html | 4 +- .../pages/tournaments/tournaments-show.html | 3 +- 9 files changed, 79 insertions(+), 40 deletions(-) create mode 100644 frontend/app/js/models/wrestler.js diff --git a/app/views/api/tournament.jbuilder b/app/views/api/tournament.jbuilder index 9216cb7..3241efb 100644 --- a/app/views/api/tournament.jbuilder +++ b/app/views/api/tournament.jbuilder @@ -13,6 +13,7 @@ json.cache! ["api_tournament", @tournament] do json.max weight.max json.bracket_size weight.bracket_size json.wrestlers weight.wrestlers do |wrestler| + json.id wrestler.id json.name wrestler.name json.school wrestler.school.name json.original_seed wrestler.original_seed @@ -27,6 +28,8 @@ json.cache! ["api_tournament", @tournament] do json.mats @tournament.mats do |mat| json.name mat.name json.unfinishedMatches mat.unfinishedMatches do |match| + json.w1 = match.w1 + json.w2 = match.w2 json.bout_number match.bout_number json.w1_name match.w1_name json.w2_name match.w2_name @@ -39,5 +42,17 @@ json.cache! ["api_tournament", @tournament] do json.w2_name match.w2_name json.weightClass match.weight.max json.round match.round + json.w1 = match.w1 + json.w2 = match.w2 + end + + json.matches @tournament.matches do |match| + json.bout_number match.bout_number + json.w1_name match.w1_name + json.w2_name match.w2_name + json.weightClass match.weight.max + json.round match.round + json.w1 = match.w1 + json.w2 = match.w2 end end diff --git a/frontend/app/js/controllers/tournament-controller.js b/frontend/app/js/controllers/tournament-controller.js index 147281a..8c09a41 100644 --- a/frontend/app/js/controllers/tournament-controller.js +++ b/frontend/app/js/controllers/tournament-controller.js @@ -1,5 +1,5 @@ 'use strict'; -app.controller("tournamentController", function($scope, tournamentsService, $routeParams) { +app.controller("tournamentController", function($scope, tournamentsService, $routeParams, Wrestler) { $scope.message = "Test message in scope."; // $scope.tournamentData = "test"; @@ -9,4 +9,7 @@ app.controller("tournamentController", function($scope, tournamentsService, $rou $scope.tournament = data; }); + $scope.wrestler = Wrestler; + + }); \ No newline at end of file diff --git a/frontend/app/js/models/wrestler.js b/frontend/app/js/models/wrestler.js new file mode 100644 index 0000000..4f45c5e --- /dev/null +++ b/frontend/app/js/models/wrestler.js @@ -0,0 +1,19 @@ +'use strict'; + +app.factory('Wrestler', function Wrestler(){ + var vm = this; + + + vm.matches = function(matches,wrestler){ + var givenWrestler = wrestler; + + console.log(givenWrestler.id); + return _.filter(matches, function(match){ + return match.w1 == givenWrestler.id || match.w2 == givenWrestler.id; + }); + + + } + + return vm; +}); \ No newline at end of file diff --git a/frontend/app/js/services/tournaments-service.js b/frontend/app/js/services/tournaments-service.js index 9e1083d..0ac1a3f 100644 --- a/frontend/app/js/services/tournaments-service.js +++ b/frontend/app/js/services/tournaments-service.js @@ -31,8 +31,8 @@ function tournamentsService($http){ }; function successResponse(response){ - console.log("success log below"); - console.log(response); + // console.log("success log below"); + // console.log(response); return response.data; } diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index bf9c532..8ed5e16 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -10,41 +10,44 @@ -
- - +
+ + +
- +
- -
+
+
+
- +
-
+ +
@@ -62,8 +65,12 @@ + + + + diff --git a/frontend/app/pages/static_pages/about.html b/frontend/app/pages/static_pages/about.html index b4b7506..0e48f2a 100644 --- a/frontend/app/pages/static_pages/about.html +++ b/frontend/app/pages/static_pages/about.html @@ -1,5 +1,4 @@ -
-
+

About WrestlingDev


WrestlingDev was created to help bring wrestling into the 21st century for free. This site is open source and is supported by the ads on the sidebar.

@@ -47,4 +46,3 @@

Suggestions, criticism, and kind words are welcomed. Please contact us.

-
\ No newline at end of file diff --git a/frontend/app/pages/static_pages/home.html b/frontend/app/pages/static_pages/home.html index 861983e..ff9797e 100644 --- a/frontend/app/pages/static_pages/home.html +++ b/frontend/app/pages/static_pages/home.html @@ -1,5 +1,4 @@ -
-
+

Welcome to WrestlingDev


This website was created to help wrestling coaches run their tournaments. It is 2015, why are we still running bout sheets to tables and why are we still using resources to push cards on a bout board? This website was created as a free way for coaches to run a tournament smoothly with as few workers as possible.

@@ -9,4 +8,3 @@ Browse Tournaments

-
\ No newline at end of file diff --git a/frontend/app/pages/static_pages/tutorials.html b/frontend/app/pages/static_pages/tutorials.html index 05004b0..2124843 100644 --- a/frontend/app/pages/static_pages/tutorials.html +++ b/frontend/app/pages/static_pages/tutorials.html @@ -1,5 +1,4 @@ -
-
+

Tutorials


Unfortunately, I do not have tutorials available at this moment in time. If you would like to learn how to use this software, please email me at jacob.wimer@gmail.com and I will gladly provide an overview of how to use this software. I've done my best to make the software intuitive and easy to use.

@@ -18,4 +17,3 @@
  • Matches can be scored at the tables and submitted via computer or bout sheets can be brought to the head table and entered there
  • -
    \ No newline at end of file diff --git a/frontend/app/pages/tournaments/tournaments-show.html b/frontend/app/pages/tournaments/tournaments-show.html index 601d787..071fb0b 100644 --- a/frontend/app/pages/tournaments/tournaments-show.html +++ b/frontend/app/pages/tournaments/tournaments-show.html @@ -1,7 +1,9 @@ + Back to browse tournaments

    {{ tournament.name }}

    +

    {{ wrestler.matches(tournament.matches,tournament.weights[0].wrestlers[0]) }}

    Address: {{ tournament.address }} @@ -166,4 +168,3 @@ - From 425e7f5fc5644f3a6db4fdaf2cbeb9f96edf8874 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 28 Apr 2016 01:13:58 +0000 Subject: [PATCH 32/46] Frontend authentication working. --- app/controllers/application_controller.rb | 13 +++++ app/views/api/tournament.jbuilder | 10 ++-- app/views/layouts/_cdn.html.erb | 2 +- config/application.rb | 4 ++ frontend/app/js/app.js | 2 +- .../app/js/controllers/login-controller.js | 51 +++++++++++++++++++ .../js/controllers/tournament-controller.js | 39 +++++++++++++- frontend/app/js/models/wrestler.js | 9 ++-- frontend/app/js/routes.js | 2 +- frontend/app/js/services/auth-service.js | 49 ------------------ .../app/js/services/tournaments-service.js | 4 +- frontend/app/pages/index.us | 33 +++++++++--- frontend/app/pages/static_pages/home.html | 2 +- .../pages/tournaments/tournaments-search.html | 2 +- .../pages/tournaments/tournaments-show.html | 27 ++++++---- frontend/config/application.js | 3 +- frontend/vendor/js/devise-min.js | 10 ++++ test/integration/single_test_test.rb | 2 +- 18 files changed, 175 insertions(+), 89 deletions(-) create mode 100644 frontend/app/js/controllers/login-controller.js delete mode 100644 frontend/app/js/services/auth-service.js create mode 100644 frontend/vendor/js/devise-min.js diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5540030..a9f6dc6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,8 +3,21 @@ class ApplicationController < ActionController::Base # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception + after_filter :set_csrf_cookie_for_ng + + def set_csrf_cookie_for_ng + cookies['XSRF-TOKEN'] = form_authenticity_token if protect_against_forgery? + end + rescue_from CanCan::AccessDenied do |exception| # flash[:error] = "Access denied!" redirect_to '/static_pages/not_allowed' end + + protected + + # In Rails 4.2 and above + def verified_request? + super || valid_authenticity_token?(session, request.headers['X-XSRF-TOKEN']) + end end diff --git a/app/views/api/tournament.jbuilder b/app/views/api/tournament.jbuilder index 3241efb..09fe7aa 100644 --- a/app/views/api/tournament.jbuilder +++ b/app/views/api/tournament.jbuilder @@ -1,7 +1,7 @@ json.cache! ["api_tournament", @tournament] do json.content(@tournament) - json.(@tournament, :id, :name, :address, :director, :director_email, :tournament_type, :created_at, :updated_at) + json.(@tournament, :id, :name, :address, :director, :director_email, :tournament_type, :created_at, :updated_at, :user_id) json.schools @tournament.schools do |school| json.name school.name @@ -28,8 +28,6 @@ json.cache! ["api_tournament", @tournament] do json.mats @tournament.mats do |mat| json.name mat.name json.unfinishedMatches mat.unfinishedMatches do |match| - json.w1 = match.w1 - json.w2 = match.w2 json.bout_number match.bout_number json.w1_name match.w1_name json.w2_name match.w2_name @@ -42,8 +40,6 @@ json.cache! ["api_tournament", @tournament] do json.w2_name match.w2_name json.weightClass match.weight.max json.round match.round - json.w1 = match.w1 - json.w2 = match.w2 end json.matches @tournament.matches do |match| @@ -52,7 +48,7 @@ json.cache! ["api_tournament", @tournament] do json.w2_name match.w2_name json.weightClass match.weight.max json.round match.round - json.w1 = match.w1 - json.w2 = match.w2 + json.w1 match.w1 + json.w2 match.w2 end end diff --git a/app/views/layouts/_cdn.html.erb b/app/views/layouts/_cdn.html.erb index 70538f0..f923e78 100644 --- a/app/views/layouts/_cdn.html.erb +++ b/app/views/layouts/_cdn.html.erb @@ -9,7 +9,7 @@ - + diff --git a/config/application.rb b/config/application.rb index d8037e7..786352b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -30,6 +30,10 @@ module Wrestling config.active_job.queue_adapter = :delayed_job config.rails_lineman.lineman_project_location = "frontend" + + config.to_prepare do + DeviseController.respond_to :html, :json + end end diff --git a/frontend/app/js/app.js b/frontend/app/js/app.js index db68ef9..395e7c2 100644 --- a/frontend/app/js/app.js +++ b/frontend/app/js/app.js @@ -1,4 +1,4 @@ -var app = angular.module("wrestlingdev", ["ngRoute"]).run(function($rootScope) { +var app = angular.module("wrestlingdev", ["ngRoute","Devise"]).run(function($rootScope) { // adds some basic utilities to the $rootScope for debugging purposes $rootScope.log = function(thing) { console.log(thing); diff --git a/frontend/app/js/controllers/login-controller.js b/frontend/app/js/controllers/login-controller.js new file mode 100644 index 0000000..c316d8b --- /dev/null +++ b/frontend/app/js/controllers/login-controller.js @@ -0,0 +1,51 @@ +'use strict'; +app.controller("loginController", function($scope, $routeParams, Auth, $rootScope) { + $scope.credentials = { + email: '', + password: '' + }; + + var config = { + headers: { + 'X-HTTP-Method-Override': 'POST' + } + }; + + + $scope.login = function(){ + Auth.login($scope.credentials, config).then(function(user) { + console.log(user); // => {id: 1, ect: '...'} + $rootScope.user = user; + $rootScope.alertClass = "alert alert-success"; + $rootScope.alertMessage = "Logged in successfully"; + }, function(error) { + console.log(error); + $rootScope.alertClass = "alert alert-danger"; + $rootScope.alertMessage = "Username and/or password is incorrect"; + }); + }; + + $scope.logout = function(){ + Auth.logout(config).then(function(oldUser) { + // alert(oldUser.name + "you're signed out now."); + $rootScope.user = null; + $rootScope.alertClass = "alert alert-success"; + $rootScope.alertMessage = "Logged out successfully"; + }, function(error) { + // An error occurred logging out. + $rootScope.alertClass = "alert alert-danger"; + $rootScope.alertMessage = "There was an error logging out"; + }); + }; + + Auth.currentUser().then(function(user) { + // User was logged in, or Devise returned + // previously authenticated session. + $rootScope.user = user; + }, function(error) { + // unauthenticated error + $rootScope.user = null; + }); + + +}); \ No newline at end of file diff --git a/frontend/app/js/controllers/tournament-controller.js b/frontend/app/js/controllers/tournament-controller.js index 8c09a41..21816bd 100644 --- a/frontend/app/js/controllers/tournament-controller.js +++ b/frontend/app/js/controllers/tournament-controller.js @@ -1,7 +1,8 @@ 'use strict'; -app.controller("tournamentController", function($scope, tournamentsService, $routeParams, Wrestler) { +app.controller("tournamentController", function($scope, tournamentsService, $routeParams, Wrestler, Auth, $rootScope) { $scope.message = "Test message in scope."; + // $scope.tournamentData = "test"; tournamentsService.tournamentDetails($routeParams.id).then(function(data) { //this will execute when the @@ -9,7 +10,43 @@ app.controller("tournamentController", function($scope, tournamentsService, $rou $scope.tournament = data; }); + // refresh tournament data every 10 seconds + // setInterval(function(){ + // tournamentsService.tournamentDetails($routeParams.id).then(function(data) { + // //this will execute when the + // //AJAX call completes. + // $scope.tournament = data; + // }); + // }, 10000); + $scope.wrestler = Wrestler; + $scope.showSchools = false; + + $scope.toggleSchools = function(){ + $scope.showSchools = !$scope.showSchools; + }; + + $scope.showWeightSeeds = false; + + $scope.toggleWeightSeeds = function(){ + $scope.showWeightSeeds = !$scope.showWeightSeeds; + }; + + $scope.showBoutBoard = false; + + $scope.toggleBoutBoard = function(){ + $scope.showBoutBoard = !$scope.showBoutBoard; + }; + + $scope.isTournamentOwner = function(tournamentId,userId){ + if(userId == tournamentId){ + return true; + } else { + return false; + } + }; + + }); \ No newline at end of file diff --git a/frontend/app/js/models/wrestler.js b/frontend/app/js/models/wrestler.js index 4f45c5e..30c2c89 100644 --- a/frontend/app/js/models/wrestler.js +++ b/frontend/app/js/models/wrestler.js @@ -4,16 +4,15 @@ app.factory('Wrestler', function Wrestler(){ var vm = this; - vm.matches = function(matches,wrestler){ - var givenWrestler = wrestler; + vm.matches = function(wrestler,matches){ - console.log(givenWrestler.id); + console.log(matches); return _.filter(matches, function(match){ - return match.w1 == givenWrestler.id || match.w2 == givenWrestler.id; + return match.w1 == wrestler.id || match.w2 == wrestler.id; }); - } + }; return vm; }); \ No newline at end of file diff --git a/frontend/app/js/routes.js b/frontend/app/js/routes.js index 2c97620..194d2f6 100644 --- a/frontend/app/js/routes.js +++ b/frontend/app/js/routes.js @@ -40,5 +40,5 @@ app.config(['$routeProvider', '$locationProvider', function($routeProvider,$loca $routeProvider.otherwise({redirectTo: '/'}); //this give me normal routes instead of /#/ - $locationProvider.html5Mode(true); + // $locationProvider.html5Mode(true); }]); \ No newline at end of file diff --git a/frontend/app/js/services/auth-service.js b/frontend/app/js/services/auth-service.js deleted file mode 100644 index db0c7d9..0000000 --- a/frontend/app/js/services/auth-service.js +++ /dev/null @@ -1,49 +0,0 @@ -app.factory('AuthenticationService', - ['Base64', '$http', '$cookieStore', '$rootScope', '$timeout', - function (Base64, $http, $cookieStore, $rootScope, $timeout) { - var service = {}; - - service.Login = function (username, password, callback) { - - /* Dummy authentication for testing, uses $timeout to simulate api call - ----------------------------------------------*/ - // $timeout(function(){ - // var response = { success: username === 'test' && password === 'test' }; - // if(!response.success) { - // response.message = 'Username or password is incorrect'; - // } - // callback(response); - // }, 1000); - - - /* Use this for real authentication - ----------------------------------------------*/ - $http.post('/api/authenticate', { username: username, password: password }) - .success(function (response) { - callback(response); - }); - - }; - - service.SetCredentials = function (username, password) { - var authdata = Base64.encode(username + ':' + password); - - $rootScope.globals = { - currentUser: { - username: username, - authdata: authdata - } - }; - - $http.defaults.headers.common['Authorization'] = 'Basic ' + authdata; // jshint ignore:line - $cookieStore.put('globals', $rootScope.globals); - }; - - service.ClearCredentials = function () { - $rootScope.globals = {}; - $cookieStore.remove('globals'); - $http.defaults.headers.common.Authorization = 'Basic '; - }; - - return service; - }]); \ No newline at end of file diff --git a/frontend/app/js/services/tournaments-service.js b/frontend/app/js/services/tournaments-service.js index 0ac1a3f..36d2a02 100644 --- a/frontend/app/js/services/tournaments-service.js +++ b/frontend/app/js/services/tournaments-service.js @@ -37,8 +37,8 @@ function tournamentsService($http){ } function errorCallback(err){ - console.log("error log below"); - console.log(err); + // console.log("error log below"); + // console.log(err); return err; } diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index 8ed5e16..213c950 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -1,7 +1,7 @@ - + WrestlingDev @@ -21,13 +21,30 @@ - WrestlingDev + WrestlingDev

    @@ -35,6 +52,10 @@
    +
    + + {{alertMessage}} +
    @@ -66,7 +87,7 @@ - + diff --git a/frontend/app/pages/static_pages/home.html b/frontend/app/pages/static_pages/home.html index ff9797e..adea8bd 100644 --- a/frontend/app/pages/static_pages/home.html +++ b/frontend/app/pages/static_pages/home.html @@ -5,6 +5,6 @@

    If you would like to run a tournament, please click log in and then click sign up.


    -Browse Tournaments +Browse Tournaments

    diff --git a/frontend/app/pages/tournaments/tournaments-search.html b/frontend/app/pages/tournaments/tournaments-search.html index 52d8282..4afdaa8 100644 --- a/frontend/app/pages/tournaments/tournaments-search.html +++ b/frontend/app/pages/tournaments/tournaments-search.html @@ -18,7 +18,7 @@ - {{ tournament.name }} + {{ tournament.name }} {{ tournament.date }} diff --git a/frontend/app/pages/tournaments/tournaments-show.html b/frontend/app/pages/tournaments/tournaments-show.html index 071fb0b..957890d 100644 --- a/frontend/app/pages/tournaments/tournaments-show.html +++ b/frontend/app/pages/tournaments/tournaments-show.html @@ -1,9 +1,8 @@ - Back to browse tournaments + Back to browse tournaments

    {{ tournament.name }}

    -

    {{ wrestler.matches(tournament.matches,tournament.weights[0].wrestlers[0]) }}

    Address: {{ tournament.address }} @@ -22,16 +21,19 @@


    - +

    School Lineups and Team Scores +

    -
    +
    + + @@ -40,6 +42,7 @@ +
    Name ScoreActions
    {{ school.name }} {{ school.score }}
    @@ -48,10 +51,11 @@
    - +

    Weights and Seeds +

    -
    +

    Click weight class for seeds


    @@ -75,10 +79,11 @@
    - +

    Mats and Bout Board +

    -
    +
    diff --git a/frontend/config/application.js b/frontend/config/application.js index 88b807f..6a7ddf8 100644 --- a/frontend/config/application.js +++ b/frontend/config/application.js @@ -26,8 +26,7 @@ module.exports = function(lineman) { apiProxy: { enabled: true, host: 'localhost', - port: 8080, - prefix: 'api' + port: 8080 }, web: { port: 8081 diff --git a/frontend/vendor/js/devise-min.js b/frontend/vendor/js/devise-min.js new file mode 100644 index 0000000..97a577f --- /dev/null +++ b/frontend/vendor/js/devise-min.js @@ -0,0 +1,10 @@ +// AngularDevise +// ------------------- +// v1.2.1 +// +// Copyright (c)2016 Justin Ridgewell +// Distributed under MIT license +// +// https://github.com/cloudspace/angular_devise + +!function(a){"use strict";var b=a.module("Devise",[]);b.provider("AuthIntercept",function(){var a=!1;this.interceptAuth=function(b){return a=!!b||void 0===b,this},this.$get=["$rootScope","$q",function(b,c){return{responseError:function(d){var e=d.config.interceptAuth;if(e=!!e||a&&void 0===e,e&&401===d.status){var f=c.defer();return b.$broadcast("devise:unauthorized",d,f),f.reject(d),f.promise}return c.reject(d)}}}]}).config(["$httpProvider",function(a){a.interceptors.push("AuthIntercept")}]),b.provider("Auth",function(){function b(b,c,d){var h={method:f[b].toLowerCase(),url:e[b]};return c&&(g?(h.data={},h.data[g]=c):h.data=c),a.extend(h,d),h}function c(b,c){a.forEach(b,function(a,d){this[d+c]=function(a){return void 0===a?b[d]:(b[d]=a,this)}},this)}function d(a){return function(){return a}}var e={login:"/users/sign_in.json",logout:"/users/sign_out.json",register:"/users.json",sendResetPasswordInstructions:"/users/password.json",resetPassword:"/users/password.json"},f={login:"POST",logout:"DELETE",register:"POST",sendResetPasswordInstructions:"POST",resetPassword:"PUT"},g="user",h=function(a){return a.data};c.call(this,f,"Method"),c.call(this,e,"Path"),this.resourceName=function(a){return void 0===a?g:(g=a,this)},this.parse=function(a){return"function"!=typeof a?h:(h=a,this)},this.$get=["$q","$http","$rootScope",function(a,c,e){function f(a){return j._currentUser=a,a}function g(){f(null),j._promise=null}function i(a){return function(b){return e.$broadcast("devise:"+a,b),b}}var j={_currentUser:null,parse:h,_promise:null,reset:function(){g(),j.currentUser()},login:function(a,d){var e=arguments.length>0,g=j.isAuthenticated();return a=a||{},c(b("login",a,d)).then(j.parse).then(f).then(function(a){return e&&!g?i("new-session")(a):a}).then(i("login"))},logout:function(a){var e=d(j._currentUser);return c(b("logout",void 0,a)).then(g).then(e).then(i("logout"))},register:function(a,d){return a=a||{},c(b("register",a,d)).then(j.parse).then(f).then(i("new-registration"))},sendResetPasswordInstructions:function(a){return a=a||{},c(b("sendResetPasswordInstructions",a)).then(j.parse).then(i("send-reset-password-instructions-successfully"))},resetPassword:function(a){return a=a||{},c(b("resetPassword",a)).then(j.parse).then(f).then(i("reset-password-successfully"))},currentUser:function(){return j.isAuthenticated()?a.when(j._currentUser):(null===j._promise&&(j._promise=j.login()),j._promise)},isAuthenticated:function(){return!!j._currentUser}};return j}]})}(angular); \ No newline at end of file diff --git a/test/integration/single_test_test.rb b/test/integration/single_test_test.rb index af56bca..32a5519 100644 --- a/test/integration/single_test_test.rb +++ b/test/integration/single_test_test.rb @@ -37,11 +37,11 @@ class SingleTestTest < ActionDispatch::IntegrationTest # Yml for wrestlers # @tournament.wrestlers.each do |w| # puts "tournament_1_#{w.name}:" - # puts " id: #{count}" # puts " name: #{w.name}" # puts " school_id: #{w.school_id}" # puts " weight_id: #{w.weight_id}" # puts " original_seed: #{w.original_seed}" + # puts " seed: #{w.seed}" # puts " season_loss: #{w.season_loss}" # puts " season_win: #{w.season_win}" # puts " criteria: #{w.criteria}" From 07ac335c7c6d805953d1879f00d13d6821c81578 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 28 Apr 2016 01:25:06 +0000 Subject: [PATCH 33/46] Fixed a few static pages on frontend --- frontend/app/pages/static_pages/about.html | 2 -- frontend/app/pages/static_pages/tutorials.html | 2 -- 2 files changed, 4 deletions(-) diff --git a/frontend/app/pages/static_pages/about.html b/frontend/app/pages/static_pages/about.html index 0e48f2a..f56e695 100644 --- a/frontend/app/pages/static_pages/about.html +++ b/frontend/app/pages/static_pages/about.html @@ -1,4 +1,3 @@ -

    About WrestlingDev


    WrestlingDev was created to help bring wrestling into the 21st century for free. This site is open source and is supported by the ads on the sidebar.

    @@ -45,4 +44,3 @@

    Contact


    Suggestions, criticism, and kind words are welcomed. Please contact us.

    -
    diff --git a/frontend/app/pages/static_pages/tutorials.html b/frontend/app/pages/static_pages/tutorials.html index 2124843..70f5141 100644 --- a/frontend/app/pages/static_pages/tutorials.html +++ b/frontend/app/pages/static_pages/tutorials.html @@ -1,4 +1,3 @@ -

    Tutorials


    Unfortunately, I do not have tutorials available at this moment in time. If you would like to learn how to use this software, please email me at jacob.wimer@gmail.com and I will gladly provide an overview of how to use this software. I've done my best to make the software intuitive and easy to use.

    @@ -16,4 +15,3 @@
  • Delegate director privileges to multiple people for tournament administration
  • Matches can be scored at the tables and submitted via computer or bout sheets can be brought to the head table and entered there
  • -
    From 84d48bbee3b1c99979fe5071f00fe78a8c539077 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 28 Apr 2016 01:58:48 +0000 Subject: [PATCH 34/46] Made login form look better and made user menu look better. --- app/controllers/api_controller.rb | 4 ++++ app/views/api/currentUserTournaments.jbuilder | 3 +++ config/routes.rb | 1 + frontend/app/js/controllers/my-tournaments.js | 11 +++++++++ frontend/app/js/routes.js | 5 ++++ .../app/js/services/tournaments-service.js | 7 +++++- frontend/app/pages/index.us | 23 ++++++++++--------- .../app/pages/tournaments/my-tournaments.html | 17 ++++++++++++++ 8 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 app/views/api/currentUserTournaments.jbuilder create mode 100644 frontend/app/js/controllers/my-tournaments.js create mode 100644 frontend/app/pages/tournaments/my-tournaments.html diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 679c84f..4b58505 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -21,4 +21,8 @@ class ApiController < ApplicationController @tournament = Tournament.new(JSON.parse(params[:tournament])) @tournament.save end + + def currentUserTournaments + @tournaments = current_user.tournaments + end end diff --git a/app/views/api/currentUserTournaments.jbuilder b/app/views/api/currentUserTournaments.jbuilder new file mode 100644 index 0000000..c9f6ee7 --- /dev/null +++ b/app/views/api/currentUserTournaments.jbuilder @@ -0,0 +1,3 @@ +json.array!(@tournaments) do |tournament| + json.extract! tournament, :id, :name, :address, :director, :director_email, :date +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 30007fe..94cc729 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -54,6 +54,7 @@ Wrestling::Application.routes.draw do #API get "/api/tournaments" => "api#tournaments" + get "/api/tournaments/user" => "api#currentUserTournaments" get "/api/tournaments/:tournament" => "api#tournament" get "/api/index" => "api#index" post "/api/tournaments/new" => "newTournament" diff --git a/frontend/app/js/controllers/my-tournaments.js b/frontend/app/js/controllers/my-tournaments.js new file mode 100644 index 0000000..567374b --- /dev/null +++ b/frontend/app/js/controllers/my-tournaments.js @@ -0,0 +1,11 @@ +'use strict'; + +app.controller("myTournamentsController", function($scope, tournamentsService, $rootScope) { + + tournamentsService.getMyTournaments().then(function(data) { + //this will execute when the + //AJAX call completes. + $scope.allTournaments = data; + }); + +}); \ No newline at end of file diff --git a/frontend/app/js/routes.js b/frontend/app/js/routes.js index 194d2f6..84ba476 100644 --- a/frontend/app/js/routes.js +++ b/frontend/app/js/routes.js @@ -24,6 +24,11 @@ app.config(['$routeProvider', '$locationProvider', function($routeProvider,$loca controller: 'tournamentsController' }); + $routeProvider.when('/tournaments/user', { + templateUrl: 'my-tournaments.html', + controller: 'myTournamentsController' + }); + $routeProvider.when('/tournaments/:id', { templateUrl: 'tournaments-show.html', controller: 'tournamentController' diff --git a/frontend/app/js/services/tournaments-service.js b/frontend/app/js/services/tournaments-service.js index 36d2a02..ecba5fa 100644 --- a/frontend/app/js/services/tournaments-service.js +++ b/frontend/app/js/services/tournaments-service.js @@ -4,7 +4,12 @@ app.factory('tournamentsService', tournamentsService); function tournamentsService($http){ var service = {}; - + service.getMyTournaments = function(user){ + return $http({ + url: '/api/tournaments/user/', + method: "GET" + }).then(successResponse, errorCallback); + }; service.getAllTournaments = function(){ return $http({ diff --git a/frontend/app/pages/index.us b/frontend/app/pages/index.us index 213c950..902d9da 100644 --- a/frontend/app/pages/index.us +++ b/frontend/app/pages/index.us @@ -28,22 +28,23 @@
  • Browse Tournaments
  • About
  • Tutorials
  • - diff --git a/frontend/app/pages/tournaments/my-tournaments.html b/frontend/app/pages/tournaments/my-tournaments.html new file mode 100644 index 0000000..9038c29 --- /dev/null +++ b/frontend/app/pages/tournaments/my-tournaments.html @@ -0,0 +1,17 @@ +

    My Tournaments

    +
    + +
    + + + + + + + + + + + + +
    NameDate
    {{ tournament.name }}{{ tournament.date }}
    From 365959778075c7c9174dcc20909321650021aa29 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Sat, 30 Apr 2016 00:55:34 +0000 Subject: [PATCH 35/46] CRUD finished for Schools on frontend --- app/views/api/tournament.jbuilder | 1 + .../js/controllers/tournament-controller.js | 34 +++++++++++ .../app/js/services/tournaments-service.js | 51 +++++++++++++++- .../pages/tournaments/tournaments-show.html | 59 +++++++++++++++++-- 4 files changed, 138 insertions(+), 7 deletions(-) diff --git a/app/views/api/tournament.jbuilder b/app/views/api/tournament.jbuilder index 09fe7aa..1027761 100644 --- a/app/views/api/tournament.jbuilder +++ b/app/views/api/tournament.jbuilder @@ -4,6 +4,7 @@ json.cache! ["api_tournament", @tournament] do json.(@tournament, :id, :name, :address, :director, :director_email, :tournament_type, :created_at, :updated_at, :user_id) json.schools @tournament.schools do |school| + json.id school.id json.name school.name json.score school.score end diff --git a/frontend/app/js/controllers/tournament-controller.js b/frontend/app/js/controllers/tournament-controller.js index 21816bd..3871072 100644 --- a/frontend/app/js/controllers/tournament-controller.js +++ b/frontend/app/js/controllers/tournament-controller.js @@ -10,6 +10,14 @@ app.controller("tournamentController", function($scope, tournamentsService, $rou $scope.tournament = data; }); + $scope.refreshTournamentData = function(){ + tournamentsService.tournamentDetails($routeParams.id).then(function(data) { + //this will execute when the + //AJAX call completes. + $scope.tournament = data; + }); + }; + // refresh tournament data every 10 seconds // setInterval(function(){ // tournamentsService.tournamentDetails($routeParams.id).then(function(data) { @@ -33,6 +41,7 @@ app.controller("tournamentController", function($scope, tournamentsService, $rou $scope.showWeightSeeds = !$scope.showWeightSeeds; }; + $scope.showBoutBoard = false; $scope.toggleBoutBoard = function(){ @@ -48,5 +57,30 @@ app.controller("tournamentController", function($scope, tournamentsService, $rou } }; + + $scope.newSchool = null; + + $scope.saveNewSchool = function(){ + $scope.newSchool.tournament_id = $scope.tournament.id; + tournamentsService.saveNewSchool($scope.newSchool).then(function(data) { + $scope.tournament.schools.push(data); + }); + $scope.newSchool = null; + $('#NewSchool').modal('hide'); + }; + + $scope.deleteSchool = function(school){ + if (confirm('Are you sure you want to delete ' + school.name + '?')) { + tournamentsService.deleteSchool(school).then(function(data) { + $scope.tournament.schools.splice( $scope.tournament.schools.indexOf(school), 1 ); + }); + } + }; + + $scope.updateSchool = function(school){ + tournamentsService.updateSchool(school); + $('#EditSchool' + school.id).modal('hide'); + }; + }); \ No newline at end of file diff --git a/frontend/app/js/services/tournaments-service.js b/frontend/app/js/services/tournaments-service.js index ecba5fa..4f5db46 100644 --- a/frontend/app/js/services/tournaments-service.js +++ b/frontend/app/js/services/tournaments-service.js @@ -1,7 +1,7 @@ app.factory('tournamentsService', tournamentsService); -function tournamentsService($http){ +function tournamentsService($http,$rootScope){ var service = {}; service.getMyTournaments = function(user){ @@ -34,16 +34,65 @@ function tournamentsService($http){ method: "GET" }).then(successResponse, errorCallback); }; + + service.saveNewSchool = function(newSchool){ + return $http({ + url: '/schools.json', + method: "POST", + + data: { + school: { + 'name': newSchool.name, + 'tournament_id': newSchool.tournament_id + } + }, + headers: { + "Content-Type": "application/json" + } + }).then(successResponse, errorCallback); + }; + + service.deleteSchool = function(school){ + return $http({ + url: '/schools/' + school.id + '/', + method: "DELETE" + }).then(successResponse, errorCallback); + }; + + service.updateSchool = function(schoolToEdit){ + return $http({ + url: '/schools/' + schoolToEdit.id, + method: "PATCH", + data: { + school: { + 'name': schoolToEdit.name, + 'tournament_id': schoolToEdit.tournament_id + } + }, + headers: { + "Content-Type": "application/json" + } + }).then(successResponse, errorCallback); + }; function successResponse(response){ // console.log("success log below"); // console.log(response); + if(response.config.method == "POST" || response.config.method == "DELETE" || response.config.method == "PATCH"){ + $rootScope.alertClass = "alert alert-success"; + $rootScope.alertMessage = response.statusText; + } return response.data; } function errorCallback(err){ // console.log("error log below"); // console.log(err); + if(err.status > 0){ + $rootScope.alertClass = "alert alert-danger"; + $rootScope.alertMessage = err.statusText; + } + return err; } diff --git a/frontend/app/pages/tournaments/tournaments-show.html b/frontend/app/pages/tournaments/tournaments-show.html index 957890d..a0f2403 100644 --- a/frontend/app/pages/tournaments/tournaments-show.html +++ b/frontend/app/pages/tournaments/tournaments-show.html @@ -27,7 +27,7 @@
    - + @@ -42,7 +42,10 @@ - +
    {{ school.name }} {{ school.score }} + + +
    @@ -85,7 +88,8 @@
    - +

    Matches have not been generated

    +
    @@ -107,9 +111,9 @@
    Name

    -

    Matches not assigned

    +

    Matches not assigned


    - +
    @@ -132,7 +136,7 @@ - +
    + + + + + +
    + +
    + From a763c966d158d336b7bae5c50540c397762b0b1c Mon Sep 17 00:00:00 2001 From: jcwimer Date: Sat, 7 May 2016 02:06:11 +0000 Subject: [PATCH 36/46] Sped up tests and updated Pool Order --- app/models/pool_order.rb | 33 +- test/fixtures/matches.yml | 3282 ++++++++++----------- test/fixtures/wrestlers.yml | 214 +- test/integration/pool_advancement_test.rb | 2 +- test/integration/single_test_test.rb | 4 +- 5 files changed, 1809 insertions(+), 1726 deletions(-) diff --git a/app/models/pool_order.rb b/app/models/pool_order.rb index f88b934..a03eebe 100644 --- a/app/models/pool_order.rb +++ b/app/models/pool_order.rb @@ -109,21 +109,26 @@ class PoolOrder end def fastestPin - timeArray = [] - wrestlersWithSamePoints.each do |w| - timeArray << w.fastestPin + wrestlersWithSamePointsWithPins = [] + wrestlersWithSamePoints.each do |wr| + if wr.pinWins.size > 0 + wrestlersWithSamePointsWithPins << wr + end end - fastest = timeArray.max - wrestlersWithFastestPin = wrestlersWithSamePoints.select{|w| w.fastestPin == fastest} - addPointsToWrestlersAhead(wrestlersWithFastestPin.first) - wrestlersWithFastestPin.each do |wr| - addPoints(wr) - end - secondFastest = timeArray.sort[-2] - wrestlersWithSecondFastestPin = wrestlersWithSamePoints.select{|w| w.fastestPin == secondFastest} - addPointsToWrestlersAhead(wrestlersWithSecondFastestPin.first) - wrestlersWithSecondFastestPin.each do |wr| - addPoints(wr) + if wrestlersWithSamePointsWithPins.size > 0 + fastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.fastestPin.pinTime}.first.fastestPin + secondFastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.fastestPin.pinTime}.second.fastestPin + wrestlersWithFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastestPin.pinTime == fastest.pinTime} + addPointsToWrestlersAhead(wrestlersWithFastestPin.first) + wrestlersWithFastestPin.each do |wr| + addPoints(wr) + end + + wrestlersWithSecondFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastestPin.pinTime == secondFastest.pinTime} + addPointsToWrestlersAhead(wrestlersWithSecondFastestPin.first) + wrestlersWithSecondFastestPin.each do |wr| + addPoints(wr) + end end end diff --git a/test/fixtures/matches.yml b/test/fixtures/matches.yml index 09e08a5..7e31d38 100644 --- a/test/fixtures/matches.yml +++ b/test/fixtures/matches.yml @@ -1,115 +1,9 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -# http://chriskottom.com/blog/2014/11/fixing-fixtures/ - # t.integer "w1" - # t.integer "w2" - # t.text "w1_stat" - # t.text "w2_stat" - # t.integer "winner_id" - # t.string "win_type" - # t.string "score" - # t.datetime "created_at" - # t.datetime "updated_at" - # t.integer "tournament_id" - # t.integer "round" - # t.integer "finished" - # t.integer "bout_number" - # t.integer "weight_id" - # t.string "bracket_position" - # t.integer "bracket_position_number" - # t.string "loser1_name" - # t.string "loser2_name" - # t.integer "mat_id" - - -# default: &default -# tournament_id: 1 - - -# one: -# <<: *defaults - -tournament_1_bout_3007: - tournament_id: 1 - weight_id: 2 - bout_number: 3007 - w1: 10 - w2: 7 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6000: - tournament_id: 1 - weight_id: 3 - bout_number: 6000 - w1: - w2: - bracket_position: 1/2 - bracket_position_number: 1 - loser1_name: Winner Pool 1 - loser2_name: Winner Pool 2 - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3013: - tournament_id: 1 - weight_id: 5 - bout_number: 3013 - w1: 39 - w2: 35 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4001: +tournament_1_bout_1000: tournament_id: 1 weight_id: 1 - bout_number: 4001 - w1: 1 - w2: 5 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1002: - tournament_id: 1 - weight_id: 3 - bout_number: 1002 - w1: 18 - w2: 19 + bout_number: 1000 + w1: 2 + w2: 1 bracket_position: Pool bracket_position_number: loser1_name: @@ -123,18 +17,18 @@ tournament_1_bout_1002: winner_id: win_type: -tournament_1_bout_3002: +tournament_1_bout_1001: tournament_id: 1 - weight_id: 3 - bout_number: 3002 - w1: 19 - w2: 21 + weight_id: 1 + bout_number: 1001 + w1: 3 + w2: 4 bracket_position: Pool bracket_position_number: loser1_name: loser2_name: - round: 3 - mat_id: + round: 1 + mat_id: 1 finished: w1_stat: w2_stat: @@ -142,12 +36,12 @@ tournament_1_bout_3002: winner_id: win_type: -tournament_1_bout_2021: +tournament_1_bout_2000: tournament_id: 1 - weight_id: 6 - bout_number: 2021 - w1: 50 - w2: 51 + weight_id: 1 + bout_number: 2000 + w1: 5 + w2: 4 bracket_position: Pool bracket_position_number: loser1_name: @@ -161,177 +55,6 @@ tournament_1_bout_2021: winner_id: win_type: -tournament_1_bout_1007: - tournament_id: 1 - weight_id: 2 - bout_number: 1007 - w1: 11 - w2: 10 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2004: - tournament_id: 1 - weight_id: 3 - bout_number: 2004 - w1: 16 - w2: 14 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1011: - tournament_id: 1 - weight_id: 4 - bout_number: 1011 - w1: 25 - w2: 32 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4004: - tournament_id: 1 - weight_id: 2 - bout_number: 4004 - w1: - w2: - bracket_position: Semis - bracket_position_number: 1 - loser1_name: Winner Pool 1 - loser2_name: Runner Up Pool 2 - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4014: - tournament_id: 1 - weight_id: 6 - bout_number: 4014 - w1: 49 - w2: 50 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6002: - tournament_id: 1 - weight_id: 2 - bout_number: 6002 - w1: - w2: - bracket_position: 1/2 - bracket_position_number: 1 - loser1_name: - loser2_name: - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4007: - tournament_id: 1 - weight_id: 4 - bout_number: 4007 - w1: - w2: - bracket_position: Quarter - bracket_position_number: 2 - loser1_name: Winner Pool 4 - loser2_name: Runner Up Pool 3 - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4013: - tournament_id: 1 - weight_id: 5 - bout_number: 4013 - w1: - w2: - bracket_position: Conso Semis - bracket_position_number: 2 - loser1_name: Runner Up Pool 2 - loser2_name: Runner Up Pool 3 - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1019: - tournament_id: 1 - weight_id: 5 - bout_number: 1019 - w1: 38 - w2: 48 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - tournament_1_bout_2001: tournament_id: 1 weight_id: 1 @@ -351,848 +74,12 @@ tournament_1_bout_2001: winner_id: win_type: -tournament_1_bout_1017: - tournament_id: 1 - weight_id: 5 - bout_number: 1017 - w1: 34 - w2: 47 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1014: - tournament_id: 1 - weight_id: 5 - bout_number: 1014 - w1: 45 - w2: 39 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6011: - tournament_id: 1 - weight_id: 5 - bout_number: 6011 - w1: - w2: - bracket_position: 7/8 - bracket_position_number: 1 - loser1_name: Loser of 4012 - loser2_name: Loser of 4013 - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3018: - tournament_id: 1 - weight_id: 5 - bout_number: 3018 - w1: 40 - w2: 48 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2014: - tournament_id: 1 - weight_id: 5 - bout_number: 2014 - w1: 37 - w2: 33 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6005: - tournament_id: 1 - weight_id: 4 - bout_number: 6005 - w1: - w2: - bracket_position: 3/4 - bracket_position_number: 1 - loser1_name: Loser of 5004 - loser2_name: Loser of 5005 - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_5002: - tournament_id: 1 - weight_id: 3 - bout_number: 5002 - w1: 21 - w2: 13 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 5 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3009: - tournament_id: 1 - weight_id: 4 - bout_number: 3009 - w1: 27 - w2: 30 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_5005: - tournament_id: 1 - weight_id: 4 - bout_number: 5005 - w1: - w2: - bracket_position: Semis - bracket_position_number: 2 - loser1_name: - loser2_name: - round: 5 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3021: - tournament_id: 1 - weight_id: 6 - bout_number: 3021 - w1: 52 - w2: 50 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2009: - tournament_id: 1 - weight_id: 4 - bout_number: 2009 - w1: 30 - w2: 28 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3011: - tournament_id: 1 - weight_id: 4 - bout_number: 3011 - w1: 32 - w2: 24 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6001: - tournament_id: 1 - weight_id: 3 - bout_number: 6001 - w1: - w2: - bracket_position: 3/4 - bracket_position_number: 1 - loser1_name: Runner Up Pool 1 - loser2_name: Runner Up Pool 2 - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6008: - tournament_id: 1 - weight_id: 5 - bout_number: 6008 - w1: - w2: - bracket_position: 1/2 - bracket_position_number: 1 - loser1_name: - loser2_name: - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3017: - tournament_id: 1 - weight_id: 5 - bout_number: 3017 - w1: 41 - w2: 34 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4000: +tournament_1_bout_3000: tournament_id: 1 weight_id: 1 - bout_number: 4000 - w1: 4 - w2: 2 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3015: - tournament_id: 1 - weight_id: 5 - bout_number: 3015 - w1: 37 - w2: 44 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2012: - tournament_id: 1 - weight_id: 5 - bout_number: 2012 - w1: 39 - w2: 46 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2000: - tournament_id: 1 - weight_id: 1 - bout_number: 2000 - w1: 5 - w2: 4 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1021: - tournament_id: 1 - weight_id: 6 - bout_number: 1021 - w1: 50 - w2: 53 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2019: - tournament_id: 1 - weight_id: 5 - bout_number: 2019 - w1: 38 - w2: 40 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1016: - tournament_id: 1 - weight_id: 5 - bout_number: 1016 - w1: 36 - w2: 37 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6006: - tournament_id: 1 - weight_id: 4 - bout_number: 6006 - w1: - w2: - bracket_position: 5/6 - bracket_position_number: 1 - loser1_name: - loser2_name: - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_5009: - tournament_id: 1 - weight_id: 6 - bout_number: 5009 - w1: 49 - w2: 53 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 5 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3010: - tournament_id: 1 - weight_id: 4 - bout_number: 3010 - w1: 22 - w2: 31 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4008: - tournament_id: 1 - weight_id: 4 - bout_number: 4008 - w1: - w2: - bracket_position: Quarter - bracket_position_number: 3 - loser1_name: Winner Pool 2 - loser2_name: Runner Up Pool 1 - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3008: - tournament_id: 1 - weight_id: 2 - bout_number: 3008 - w1: 6 - w2: 9 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2005: - tournament_id: 1 - weight_id: 3 - bout_number: 2005 - w1: 17 - w2: 15 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1003: - tournament_id: 1 - weight_id: 3 - bout_number: 1003 - w1: 21 - w2: 20 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: 1 - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2017: - tournament_id: 1 - weight_id: 5 - bout_number: 2017 - w1: 34 - w2: 43 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4011: - tournament_id: 1 - weight_id: 5 - bout_number: 4011 - w1: - w2: - bracket_position: Semis - bracket_position_number: 2 - loser1_name: Winner Pool 2 - loser2_name: Winner Pool 3 - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3003: - tournament_id: 1 - weight_id: 3 - bout_number: 3003 - w1: 13 - w2: 18 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_5006: - tournament_id: 1 - weight_id: 4 - bout_number: 5006 - w1: - w2: - bracket_position: Conso Semis - bracket_position_number: 1 - loser1_name: Loser of 4006 - loser2_name: Loser of 4007 - round: 5 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3006: - tournament_id: 1 - weight_id: 2 - bout_number: 3006 - w1: 11 - w2: 12 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_5003: - tournament_id: 1 - weight_id: 3 - bout_number: 5003 - w1: 20 - w2: 19 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 5 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_5008: - tournament_id: 1 - weight_id: 6 - bout_number: 5008 - w1: 51 - w2: 52 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 5 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2010: - tournament_id: 1 - weight_id: 4 - bout_number: 2010 - w1: 31 - w2: 23 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4009: - tournament_id: 1 - weight_id: 4 - bout_number: 4009 - w1: - w2: - bracket_position: Quarter - bracket_position_number: 4 - loser1_name: Winner Pool 3 - loser2_name: Runner Up Pool 4 - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1001: - tournament_id: 1 - weight_id: 1 - bout_number: 1001 - w1: 3 - w2: 4 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: 1 - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1022: - tournament_id: 1 - weight_id: 6 - bout_number: 1022 - w1: 51 - w2: 49 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2018: - tournament_id: 1 - weight_id: 5 - bout_number: 2018 - w1: 42 - w2: 48 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1015: - tournament_id: 1 - weight_id: 5 - bout_number: 1015 - w1: 44 - w2: 33 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6007: - tournament_id: 1 - weight_id: 4 - bout_number: 6007 - w1: - w2: - bracket_position: 7/8 - bracket_position_number: 1 - loser1_name: Loser of 5006 - loser2_name: Loser of 5007 - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6009: - tournament_id: 1 - weight_id: 5 - bout_number: 6009 - w1: - w2: - bracket_position: 3/4 - bracket_position_number: 1 - loser1_name: Loser of 4010 - loser2_name: Loser of 4011 - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3016: - tournament_id: 1 - weight_id: 5 - bout_number: 3016 - w1: 43 - w2: 47 + bout_number: 3000 + w1: 1 + w2: 3 bracket_position: Pool bracket_position_number: loser1_name: @@ -1225,17 +112,17 @@ tournament_1_bout_3001: winner_id: win_type: -tournament_1_bout_3014: +tournament_1_bout_4000: tournament_id: 1 - weight_id: 5 - bout_number: 3014 - w1: 36 - w2: 33 + weight_id: 1 + bout_number: 4000 + w1: 4 + w2: 2 bracket_position: Pool bracket_position_number: loser1_name: loser2_name: - round: 3 + round: 4 mat_id: finished: w1_stat: @@ -1244,17 +131,17 @@ tournament_1_bout_3014: winner_id: win_type: -tournament_1_bout_2013: +tournament_1_bout_4001: tournament_id: 1 - weight_id: 5 - bout_number: 2013 - w1: 35 - w2: 45 + weight_id: 1 + bout_number: 4001 + w1: 1 + w2: 5 bracket_position: Pool bracket_position_number: loser1_name: loser2_name: - round: 2 + round: 4 mat_id: finished: w1_stat: @@ -1263,130 +150,16 @@ tournament_1_bout_2013: winner_id: win_type: -tournament_1_bout_1006: +tournament_1_bout_5000: tournament_id: 1 - weight_id: 2 - bout_number: 1006 - w1: 7 - w2: 12 + weight_id: 1 + bout_number: 5000 + w1: 3 + w2: 5 bracket_position: Pool bracket_position_number: loser1_name: loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3020: - tournament_id: 1 - weight_id: 6 - bout_number: 3020 - w1: 53 - w2: 51 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1009: - tournament_id: 1 - weight_id: 4 - bout_number: 1009 - w1: 28 - w2: 27 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1012: - tournament_id: 1 - weight_id: 4 - bout_number: 1012 - w1: 26 - w2: 29 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2007: - tournament_id: 1 - weight_id: 2 - bout_number: 2007 - w1: 7 - w2: 11 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1004: - tournament_id: 1 - weight_id: 3 - bout_number: 1004 - w1: 17 - w2: 14 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_5007: - tournament_id: 1 - weight_id: 4 - bout_number: 5007 - w1: - w2: - bracket_position: Conso Semis - bracket_position_number: 2 - loser1_name: Loser of 4008 - loser2_name: Loser of 4009 round: 5 mat_id: finished: @@ -1396,18 +169,37 @@ tournament_1_bout_5007: winner_id: win_type: -tournament_1_bout_4002: +tournament_1_bout_5001: + tournament_id: 1 + weight_id: 1 + bout_number: 5001 + w1: 4 + w2: 1 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1002: tournament_id: 1 weight_id: 3 - bout_number: 4002 - w1: 20 - w2: 18 + bout_number: 1002 + w1: 18 + w2: 19 bracket_position: Pool bracket_position_number: loser1_name: loser2_name: - round: 4 - mat_id: + round: 1 + mat_id: 1 finished: w1_stat: w2_stat: @@ -1415,37 +207,18 @@ tournament_1_bout_4002: winner_id: win_type: -tournament_1_bout_4010: +tournament_1_bout_1003: tournament_id: 1 - weight_id: 5 - bout_number: 4010 - w1: - w2: - bracket_position: Semis - bracket_position_number: 1 - loser1_name: Winner Pool 1 - loser2_name: Winner Pool 4 - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2016: - tournament_id: 1 - weight_id: 5 - bout_number: 2016 - w1: 41 - w2: 47 + weight_id: 3 + bout_number: 1003 + w1: 21 + w2: 20 bracket_position: Pool bracket_position_number: loser1_name: loser2_name: - round: 2 - mat_id: + round: 1 + mat_id: 1 finished: w1_stat: w2_stat: @@ -1472,120 +245,6 @@ tournament_1_bout_2002: winner_id: win_type: -tournament_1_bout_2008: - tournament_id: 1 - weight_id: 2 - bout_number: 2008 - w1: 9 - w2: 8 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3004: - tournament_id: 1 - weight_id: 3 - bout_number: 3004 - w1: 15 - w2: 14 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2011: - tournament_id: 1 - weight_id: 4 - bout_number: 2011 - w1: 24 - w2: 25 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2006: - tournament_id: 1 - weight_id: 2 - bout_number: 2006 - w1: 10 - w2: 12 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1005: - tournament_id: 1 - weight_id: 3 - bout_number: 1005 - w1: 15 - w2: 16 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2020: - tournament_id: 1 - weight_id: 6 - bout_number: 2020 - w1: 52 - w2: 49 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 2 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - tournament_1_bout_2003: tournament_id: 1 weight_id: 3 @@ -1605,31 +264,12 @@ tournament_1_bout_2003: winner_id: win_type: -tournament_1_bout_5001: +tournament_1_bout_3002: tournament_id: 1 - weight_id: 1 - bout_number: 5001 - w1: 4 - w2: 1 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 5 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3012: - tournament_id: 1 - weight_id: 5 - bout_number: 3012 - w1: 45 - w2: 46 + weight_id: 3 + bout_number: 3002 + w1: 19 + w2: 21 bracket_position: Pool bracket_position_number: loser1_name: @@ -1643,12 +283,69 @@ tournament_1_bout_3012: winner_id: win_type: -tournament_1_bout_5000: +tournament_1_bout_3003: tournament_id: 1 - weight_id: 1 - bout_number: 5000 - w1: 3 - w2: 5 + weight_id: 3 + bout_number: 3003 + w1: 13 + w2: 18 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4002: + tournament_id: 1 + weight_id: 3 + bout_number: 4002 + w1: 20 + w2: 18 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4003: + tournament_id: 1 + weight_id: 3 + bout_number: 4003 + w1: 19 + w2: 13 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5002: + tournament_id: 1 + weight_id: 3 + bout_number: 5002 + w1: 21 + w2: 13 bracket_position: Pool bracket_position_number: loser1_name: @@ -1662,6 +359,291 @@ tournament_1_bout_5000: winner_id: win_type: +tournament_1_bout_5003: + tournament_id: 1 + weight_id: 3 + bout_number: 5003 + w1: 20 + w2: 19 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1004: + tournament_id: 1 + weight_id: 3 + bout_number: 1004 + w1: 17 + w2: 14 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1005: + tournament_id: 1 + weight_id: 3 + bout_number: 1005 + w1: 15 + w2: 16 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2004: + tournament_id: 1 + weight_id: 3 + bout_number: 2004 + w1: 16 + w2: 14 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2005: + tournament_id: 1 + weight_id: 3 + bout_number: 2005 + w1: 17 + w2: 15 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3004: + tournament_id: 1 + weight_id: 3 + bout_number: 3004 + w1: 15 + w2: 14 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3005: + tournament_id: 1 + weight_id: 3 + bout_number: 3005 + w1: 16 + w2: 17 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6000: + tournament_id: 1 + weight_id: 3 + bout_number: 6000 + w1: + w2: + bracket_position: 1/2 + bracket_position_number: 1 + loser1_name: Winner Pool 1 + loser2_name: Winner Pool 2 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6001: + tournament_id: 1 + weight_id: 3 + bout_number: 6001 + w1: + w2: + bracket_position: 3/4 + bracket_position_number: 1 + loser1_name: Runner Up Pool 1 + loser2_name: Runner Up Pool 2 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1006: + tournament_id: 1 + weight_id: 2 + bout_number: 1006 + w1: 7 + w2: 12 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1007: + tournament_id: 1 + weight_id: 2 + bout_number: 1007 + w1: 11 + w2: 10 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2006: + tournament_id: 1 + weight_id: 2 + bout_number: 2006 + w1: 10 + w2: 12 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2007: + tournament_id: 1 + weight_id: 2 + bout_number: 2007 + w1: 7 + w2: 11 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3006: + tournament_id: 1 + weight_id: 2 + bout_number: 3006 + w1: 11 + w2: 12 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3007: + tournament_id: 1 + weight_id: 2 + bout_number: 3007 + w1: 10 + w2: 7 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + tournament_1_bout_1008: tournament_id: 1 weight_id: 2 @@ -1681,12 +663,164 @@ tournament_1_bout_1008: winner_id: win_type: -tournament_1_bout_3005: +tournament_1_bout_2008: tournament_id: 1 - weight_id: 3 - bout_number: 3005 - w1: 16 - w2: 17 + weight_id: 2 + bout_number: 2008 + w1: 9 + w2: 8 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3008: + tournament_id: 1 + weight_id: 2 + bout_number: 3008 + w1: 6 + w2: 9 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4004: + tournament_id: 1 + weight_id: 2 + bout_number: 4004 + w1: + w2: + bracket_position: Semis + bracket_position_number: 1 + loser1_name: Winner Pool 1 + loser2_name: Runner Up Pool 2 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4005: + tournament_id: 1 + weight_id: 2 + bout_number: 4005 + w1: + w2: + bracket_position: Semis + bracket_position_number: 2 + loser1_name: Winner Pool 2 + loser2_name: Runner Up Pool 1 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6002: + tournament_id: 1 + weight_id: 2 + bout_number: 6002 + w1: + w2: + bracket_position: 1/2 + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6003: + tournament_id: 1 + weight_id: 2 + bout_number: 6003 + w1: + w2: + bracket_position: 3/4 + bracket_position_number: 1 + loser1_name: Loser of 4004 + loser2_name: Loser of 4005 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1009: + tournament_id: 1 + weight_id: 4 + bout_number: 1009 + w1: 28 + w2: 27 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2009: + tournament_id: 1 + weight_id: 4 + bout_number: 2009 + w1: 30 + w2: 28 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3009: + tournament_id: 1 + weight_id: 4 + bout_number: 3009 + w1: 27 + w2: 30 bracket_position: Pool bracket_position_number: loser1_name: @@ -1719,107 +853,12 @@ tournament_1_bout_1010: winner_id: win_type: -tournament_1_bout_5004: +tournament_1_bout_2010: tournament_id: 1 weight_id: 4 - bout_number: 5004 - w1: - w2: - bracket_position: Semis - bracket_position_number: 1 - loser1_name: - loser2_name: - round: 5 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4003: - tournament_id: 1 - weight_id: 3 - bout_number: 4003 - w1: 19 - w2: 13 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1000: - tournament_id: 1 - weight_id: 1 - bout_number: 1000 - w1: 2 - w2: 1 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: 1 - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6010: - tournament_id: 1 - weight_id: 5 - bout_number: 6010 - w1: - w2: - bracket_position: 5/6 - bracket_position_number: 1 - loser1_name: - loser2_name: - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3019: - tournament_id: 1 - weight_id: 5 - bout_number: 3019 - w1: 42 - w2: 38 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 3 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_2015: - tournament_id: 1 - weight_id: 5 - bout_number: 2015 - w1: 44 - w2: 36 + bout_number: 2010 + w1: 31 + w2: 23 bracket_position: Pool bracket_position_number: loser1_name: @@ -1833,69 +872,12 @@ tournament_1_bout_2015: winner_id: win_type: -tournament_1_bout_6004: +tournament_1_bout_3010: tournament_id: 1 weight_id: 4 - bout_number: 6004 - w1: - w2: - bracket_position: 1/2 - bracket_position_number: 1 - loser1_name: - loser2_name: - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_4012: - tournament_id: 1 - weight_id: 5 - bout_number: 4012 - w1: - w2: - bracket_position: Conso Semis - bracket_position_number: 1 - loser1_name: Runner Up Pool 1 - loser2_name: Runner Up Pool 4 - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_1020: - tournament_id: 1 - weight_id: 5 - bout_number: 1020 - w1: 40 - w2: 42 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 1 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_3000: - tournament_id: 1 - weight_id: 1 - bout_number: 3000 - w1: 1 - w2: 3 + bout_number: 3010 + w1: 22 + w2: 31 bracket_position: Pool bracket_position_number: loser1_name: @@ -1909,12 +891,12 @@ tournament_1_bout_3000: winner_id: win_type: -tournament_1_bout_1018: +tournament_1_bout_1011: tournament_id: 1 - weight_id: 5 - bout_number: 1018 - w1: 43 - w2: 41 + weight_id: 4 + bout_number: 1011 + w1: 25 + w2: 32 bracket_position: Pool bracket_position_number: loser1_name: @@ -1928,12 +910,50 @@ tournament_1_bout_1018: winner_id: win_type: -tournament_1_bout_1013: +tournament_1_bout_2011: tournament_id: 1 - weight_id: 5 - bout_number: 1013 - w1: 35 - w2: 46 + weight_id: 4 + bout_number: 2011 + w1: 24 + w2: 25 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3011: + tournament_id: 1 + weight_id: 4 + bout_number: 3011 + w1: 32 + w2: 24 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1012: + tournament_id: 1 + weight_id: 4 + bout_number: 1012 + w1: 26 + w2: 29 bracket_position: Pool bracket_position_number: loser1_name: @@ -1947,44 +967,6 @@ tournament_1_bout_1013: winner_id: win_type: -tournament_1_bout_4015: - tournament_id: 1 - weight_id: 6 - bout_number: 4015 - w1: 53 - w2: 52 - bracket_position: Pool - bracket_position_number: - loser1_name: - loser2_name: - round: 4 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - -tournament_1_bout_6003: - tournament_id: 1 - weight_id: 2 - bout_number: 6003 - w1: - w2: - bracket_position: 3/4 - bracket_position_number: 1 - loser1_name: Loser of 4004 - loser2_name: Loser of 4005 - round: 6 - mat_id: - finished: - w1_stat: - w2_stat: - score: - winner_id: - win_type: - tournament_1_bout_4006: tournament_id: 1 weight_id: 4 @@ -2004,14 +986,33 @@ tournament_1_bout_4006: winner_id: win_type: -tournament_1_bout_4005: +tournament_1_bout_4007: tournament_id: 1 - weight_id: 2 - bout_number: 4005 + weight_id: 4 + bout_number: 4007 w1: w2: - bracket_position: Semis + bracket_position: Quarter bracket_position_number: 2 + loser1_name: Winner Pool 4 + loser2_name: Runner Up Pool 3 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4008: + tournament_id: 1 + weight_id: 4 + bout_number: 4008 + w1: + w2: + bracket_position: Quarter + bracket_position_number: 3 loser1_name: Winner Pool 2 loser2_name: Runner Up Pool 1 round: 4 @@ -2022,3 +1023,972 @@ tournament_1_bout_4005: score: winner_id: win_type: + +tournament_1_bout_4009: + tournament_id: 1 + weight_id: 4 + bout_number: 4009 + w1: + w2: + bracket_position: Quarter + bracket_position_number: 4 + loser1_name: Winner Pool 3 + loser2_name: Runner Up Pool 4 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5004: + tournament_id: 1 + weight_id: 4 + bout_number: 5004 + w1: + w2: + bracket_position: Semis + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5005: + tournament_id: 1 + weight_id: 4 + bout_number: 5005 + w1: + w2: + bracket_position: Semis + bracket_position_number: 2 + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5006: + tournament_id: 1 + weight_id: 4 + bout_number: 5006 + w1: + w2: + bracket_position: Conso Semis + bracket_position_number: 1 + loser1_name: Loser of 4006 + loser2_name: Loser of 4007 + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5007: + tournament_id: 1 + weight_id: 4 + bout_number: 5007 + w1: + w2: + bracket_position: Conso Semis + bracket_position_number: 2 + loser1_name: Loser of 4008 + loser2_name: Loser of 4009 + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6004: + tournament_id: 1 + weight_id: 4 + bout_number: 6004 + w1: + w2: + bracket_position: 1/2 + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6005: + tournament_id: 1 + weight_id: 4 + bout_number: 6005 + w1: + w2: + bracket_position: 3/4 + bracket_position_number: 1 + loser1_name: Loser of 5004 + loser2_name: Loser of 5005 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6006: + tournament_id: 1 + weight_id: 4 + bout_number: 6006 + w1: + w2: + bracket_position: 5/6 + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6007: + tournament_id: 1 + weight_id: 4 + bout_number: 6007 + w1: + w2: + bracket_position: 7/8 + bracket_position_number: 1 + loser1_name: Loser of 5006 + loser2_name: Loser of 5007 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1013: + tournament_id: 1 + weight_id: 5 + bout_number: 1013 + w1: 35 + w2: 46 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1014: + tournament_id: 1 + weight_id: 5 + bout_number: 1014 + w1: 45 + w2: 39 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2012: + tournament_id: 1 + weight_id: 5 + bout_number: 2012 + w1: 39 + w2: 46 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2013: + tournament_id: 1 + weight_id: 5 + bout_number: 2013 + w1: 35 + w2: 45 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3012: + tournament_id: 1 + weight_id: 5 + bout_number: 3012 + w1: 45 + w2: 46 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3013: + tournament_id: 1 + weight_id: 5 + bout_number: 3013 + w1: 39 + w2: 35 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1015: + tournament_id: 1 + weight_id: 5 + bout_number: 1015 + w1: 44 + w2: 33 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1016: + tournament_id: 1 + weight_id: 5 + bout_number: 1016 + w1: 36 + w2: 37 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2014: + tournament_id: 1 + weight_id: 5 + bout_number: 2014 + w1: 37 + w2: 33 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2015: + tournament_id: 1 + weight_id: 5 + bout_number: 2015 + w1: 44 + w2: 36 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3014: + tournament_id: 1 + weight_id: 5 + bout_number: 3014 + w1: 36 + w2: 33 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3015: + tournament_id: 1 + weight_id: 5 + bout_number: 3015 + w1: 37 + w2: 44 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1017: + tournament_id: 1 + weight_id: 5 + bout_number: 1017 + w1: 34 + w2: 47 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1018: + tournament_id: 1 + weight_id: 5 + bout_number: 1018 + w1: 43 + w2: 41 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2016: + tournament_id: 1 + weight_id: 5 + bout_number: 2016 + w1: 41 + w2: 47 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2017: + tournament_id: 1 + weight_id: 5 + bout_number: 2017 + w1: 34 + w2: 43 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3016: + tournament_id: 1 + weight_id: 5 + bout_number: 3016 + w1: 43 + w2: 47 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3017: + tournament_id: 1 + weight_id: 5 + bout_number: 3017 + w1: 41 + w2: 34 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1019: + tournament_id: 1 + weight_id: 5 + bout_number: 1019 + w1: 38 + w2: 48 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1020: + tournament_id: 1 + weight_id: 5 + bout_number: 1020 + w1: 40 + w2: 42 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2018: + tournament_id: 1 + weight_id: 5 + bout_number: 2018 + w1: 42 + w2: 48 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2019: + tournament_id: 1 + weight_id: 5 + bout_number: 2019 + w1: 38 + w2: 40 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3018: + tournament_id: 1 + weight_id: 5 + bout_number: 3018 + w1: 40 + w2: 48 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3019: + tournament_id: 1 + weight_id: 5 + bout_number: 3019 + w1: 42 + w2: 38 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4010: + tournament_id: 1 + weight_id: 5 + bout_number: 4010 + w1: + w2: + bracket_position: Semis + bracket_position_number: 1 + loser1_name: Winner Pool 1 + loser2_name: Winner Pool 4 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4011: + tournament_id: 1 + weight_id: 5 + bout_number: 4011 + w1: + w2: + bracket_position: Semis + bracket_position_number: 2 + loser1_name: Winner Pool 2 + loser2_name: Winner Pool 3 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4012: + tournament_id: 1 + weight_id: 5 + bout_number: 4012 + w1: + w2: + bracket_position: Conso Semis + bracket_position_number: 1 + loser1_name: Runner Up Pool 1 + loser2_name: Runner Up Pool 4 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4013: + tournament_id: 1 + weight_id: 5 + bout_number: 4013 + w1: + w2: + bracket_position: Conso Semis + bracket_position_number: 2 + loser1_name: Runner Up Pool 2 + loser2_name: Runner Up Pool 3 + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6008: + tournament_id: 1 + weight_id: 5 + bout_number: 6008 + w1: + w2: + bracket_position: 1/2 + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6009: + tournament_id: 1 + weight_id: 5 + bout_number: 6009 + w1: + w2: + bracket_position: 3/4 + bracket_position_number: 1 + loser1_name: Loser of 4010 + loser2_name: Loser of 4011 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6010: + tournament_id: 1 + weight_id: 5 + bout_number: 6010 + w1: + w2: + bracket_position: 5/6 + bracket_position_number: 1 + loser1_name: + loser2_name: + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_6011: + tournament_id: 1 + weight_id: 5 + bout_number: 6011 + w1: + w2: + bracket_position: 7/8 + bracket_position_number: 1 + loser1_name: Loser of 4012 + loser2_name: Loser of 4013 + round: 6 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1021: + tournament_id: 1 + weight_id: 6 + bout_number: 1021 + w1: 50 + w2: 53 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_1022: + tournament_id: 1 + weight_id: 6 + bout_number: 1022 + w1: 51 + w2: 49 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 1 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2020: + tournament_id: 1 + weight_id: 6 + bout_number: 2020 + w1: 52 + w2: 49 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_2021: + tournament_id: 1 + weight_id: 6 + bout_number: 2021 + w1: 50 + w2: 51 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 2 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3020: + tournament_id: 1 + weight_id: 6 + bout_number: 3020 + w1: 53 + w2: 51 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_3021: + tournament_id: 1 + weight_id: 6 + bout_number: 3021 + w1: 52 + w2: 50 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 3 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4014: + tournament_id: 1 + weight_id: 6 + bout_number: 4014 + w1: 49 + w2: 50 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_4015: + tournament_id: 1 + weight_id: 6 + bout_number: 4015 + w1: 53 + w2: 52 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 4 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5008: + tournament_id: 1 + weight_id: 6 + bout_number: 5008 + w1: 51 + w2: 52 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: + +tournament_1_bout_5009: + tournament_id: 1 + weight_id: 6 + bout_number: 5009 + w1: 49 + w2: 53 + bracket_position: Pool + bracket_position_number: + loser1_name: + loser2_name: + round: 5 + mat_id: + finished: + w1_stat: + w2_stat: + score: + winner_id: + win_type: \ No newline at end of file diff --git a/test/fixtures/wrestlers.yml b/test/fixtures/wrestlers.yml index d2f48af..56dfaff 100644 --- a/test/fixtures/wrestlers.yml +++ b/test/fixtures/wrestlers.yml @@ -1,531 +1,637 @@ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -wrestler1: +tournament_1_wrestler_1: id: 1 name: Jackson Lakso school_id: 1 weight_id: 1 original_seed: 3 + seed: 2 season_loss: 8 season_win: 30 criteria: SQ + extra: -wrestler2: +tournament_1_wrestler_2: id: 2 name: JD Woods school_id: 1 weight_id: 1 original_seed: 5 + seed: 5 season_loss: 12 season_win: 30 criteria: DP 6th + extra: -wrestler3: +tournament_1_wrestler_3: id: 3 name: Jaden Mattox school_id: 1 weight_id: 1 original_seed: 1 + seed: 1 season_loss: 3 season_win: 49 criteria: SP 2nd + extra: -wrestler4: +tournament_1_wrestler_4: id: 4 name: Zach Collins school_id: 1 weight_id: 1 original_seed: 4 + seed: 4 season_loss: 8 season_win: 30 criteria: DP 5th + extra: -wrestler5: +tournament_1_wrestler_5: id: 5 name: James Wimer school_id: 1 weight_id: 1 original_seed: 2 + seed: 3 season_loss: 12 season_win: 49 criteria: SP 5th + extra: -wrestler6: +tournament_1_wrestler_6: id: 6 name: Derek Wurzauf school_id: 1 weight_id: 2 original_seed: 6 + seed: 3 season_loss: 15 season_win: 16 criteria: + extra: -wrestler7: +tournament_1_wrestler_7: id: 7 name: Casey Davis school_id: 1 weight_id: 2 original_seed: 5 + seed: 5 season_loss: 15 season_win: 16 criteria: DQ + extra: -wrestler8: +tournament_1_wrestler_8: id: 8 name: Kameron Teacher school_id: 1 weight_id: 2 original_seed: 2 + seed: 2 season_loss: 2 season_win: 50 criteria: SQ + extra: -wrestler9: +tournament_1_wrestler_9: id: 9 name: Robbie Fusner school_id: 1 weight_id: 2 original_seed: 3 + seed: 6 season_loss: 5 season_win: 40 criteria: SQ + extra: -wrestler10: +tournament_1_wrestler_10: id: 10 name: Guy1 school_id: 1 weight_id: 2 original_seed: 7 + seed: 4 season_loss: 2 season_win: 50 criteria: + extra: -wrestler11: +tournament_1_wrestler_11: id: 11 name: Ethan Leapley school_id: 1 weight_id: 2 original_seed: 4 + seed: 7 season_loss: 15 season_win: 20 criteria: DP 6th + extra: -wrestler12: +tournament_1_wrestler_12: id: 12 name: Clayton Ray school_id: 1 weight_id: 2 original_seed: 1 + seed: 1 season_loss: 4 season_win: 30 criteria: SP 7th + extra: -wrestler13: +tournament_1_wrestler_13: id: 13 name: Guy2 school_id: 1 weight_id: 3 original_seed: 1 + seed: 1 season_loss: 2 season_win: 50 criteria: + extra: -wrestler14: +tournament_1_wrestler_14: id: 14 name: Guy9 school_id: 1 weight_id: 3 original_seed: 8 + seed: 3 season_loss: 2 season_win: 50 criteria: + extra: -wrestler15: +tournament_1_wrestler_15: id: 15 name: Guy7 school_id: 1 weight_id: 3 original_seed: 6 + seed: 6 season_loss: 2 season_win: 50 criteria: + extra: -wrestler16: +tournament_1_wrestler_16: id: 16 name: Guy3 school_id: 1 weight_id: 3 original_seed: 2 + seed: 2 season_loss: 2 season_win: 50 criteria: + extra: -wrestler17: +tournament_1_wrestler_17: id: 17 name: Guy4 school_id: 1 weight_id: 3 original_seed: 3 + seed: 8 season_loss: 2 season_win: 50 criteria: + extra: -wrestler18: +tournament_1_wrestler_18: id: 18 name: Guy8 school_id: 1 weight_id: 3 original_seed: 7 + seed: 7 season_loss: 2 season_win: 50 criteria: + extra: -wrestler19: +tournament_1_wrestler_19: id: 19 name: Guy10 school_id: 1 weight_id: 3 original_seed: 9 + seed: 4 season_loss: 2 season_win: 50 criteria: + extra: -wrestler20: +tournament_1_wrestler_20: id: 20 name: Guy6 school_id: 1 weight_id: 3 original_seed: 5 + seed: 5 season_loss: 2 season_win: 50 criteria: + extra: -wrestler21: +tournament_1_wrestler_21: id: 21 name: Guy5 school_id: 1 weight_id: 3 original_seed: 4 + seed: 9 season_loss: 2 season_win: 50 criteria: + extra: -wrestler22: +tournament_1_wrestler_22: id: 22 name: Guy20 school_id: 1 weight_id: 4 original_seed: 10 + seed: 7 season_loss: 2 season_win: 50 criteria: + extra: -wrestler23: +tournament_1_wrestler_23: id: 23 name: Guy12 school_id: 1 weight_id: 4 original_seed: 2 + seed: 2 season_loss: 2 season_win: 50 criteria: + extra: -wrestler24: +tournament_1_wrestler_24: id: 24 name: Guy16 school_id: 1 weight_id: 4 original_seed: 6 + seed: 6 season_loss: 2 season_win: 50 criteria: + extra: -wrestler25: +tournament_1_wrestler_25: id: 25 name: Guy13 school_id: 1 weight_id: 4 original_seed: 3 + seed: 3 season_loss: 2 season_win: 50 criteria: + extra: -wrestler26: +tournament_1_wrestler_26: id: 26 name: Guy15 school_id: 1 weight_id: 4 original_seed: 5 + seed: 5 season_loss: 2 season_win: 50 criteria: + extra: -wrestler27: +tournament_1_wrestler_27: id: 27 name: Guy21 school_id: 1 weight_id: 4 original_seed: 11 + seed: 8 season_loss: 2 season_win: 50 criteria: + extra: -wrestler28: +tournament_1_wrestler_28: id: 28 name: Guy11 school_id: 1 weight_id: 4 original_seed: 1 + seed: 1 season_loss: 2 season_win: 50 criteria: + extra: -wrestler29: +tournament_1_wrestler_29: id: 29 name: Guy14 school_id: 1 weight_id: 4 original_seed: 4 + seed: 4 season_loss: 2 season_win: 50 criteria: + extra: -wrestler30: +tournament_1_wrestler_30: id: 30 name: Guy18 school_id: 1 weight_id: 4 original_seed: 8 + seed: 11 season_loss: 2 season_win: 50 criteria: + extra: -wrestler31: +tournament_1_wrestler_31: id: 31 name: Guy17 school_id: 1 weight_id: 4 original_seed: 7 + seed: 10 season_loss: 2 season_win: 50 criteria: + extra: -wrestler32: +tournament_1_wrestler_32: id: 32 name: Guy19 school_id: 1 weight_id: 4 original_seed: 9 + seed: 9 season_loss: 2 season_win: 50 criteria: + extra: -wrestler33: +tournament_1_wrestler_33: id: 33 name: Guy36 school_id: 1 weight_id: 5 original_seed: 15 + seed: 7 season_loss: 2 season_win: 50 criteria: + extra: -wrestler34: +tournament_1_wrestler_34: id: 34 name: Guy31 school_id: 1 weight_id: 5 original_seed: 10 + seed: 10 season_loss: 2 season_win: 50 criteria: + extra: -wrestler35: +tournament_1_wrestler_35: id: 35 name: Guy22 school_id: 1 weight_id: 5 original_seed: 1 + seed: 1 season_loss: 2 season_win: 50 criteria: + extra: -wrestler36: +tournament_1_wrestler_36: id: 36 name: Guy32 school_id: 1 weight_id: 5 original_seed: 11 + seed: 11 season_loss: 2 season_win: 50 criteria: + extra: -wrestler37: +tournament_1_wrestler_37: id: 37 name: Guy23 school_id: 1 weight_id: 5 original_seed: 2 + seed: 2 season_loss: 2 season_win: 50 criteria: + extra: -wrestler38: +tournament_1_wrestler_38: id: 38 name: Guy34 school_id: 1 weight_id: 5 original_seed: 13 + seed: 13 season_loss: 2 season_win: 50 criteria: + extra: -wrestler39: +tournament_1_wrestler_39: id: 39 name: Guy29 school_id: 1 weight_id: 5 original_seed: 8 + seed: 16 season_loss: 2 season_win: 50 criteria: + extra: -wrestler40: +tournament_1_wrestler_40: id: 40 name: Guy26 school_id: 1 weight_id: 5 original_seed: 5 + seed: 5 season_loss: 2 season_win: 50 criteria: + extra: -wrestler41: +tournament_1_wrestler_41: id: 41 name: Guy35 school_id: 1 weight_id: 5 original_seed: 14 + seed: 6 season_loss: 2 season_win: 50 criteria: + extra: -wrestler42: +tournament_1_wrestler_42: id: 42 name: Guy30 school_id: 1 weight_id: 5 original_seed: 9 + seed: 9 season_loss: 2 season_win: 50 criteria: + extra: -wrestler43: +tournament_1_wrestler_43: id: 43 name: Guy27 school_id: 1 weight_id: 5 original_seed: 6 + seed: 14 season_loss: 2 season_win: 50 criteria: + extra: -wrestler44: +tournament_1_wrestler_44: id: 44 name: Guy28 school_id: 1 weight_id: 5 original_seed: 7 + seed: 15 season_loss: 2 season_win: 50 criteria: + extra: -wrestler45: +tournament_1_wrestler_45: id: 45 name: Guy37 school_id: 1 weight_id: 5 original_seed: 16 + seed: 8 season_loss: 2 season_win: 50 criteria: + extra: -wrestler46: +tournament_1_wrestler_46: id: 46 name: Guy33 school_id: 1 weight_id: 5 original_seed: 12 + seed: 12 season_loss: 2 season_win: 50 criteria: + extra: -wrestler47: +tournament_1_wrestler_47: id: 47 name: Guy24 school_id: 1 weight_id: 5 original_seed: 3 + seed: 3 season_loss: 2 season_win: 50 criteria: + extra: -wrestler48: +tournament_1_wrestler_48: id: 48 name: Guy25 school_id: 1 weight_id: 5 original_seed: 4 + seed: 4 season_loss: 2 season_win: 50 criteria: + extra: -wrestler49: +tournament_1_wrestler_49: id: 49 name: Guy42 school_id: 1 weight_id: 6 original_seed: + seed: 4 season_loss: 2 season_win: 50 criteria: + extra: -wrestler50: +tournament_1_wrestler_50: id: 50 name: Guy39 school_id: 1 weight_id: 6 original_seed: 2 + seed: 2 season_loss: 2 season_win: 50 criteria: + extra: -wrestler51: +tournament_1_wrestler_51: id: 51 name: Guy41 school_id: 1 weight_id: 6 original_seed: + seed: 3 season_loss: 2 season_win: 50 criteria: + extra: -wrestler52: +tournament_1_wrestler_52: id: 52 name: Guy43 school_id: 1 weight_id: 6 original_seed: + seed: 5 season_loss: 2 season_win: 50 criteria: + extra: -wrestler53: +tournament_1_wrestler_53: id: 53 name: Guy40 school_id: 1 weight_id: 6 original_seed: + seed: 6 season_loss: 2 season_win: 50 - criteria: \ No newline at end of file + criteria: + extra: \ No newline at end of file diff --git a/test/integration/pool_advancement_test.rb b/test/integration/pool_advancement_test.rb index 5df311a..502e27c 100644 --- a/test/integration/pool_advancement_test.rb +++ b/test/integration/pool_advancement_test.rb @@ -7,7 +7,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest # WHY DOES THIS NOT WORK WITHOUT GENERATING MATCHUPS BEFORE EVERY TEST? # FIXTURES FOR MATCHES ARE FILLED OUT AND WORK FOR OTHER TESTS - tournament.generateMatchups + # tournament.generateMatchups end def singlePoolNotFinished diff --git a/test/integration/single_test_test.rb b/test/integration/single_test_test.rb index 32a5519..919fda3 100644 --- a/test/integration/single_test_test.rb +++ b/test/integration/single_test_test.rb @@ -36,7 +36,8 @@ class SingleTestTest < ActionDispatch::IntegrationTest # Yml for wrestlers # @tournament.wrestlers.each do |w| - # puts "tournament_1_#{w.name}:" + # puts "tournament_1_wrestler_#{count}:" + # puts " id: #{count}" # puts " name: #{w.name}" # puts " school_id: #{w.school_id}" # puts " weight_id: #{w.weight_id}" @@ -45,6 +46,7 @@ class SingleTestTest < ActionDispatch::IntegrationTest # puts " season_loss: #{w.season_loss}" # puts " season_win: #{w.season_win}" # puts " criteria: #{w.criteria}" + # puts " extra: #{w.extra}" # puts "" # count += 1 # end From 2f9c54df2e7dcc4f82bf8a9a5c9bbff3dc510f87 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Sat, 14 May 2016 13:28:28 +0000 Subject: [PATCH 37/46] Refactored match generation so I can eventually support multiple types of tournaments --- app/controllers/tournaments_controller.rb | 2 +- app/models/generates_tournament_matches.rb | 60 ------------------ app/models/tournament.rb | 19 ------ app/models/weight.rb | 49 --------------- .../generate_tournament_matches.rb | 61 +++++++++++++++++++ .../pool_bracket_generation.rb} | 2 +- .../tournament_services/pool_generation.rb} | 2 +- .../pool_to_bracket_generate_loser_names.rb} | 19 +++--- .../pool_to_bracket_match_generation.rb | 46 ++++++++++++++ .../tournament_services/tournament_seeding.rb | 44 +++++++++++++ .../wipe_tournament_matches.rb | 19 ++++++ config/application.rb | 2 + test/integration/pool_advancement_test.rb | 4 -- test/integration/poolbracket_matchups_test.rb | 4 +- 14 files changed, 189 insertions(+), 144 deletions(-) delete mode 100644 app/models/generates_tournament_matches.rb create mode 100644 app/services/tournament_services/generate_tournament_matches.rb rename app/{models/pool_bracket.rb => services/tournament_services/pool_bracket_generation.rb} (98%) rename app/{models/pool.rb => services/tournament_services/pool_generation.rb} (96%) rename app/{models/generates_loser_names.rb => services/tournament_services/pool_to_bracket_generate_loser_names.rb} (92%) create mode 100644 app/services/tournament_services/pool_to_bracket_match_generation.rb create mode 100644 app/services/tournament_services/tournament_seeding.rb create mode 100644 app/services/tournament_services/wipe_tournament_matches.rb diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index b06c577..b89d609 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -163,7 +163,7 @@ class TournamentsController < ApplicationController end def generate_matches - @tournament.generateMatchups + GenerateTournamentMatches.new(@tournament).generate end def brackets diff --git a/app/models/generates_tournament_matches.rb b/app/models/generates_tournament_matches.rb deleted file mode 100644 index 7661a64..0000000 --- a/app/models/generates_tournament_matches.rb +++ /dev/null @@ -1,60 +0,0 @@ -module GeneratesTournamentMatches - - def generateMatchups - self.curently_generating_matches = 1 - self.save - resetSchoolScores - setSeedsAndRandomSeedingWrestlersWithoutSeeds - poolToBracket() if tournament_type == "Pool to bracket" - self.curently_generating_matches = nil - self.save - end - if Rails.env.production? - handle_asynchronously :generateMatchups - end - - def poolToBracket - destroyAllMatches - generatePoolToBracketMatches - poolToBracketPostMatchCreation - end - - def generatePoolToBracketMatches - weights.order(:max).each do |weight| - Pool.new(weight).generatePools() - last_match = matches.where(weight: weight).order(round: :desc).limit(1).first - highest_round = last_match.round - PoolBracket.new(weight, highest_round).generateBracketMatches() - end - end - - def poolToBracketPostMatchCreation - moveFinalsMatchesToLastRound - assignBouts - assignLoserNames - assignFirstMatchesToMats - movePoolSeedsToFinalPoolRound - end - - def moveFinalsMatchesToLastRound - finalsRound = self.totalRounds - finalsMatches = self.matches.select{|m| m.bracket_position == "1/2" || m.bracket_position == "3/4" || m.bracket_position == "5/6" || m.bracket_position == "7/8"} - finalsMatches. each do |m| - m.round = finalsRound - m.save - end - end - - def setSeedsAndRandomSeedingWrestlersWithoutSeeds - weights.each do |w| - w.setSeeds - end - end - - def movePoolSeedsToFinalPoolRound - self.weights.each do |w| - w.setOriginalSeedsToWrestleLastPoolRound - end - end - -end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index e1224f3..19dff17 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -1,7 +1,5 @@ class Tournament < ActiveRecord::Base - include GeneratesLoserNames - include GeneratesTournamentMatches belongs_to :user has_many :schools, dependent: :destroy has_many :weights, dependent: :destroy @@ -24,10 +22,6 @@ class Tournament < ActiveRecord::Base time end - def resetSchoolScores - schools.update_all("score = 0.0") - end - def tournament_types ["Pool to bracket"] end @@ -50,19 +44,6 @@ class Tournament < ActiveRecord::Base def matchesByRound(round) matches.joins(:weight).where(round: round).order("weights.max") end - - def assignBouts - bout_counts = Hash.new(0) - matches.each do |m| - m.bout_number = m.round * 1000 + bout_counts[m.round] - bout_counts[m.round] += 1 - m.save! - end - end - - def assignFirstMatchesToMats - assignMats(mats) - end def totalRounds self.matches.sort_by{|m| m.round}.last.round diff --git a/app/models/weight.rb b/app/models/weight.rb index 824a103..1573b19 100644 --- a/app/models/weight.rb +++ b/app/models/weight.rb @@ -46,22 +46,6 @@ class Weight < ActiveRecord::Base wrestlersForPool(pool).sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]} end - def setOriginalSeedsToWrestleLastPoolRound - pool = 1 - until pool > self.pools - wrestler1 = poolSeedOrder(pool).first - wrestler2 = poolSeedOrder(pool).second - match = wrestler1.poolMatches.sort_by{|m| m.round}.last - if match.w1 != wrestler2.id or match.w2 != wrestler2.id - if match.w1 == wrestler1.id - swapWrestlers(match.w2,wrestler2.id) - elsif match.w2 == wrestler1.id - swapWrestlers(match.w1,wrestler2.id) - end - end - pool += 1 - end - end def swapWrestlers(wrestler1_id,wrestler2_id) SwapWrestlers.new.swapWrestlers(wrestler1_id,wrestler2_id) @@ -180,38 +164,5 @@ class Weight < ActiveRecord::Base def poolOrder(pool) PoolOrder.new(wrestlersForPool(pool)).getPoolOrder end - - def randomSeeding - wrestlerWithSeeds = self.wrestlers.select{|w| w.original_seed != nil }.sort_by{|w| w.original_seed} - if wrestlerWithSeeds.size > 0 - highestSeed = wrestlerWithSeeds.last.seed - seed = highestSeed + 1 - else - seed = 1 - end - wrestlersWithoutSeed = self.wrestlers.select{|w| w.original_seed == nil } - wrestlersWithoutSeed.shuffle.each do |w| - w.seed = seed - w.save - seed += 1 - end - end - - def setSeeds - resetAllSeeds - wrestlerWithSeeds = self.wrestlers.select{|w| w.original_seed != nil } - wrestlerWithSeeds.each do |w| - w.seed = w.original_seed - w.save - end - randomSeeding - end - - def resetAllSeeds - self.wrestlers.each do |w| - w.seed = nil - w.save - end - end end diff --git a/app/services/tournament_services/generate_tournament_matches.rb b/app/services/tournament_services/generate_tournament_matches.rb new file mode 100644 index 0000000..4ffdb34 --- /dev/null +++ b/app/services/tournament_services/generate_tournament_matches.rb @@ -0,0 +1,61 @@ +class GenerateTournamentMatches + def initialize( tournament ) + @tournament = tournament + end + + def generate + standardStartingActions + PoolToBracketMatchGeneration.new(@tournament).generatePoolToBracketMatches if @tournament.tournament_type == "Pool to bracket" + postMatchCreationActions + PoolToBracketMatchGeneration.new(@tournament).assignLoserNames if @tournament.tournament_type == "Pool to bracket" + end + + def standardStartingActions + @tournament.curently_generating_matches = 1 + @tournament.save + WipeTournamentMatches.new(@tournament).setUpMatchGeneration + TournamentSeeding.new(@tournament).setSeeds + end + + def postMatchCreationActions + moveFinalsMatchesToLastRound + assignBouts + assignFirstMatchesToMats + @tournament.curently_generating_matches = nil + @tournament.save + end + + def assignBouts + bout_counts = Hash.new(0) + @tournament.matches.each do |m| + m.bout_number = m.round * 1000 + bout_counts[m.round] + bout_counts[m.round] += 1 + m.save! + end + end + + def moveFinalsMatchesToLastRound + finalsRound = @tournament.totalRounds + finalsMatches = @tournament.matches.select{|m| m.bracket_position == "1/2" || m.bracket_position == "3/4" || m.bracket_position == "5/6" || m.bracket_position == "7/8"} + finalsMatches. each do |m| + m.round = finalsRound + m.save + end + end + + def assignFirstMatchesToMats + matsToAssign = @tournament.mats + if matsToAssign.count > 0 + until matsToAssign.sort_by{|m| m.id}.last.matches.count == 4 + matsToAssign.sort_by{|m| m.id}.each do |m| + m.assignNextMatch + end + end + end + end + + + + + +end \ No newline at end of file diff --git a/app/models/pool_bracket.rb b/app/services/tournament_services/pool_bracket_generation.rb similarity index 98% rename from app/models/pool_bracket.rb rename to app/services/tournament_services/pool_bracket_generation.rb index 26be9f4..4b42763 100644 --- a/app/models/pool_bracket.rb +++ b/app/services/tournament_services/pool_bracket_generation.rb @@ -1,4 +1,4 @@ -class PoolBracket +class PoolBracketGeneration def initialize(weight, highest_round) @weight = weight diff --git a/app/models/pool.rb b/app/services/tournament_services/pool_generation.rb similarity index 96% rename from app/models/pool.rb rename to app/services/tournament_services/pool_generation.rb index 8e7a3af..12a3e5c 100644 --- a/app/models/pool.rb +++ b/app/services/tournament_services/pool_generation.rb @@ -1,4 +1,4 @@ -class Pool +class PoolGeneration def initialize(weight) @weight = weight @tournament = @weight.tournament diff --git a/app/models/generates_loser_names.rb b/app/services/tournament_services/pool_to_bracket_generate_loser_names.rb similarity index 92% rename from app/models/generates_loser_names.rb rename to app/services/tournament_services/pool_to_bracket_generate_loser_names.rb index 023eb12..d315c04 100644 --- a/app/models/generates_loser_names.rb +++ b/app/services/tournament_services/pool_to_bracket_generate_loser_names.rb @@ -1,8 +1,12 @@ -module GeneratesLoserNames - def assignLoserNames +class PoolToBracketGenerateLoserNames + def initialize( tournament ) + @tournament = tournament + end + + def assignLoserNames matches_by_weight = nil - weights.each do |w| - matches_by_weight = matches.where(weight_id: w.id) + @tournament.weights.each do |w| + matches_by_weight = @tournament.matches.where(weight_id: w.id) if w.pool_bracket_type == "twoPoolsToSemi" twoPoolsToSemiLoser(matches_by_weight) elsif w.pool_bracket_type == "fourPoolsToQuarter" @@ -12,7 +16,7 @@ module GeneratesLoserNames end saveMatches(matches_by_weight) end - end + end def twoPoolsToSemiLoser(matches_by_weight) match1 = matches_by_weight.select{|m| m.loser1_name == "Winner Pool 1"}.first @@ -59,5 +63,6 @@ module GeneratesLoserNames matches.each do |m| m.save! end - end -end + end + +end \ No newline at end of file diff --git a/app/services/tournament_services/pool_to_bracket_match_generation.rb b/app/services/tournament_services/pool_to_bracket_match_generation.rb new file mode 100644 index 0000000..31e9388 --- /dev/null +++ b/app/services/tournament_services/pool_to_bracket_match_generation.rb @@ -0,0 +1,46 @@ +class PoolToBracketMatchGeneration + def initialize( tournament ) + @tournament = tournament + end + + + + def generatePoolToBracketMatches + @tournament.weights.order(:max).each do |weight| + PoolGeneration.new(weight).generatePools() + last_match = @tournament.matches.where(weight: weight).order(round: :desc).limit(1).first + highest_round = last_match.round + PoolBracketGeneration.new(weight, highest_round).generateBracketMatches() + end + movePoolSeedsToFinalPoolRound + end + + def movePoolSeedsToFinalPoolRound + @tournament.weights.each do |w| + setOriginalSeedsToWrestleLastPoolRound(w) + end + end + + def setOriginalSeedsToWrestleLastPoolRound(weight) + pool = 1 + until pool > weight.pools + wrestler1 = weight.poolSeedOrder(pool).first + wrestler2 = weight.poolSeedOrder(pool).second + match = wrestler1.poolMatches.sort_by{|m| m.round}.last + if match.w1 != wrestler2.id or match.w2 != wrestler2.id + if match.w1 == wrestler1.id + SwapWrestlers.new.swapWrestlers(match.w2,wrestler2.id) + elsif match.w2 == wrestler1.id + SwapWrestlers.new.swapWrestlers(match.w1,wrestler2.id) + end + end + pool += 1 + end + end + + + def assignLoserNames + PoolToBracketGenerateLoserNames.new(@tournament).assignLoserNames + end + +end \ No newline at end of file diff --git a/app/services/tournament_services/tournament_seeding.rb b/app/services/tournament_services/tournament_seeding.rb new file mode 100644 index 0000000..4ffb9aa --- /dev/null +++ b/app/services/tournament_services/tournament_seeding.rb @@ -0,0 +1,44 @@ +class TournamentSeeding + def initialize( tournament ) + @tournament = tournament + end + + def setSeeds + @tournament.weights.each do |w| + resetAllSeeds(w) + setOriginalSeeds(w) + randomSeeding(w) + end + end + + def randomSeeding(weight) + wrestlerWithSeeds = weight.wrestlers.select{|w| w.original_seed != nil }.sort_by{|w| w.original_seed} + if wrestlerWithSeeds.size > 0 + highestSeed = wrestlerWithSeeds.last.seed + seed = highestSeed + 1 + else + seed = 1 + end + wrestlersWithoutSeed = weight.wrestlers.select{|w| w.original_seed == nil } + wrestlersWithoutSeed.shuffle.each do |w| + w.seed = seed + w.save + seed += 1 + end + end + + def setOriginalSeeds(weight) + wrestlerWithSeeds = weight.wrestlers.select{|w| w.original_seed != nil } + wrestlerWithSeeds.each do |w| + w.seed = w.original_seed + w.save + end + end + + def resetAllSeeds(weight) + weight.wrestlers.each do |w| + w.seed = nil + w.save + end + end +end \ No newline at end of file diff --git a/app/services/tournament_services/wipe_tournament_matches.rb b/app/services/tournament_services/wipe_tournament_matches.rb new file mode 100644 index 0000000..e77c0cb --- /dev/null +++ b/app/services/tournament_services/wipe_tournament_matches.rb @@ -0,0 +1,19 @@ +class WipeTournamentMatches + + def initialize( tournament ) + @tournament = tournament + end + + def setUpMatchGeneration + wipeMatches + resetSchoolScores + end + + def wipeMatches + @tournament.matches.destroy_all + end + + def resetSchoolScores + @tournament.schools.update_all("score = 0.0") + end +end \ No newline at end of file diff --git a/config/application.rb b/config/application.rb index 786352b..a05c52e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -34,6 +34,8 @@ module Wrestling config.to_prepare do DeviseController.respond_to :html, :json end + + config.autoload_paths += %W(#{config.root}/app/services/tournament_services) end diff --git a/test/integration/pool_advancement_test.rb b/test/integration/pool_advancement_test.rb index 502e27c..cb5382c 100644 --- a/test/integration/pool_advancement_test.rb +++ b/test/integration/pool_advancement_test.rb @@ -4,10 +4,6 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest def setup tournament = Tournament.find(1) - - # WHY DOES THIS NOT WORK WITHOUT GENERATING MATCHUPS BEFORE EVERY TEST? - # FIXTURES FOR MATCHES ARE FILLED OUT AND WORK FOR OTHER TESTS - # tournament.generateMatchups end def singlePoolNotFinished diff --git a/test/integration/poolbracket_matchups_test.rb b/test/integration/poolbracket_matchups_test.rb index 0279a91..5946be3 100644 --- a/test/integration/poolbracket_matchups_test.rb +++ b/test/integration/poolbracket_matchups_test.rb @@ -3,7 +3,7 @@ require 'test_helper' class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest def setup @tournament = Tournament.find(1) - @tournament.generateMatchups + GenerateTournamentMatches.new(@tournament).generate end def createTournament(numberOfWrestlers) @@ -69,7 +69,7 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest end def checkForByeInPool(tournament) - tournament.generateMatchups + GenerateTournamentMatches.new(tournament).generate matchups = tournament.matches tournament.weights.each do |w| w.wrestlers.each do |wr| From a6e64bdf8f4a21c222939bb253a8b5dc2d021bb0 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Sat, 14 May 2016 14:54:49 +0000 Subject: [PATCH 38/46] Moved none database classes out of model folder. Still need to separate classes that are doing too much for bracket_advancement, for placement points, and for swapping wrestlers in pool/bracket. --- app/{models => services/bracket_advancement}/pool_advance.rb | 0 app/{models => services/bracket_advancement}/pool_order.rb | 0 .../wrestler_services}/pool_bracket_placement_points.rb | 0 app/{models => services/wrestler_services}/swap_wrestlers.rb | 0 config/application.rb | 2 ++ 5 files changed, 2 insertions(+) rename app/{models => services/bracket_advancement}/pool_advance.rb (100%) rename app/{models => services/bracket_advancement}/pool_order.rb (100%) rename app/{models => services/wrestler_services}/pool_bracket_placement_points.rb (100%) rename app/{models => services/wrestler_services}/swap_wrestlers.rb (100%) diff --git a/app/models/pool_advance.rb b/app/services/bracket_advancement/pool_advance.rb similarity index 100% rename from app/models/pool_advance.rb rename to app/services/bracket_advancement/pool_advance.rb diff --git a/app/models/pool_order.rb b/app/services/bracket_advancement/pool_order.rb similarity index 100% rename from app/models/pool_order.rb rename to app/services/bracket_advancement/pool_order.rb diff --git a/app/models/pool_bracket_placement_points.rb b/app/services/wrestler_services/pool_bracket_placement_points.rb similarity index 100% rename from app/models/pool_bracket_placement_points.rb rename to app/services/wrestler_services/pool_bracket_placement_points.rb diff --git a/app/models/swap_wrestlers.rb b/app/services/wrestler_services/swap_wrestlers.rb similarity index 100% rename from app/models/swap_wrestlers.rb rename to app/services/wrestler_services/swap_wrestlers.rb diff --git a/config/application.rb b/config/application.rb index a05c52e..83f26e4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -36,6 +36,8 @@ module Wrestling end config.autoload_paths += %W(#{config.root}/app/services/tournament_services) + config.autoload_paths += %W(#{config.root}/app/services/wrestler_services) + config.autoload_paths += %W(#{config.root}/app/services/bracket_advancement) end From 225e90ca8f257c28a25642c5d07b462b483db37d Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Sat, 14 May 2016 11:20:28 -0400 Subject: [PATCH 39/46] Get frontend javascript into the docker image. Still need to figure out how to get frontend templates into rails. --- config/environments/production.rb | 3 +++ deploy/deploy-test.sh | 3 ++- frontend/config/application.js | 4 ++++ rails-prod-Dockerfile | 11 +++++++---- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 33ca8d1..44552b6 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -110,4 +110,7 @@ Wrestling::Application.configure do config.action_mailer.perform_deliveries = true #Devise needs origin of email Rails.application.routes.default_url_options[:host] = 'https://wrestlingdev.com' + + #For lineman creating assets + config.serve_static_files = true end diff --git a/deploy/deploy-test.sh b/deploy/deploy-test.sh index 0b6b3fc..21116f5 100755 --- a/deploy/deploy-test.sh +++ b/deploy/deploy-test.sh @@ -1,5 +1,6 @@ cd .. -bash rails-prod.sh wrestlingdev +docker build -t wrestlingdev -f rails-prod-Dockerfile . cd deploy +docker-compose -f docker-compose-test.yml kill docker-compose -f docker-compose-test.yml up -d echo Make sure your local mysql database has a wrestlingtourney db diff --git a/frontend/config/application.js b/frontend/config/application.js index 6a7ddf8..5eb19e0 100644 --- a/frontend/config/application.js +++ b/frontend/config/application.js @@ -33,6 +33,10 @@ module.exports = function(lineman) { } }, + removeTasks: { + common: ["jshint"] + }, + // Sass // // Lineman supports Sass via grunt-contrib-sass, which requires you first diff --git a/rails-prod-Dockerfile b/rails-prod-Dockerfile index db3326a..e5b90a5 100644 --- a/rails-prod-Dockerfile +++ b/rails-prod-Dockerfile @@ -54,6 +54,7 @@ RUN bundle install --without test WORKDIR /tmp COPY frontend/package.json package.json RUN npm install +RUN npm install lineman RUN npm install -g lineman # Copy site into place. @@ -64,9 +65,13 @@ ENV WRESTLINGDEV_SECRET_KEY_BASE 077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e446 ENV WRESTLINGDEV_DEVISE_SECRET_KEY 2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa WORKDIR /var/www/ ADD . /var/www/ + +#Copy node_modules to /var/www +RUN mv /tmp/node_modules /var/www/frontend/node_modules + #RUN RAILS_ENV=production bundle exec rake db:migrate RUN RAILS_ENV=production bundle exec rake assets:precompile - +#RUN cp /var/www/frontend/dist/*.html /var/www/public/ # Update the default apache site with the config we created. RUN rm /etc/apache2/sites-enabled/000-default.conf @@ -78,9 +83,7 @@ RUN a2ensite default-ssl.conf RUN echo PassengerMaxPoolSize 3 >> /etc/apache2/apache2.conf RUN echo PassengerMinInstances 3 >> /etc/apache2/apache2.conf RUN echo PassengerPreStart *:443 >> /etc/apache2/apache2.conf - -#Copy node_modules to /var/www -RUN mv /tmp/node_modules /var/www/frontend/node_modules + # By default, simply start apache. CMD /usr/sbin/apache2ctl -D FOREGROUND From 4f15c2b8a32116ab836a6076e3a0a3fb143a6445 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Thu, 26 May 2016 01:04:51 +0000 Subject: [PATCH 40/46] Still moving logic out of the models --- app/models/match.rb | 14 ++---- app/models/school.rb | 3 ++ app/models/teampointadjust.rb | 8 +--- app/models/wrestler.rb | 47 +++++++------------ .../bracket_advancement/advance_wrestler.rb | 14 ++++++ .../generate_tournament_matches.rb | 3 ++ .../calculate_wrestler_team_score.rb | 47 +++++++++++++++++++ 7 files changed, 90 insertions(+), 46 deletions(-) create mode 100644 app/services/bracket_advancement/advance_wrestler.rb create mode 100644 app/services/wrestler_services/calculate_wrestler_team_score.rb diff --git a/app/models/match.rb b/app/models/match.rb index 549bc85..af655d4 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -32,9 +32,7 @@ class Match < ActiveRecord::Base wrestler2.school.calcScore end end - if Rails.env.production? - handle_asynchronously :calcSchoolPoints - end + def mat_assigned if self.mat @@ -57,15 +55,11 @@ class Match < ActiveRecord::Base def advance_wrestlers if self.w1 && self.w2 - @w1 = wrestler1 - @w2 = wrestler2 - @w1.advanceInBracket(self) - @w2.advanceInBracket(self) + AdvanceWrestler.new(wrestler1).advance + AdvanceWrestler.new(wrestler2).advance end end - if Rails.env.production? - handle_asynchronously :advance_wrestlers - end + def bracketScore if self.finished != 1 diff --git a/app/models/school.rb b/app/models/school.rb index 598eb77..1da7707 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -24,6 +24,9 @@ class School < ActiveRecord::Base self.score = newScore self.save end + if Rails.env.production? + handle_asynchronously :calcScore + end def totalWrestlerPoints points = 0 diff --git a/app/models/teampointadjust.rb b/app/models/teampointadjust.rb index 64fcb48..ff61f81 100644 --- a/app/models/teampointadjust.rb +++ b/app/models/teampointadjust.rb @@ -14,15 +14,11 @@ class Teampointadjust < ActiveRecord::Base #Team score needs calculated if self.wrestler_id != nil #In case this affects pool order - if self.wrestler.lastFinishedMatch - self.wrestler.lastFinishedMatch.advance_wrestlers - end + AdvanceWrestler.new(self.wrestler).advance self.wrestler.school.calcScore elsif self.school_id != nil self.school.calcScore end end - if Rails.env.production? - handle_asynchronously :advance_wrestlers_and_calc_team_score - end + end diff --git a/app/models/wrestler.rb b/app/models/wrestler.rb index b8ebd9e..d23a683 100644 --- a/app/models/wrestler.rb +++ b/app/models/wrestler.rb @@ -22,28 +22,19 @@ class Wrestler < ActiveRecord::Base end def totalTeamPoints - if self.extra - return 0 - else - teamPointsEarned - totalDeductedPoints - end + CalculateWrestlerTeamScore.new(self).totalScore end def teamPointsEarned - points = 0.0 - points = points + (poolWins.size * 2) + (championshipAdvancementWins.size * 2) + (consoAdvancementWins.size * 1) + (pinWins.size * 2) + (techWins.size * 1.5) + (majorWins.size * 1) + placementPoints + CalculateWrestlerTeamScore.new(self).earnedPoints end def placementPoints - PoolBracketPlacementPoints.new(self).calcPoints + CalculateWrestlerTeamScore.new(self).placementPoints end def totalDeductedPoints - points = 0 - self.deductedPoints.each do |d| - points = points + d.points - end - points + CalculateWrestlerTeamScore.new(self).deductedPoints end def nextMatch @@ -88,15 +79,15 @@ class Wrestler < ActiveRecord::Base end def resultByBout(bout) - @match = allMatches.select{|m| m.bout_number == bout and m.finished == 1} - if @match.size == 0 + bout_match = allMatches.select{|m| m.bout_number == bout and m.finished == 1} + if bout_match.size == 0 return "" end - if @match.first.winner_id == self.id - return "W #{@match.first.bracketScore}" + if bout_match.first.winner_id == self.id + return "W #{bout_match.first.bracketScore}" end - if @match.first.winner_id != self.id - return "L #{@match.first.bracketScore}" + if bout_match.first.winner_id != self.id + return "L #{bout_match.first.bracketScore}" end end @@ -113,26 +104,25 @@ class Wrestler < ActiveRecord::Base end def generatePoolNumber - @pool = self.weight.returnPoolNumber(self) + self.weight.returnPoolNumber(self) end def boutByRound(round) - @match = allMatches.select{|m| m.round == round}.first - if @match.blank? + round_match = allMatches.select{|m| m.round == round}.first + if round_match.blank? return "BYE" else - return @match.bout_number + return round_match.bout_number end end def allMatches - @matches = matches.select{|m| m.w1 == self.id or m.w2 == self.id} - return @matches + return matches.select{|m| m.w1 == self.id or m.w2 == self.id} end def poolMatches - @poolMatches = allMatches.select{|m| m.bracket_position == "Pool"} - @poolMatches.select{|m| m.poolNumber == self.generatePoolNumber} + pool_matches = allMatches.select{|m| m.bracket_position == "Pool"} + pool_matches.select{|m| m.poolNumber == self.generatePoolNumber} end def championshipAdvancementWins @@ -213,7 +203,4 @@ class Wrestler < ActiveRecord::Base end end - def advanceInBracket(match) - PoolAdvance.new(self,match).advanceWrestler - end end diff --git a/app/services/bracket_advancement/advance_wrestler.rb b/app/services/bracket_advancement/advance_wrestler.rb new file mode 100644 index 0000000..b7ec03c --- /dev/null +++ b/app/services/bracket_advancement/advance_wrestler.rb @@ -0,0 +1,14 @@ +class AdvanceWrestler + def initialize( wrestler ) + @wrestler = wrestler + @tournament = @wrestler.tournament + end + + def advance + PoolAdvance.new(@wrestler,@wrestler.lastMatch).advanceWrestler if @tournament.tournament_type == "Pool to bracket" + end + if Rails.env.production? + handle_asynchronously :advance + end + +end \ No newline at end of file diff --git a/app/services/tournament_services/generate_tournament_matches.rb b/app/services/tournament_services/generate_tournament_matches.rb index 4ffdb34..dcf3dd8 100644 --- a/app/services/tournament_services/generate_tournament_matches.rb +++ b/app/services/tournament_services/generate_tournament_matches.rb @@ -9,6 +9,9 @@ class GenerateTournamentMatches postMatchCreationActions PoolToBracketMatchGeneration.new(@tournament).assignLoserNames if @tournament.tournament_type == "Pool to bracket" end + if Rails.env.production? + handle_asynchronously :generate + end def standardStartingActions @tournament.curently_generating_matches = 1 diff --git a/app/services/wrestler_services/calculate_wrestler_team_score.rb b/app/services/wrestler_services/calculate_wrestler_team_score.rb new file mode 100644 index 0000000..fc7b0d8 --- /dev/null +++ b/app/services/wrestler_services/calculate_wrestler_team_score.rb @@ -0,0 +1,47 @@ +class CalculateWrestlerTeamScore + def initialize( wrestler ) + @wrestler = wrestler + @tournament = @wrestler.tournament + end + + def totalScore + if @wrestler.extra + return 0 + else + earnedPoints - deductedPoints + end + end + + def earnedPoints + return poolPoints + bracketPoints + placementPoints + bonusWinPoints + end + + def deductedPoints + points = 0 + @wrestler.deductedPoints.each do |d| + points = points + d.points + end + points + end + + def placementPoints + PoolBracketPlacementPoints.new(@wrestler).calcPoints if @tournament.tournament_type == "Pool to bracket" + end + + def bracketPoints + (@wrestler.championshipAdvancementWins.size * 2) + (@wrestler.consoAdvancementWins.size * 1) + end + + def poolPoints + if @tournament.tournament_type == "Pool to bracket" + (@wrestler.poolWins.size * 2) + else + 0 + end + end + + def bonusWinPoints + (@wrestler.pinWins.size * 2) + (@wrestler.techWins.size * 1.5) + (@wrestler.majorWins.size * 1) + end + +end \ No newline at end of file From a14d750f135ea84e06ffaf1af41624e0452c2000 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 6 Jul 2016 02:07:52 +0000 Subject: [PATCH 41/46] Added docker ignore --- .dockerignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5ffbd26 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +./.git \ No newline at end of file From bbb745564eafc2110614d870ce8d83d1d9e8ee7d Mon Sep 17 00:00:00 2001 From: jcwimer Date: Fri, 9 Sep 2016 17:51:00 +0000 Subject: [PATCH 42/46] Re-generating one weight classes matches - NEED TO REFACTOR and NEED TO WRITE TESTS Code is repeated in the following classes: GenerateTournamentMatches PoolToBracketMatchGeneration PoolToBracketGenerateLoserNames WipeTournamentMatches --- app/controllers/weights_controller.rb | 9 ++++++-- .../generate_tournament_matches.rb | 21 ++++++++++++++++++- .../pool_to_bracket_generate_loser_names.rb | 12 +++++++++++ .../pool_to_bracket_match_generation.rb | 8 ++++++- .../wipe_tournament_matches.rb | 4 ++++ app/views/weights/re_gen.html.erb | 3 +++ app/views/weights/show.html.erb | 3 +++ config/routes.rb | 1 + db/schema.rb | 2 +- 9 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 app/views/weights/re_gen.html.erb diff --git a/app/controllers/weights_controller.rb b/app/controllers/weights_controller.rb index 54bc317..02e17af 100644 --- a/app/controllers/weights_controller.rb +++ b/app/controllers/weights_controller.rb @@ -1,6 +1,6 @@ class WeightsController < ApplicationController - before_action :set_weight, only: [:show, :edit, :update, :destroy] - before_filter :check_access, only: [:new,:create,:update,:destroy,:edit] + before_action :set_weight, only: [:show, :edit, :update, :destroy,:re_gen] + before_filter :check_access, only: [:new,:create,:update,:destroy,:edit, :re_gen] # GET /weights/1 @@ -69,6 +69,11 @@ class WeightsController < ApplicationController format.json { head :no_content } end end + + def re_gen + @tournament = @weight.tournament + GenerateTournamentMatches.new(@tournament).generateWeight(@weight) + end private # Use callbacks to share common setup or constraints between actions. diff --git a/app/services/tournament_services/generate_tournament_matches.rb b/app/services/tournament_services/generate_tournament_matches.rb index dcf3dd8..2deda40 100644 --- a/app/services/tournament_services/generate_tournament_matches.rb +++ b/app/services/tournament_services/generate_tournament_matches.rb @@ -2,6 +2,19 @@ class GenerateTournamentMatches def initialize( tournament ) @tournament = tournament end + + def generateWeight(weight) + WipeTournamentMatches.new(@tournament).wipeWeightMatches(weight) + @tournament.curently_generating_matches = 1 + @tournament.save + unAssignBouts + PoolToBracketMatchGeneration.new(@tournament).generatePoolToBracketMatchesWeight(weight) if @tournament.tournament_type == "Pool to bracket" + postMatchCreationActions + PoolToBracketGenerateLoserNames.new(@tournament).assignLoserNamesWeight(weight) if @tournament.tournament_type == "Pool to bracket" + end + if Rails.env.production? + handle_asynchronously :generateWeight + end def generate standardStartingActions @@ -57,7 +70,13 @@ class GenerateTournamentMatches end end - + def unAssignBouts + bout_counts = Hash.new(0) + @tournament.matches.each do |m| + m.bout_number = nil + m.save! + end + end diff --git a/app/services/tournament_services/pool_to_bracket_generate_loser_names.rb b/app/services/tournament_services/pool_to_bracket_generate_loser_names.rb index d315c04..49b98fc 100644 --- a/app/services/tournament_services/pool_to_bracket_generate_loser_names.rb +++ b/app/services/tournament_services/pool_to_bracket_generate_loser_names.rb @@ -3,6 +3,18 @@ class PoolToBracketGenerateLoserNames @tournament = tournament end + def assignLoserNamesWeight(weight) + matches_by_weight = @tournament.matches.where(weight_id: weight.id) + if weight.pool_bracket_type == "twoPoolsToSemi" + twoPoolsToSemiLoser(matches_by_weight) + elsif weight.pool_bracket_type == "fourPoolsToQuarter" + fourPoolsToQuarterLoser(matches_by_weight) + elsif weight.pool_bracket_type == "fourPoolsToSemi" + fourPoolsToSemiLoser(matches_by_weight) + end + saveMatches(matches_by_weight) + end + def assignLoserNames matches_by_weight = nil @tournament.weights.each do |w| diff --git a/app/services/tournament_services/pool_to_bracket_match_generation.rb b/app/services/tournament_services/pool_to_bracket_match_generation.rb index 31e9388..a961895 100644 --- a/app/services/tournament_services/pool_to_bracket_match_generation.rb +++ b/app/services/tournament_services/pool_to_bracket_match_generation.rb @@ -3,7 +3,13 @@ class PoolToBracketMatchGeneration @tournament = tournament end - + def generatePoolToBracketMatchesWeight(weight) + PoolGeneration.new(weight).generatePools() + last_match = @tournament.matches.where(weight: weight).order(round: :desc).limit(1).first + highest_round = last_match.round + PoolBracketGeneration.new(weight, highest_round).generateBracketMatches() + setOriginalSeedsToWrestleLastPoolRound(weight) + end def generatePoolToBracketMatches @tournament.weights.order(:max).each do |weight| diff --git a/app/services/tournament_services/wipe_tournament_matches.rb b/app/services/tournament_services/wipe_tournament_matches.rb index e77c0cb..1738a8c 100644 --- a/app/services/tournament_services/wipe_tournament_matches.rb +++ b/app/services/tournament_services/wipe_tournament_matches.rb @@ -9,6 +9,10 @@ class WipeTournamentMatches resetSchoolScores end + def wipeWeightMatches(weight) + weight.matches.destroy_all + end + def wipeMatches @tournament.matches.destroy_all end diff --git a/app/views/weights/re_gen.html.erb b/app/views/weights/re_gen.html.erb new file mode 100644 index 0000000..c1aaac8 --- /dev/null +++ b/app/views/weights/re_gen.html.erb @@ -0,0 +1,3 @@ +<%= link_to "Back to #{@weight.tournament.name}", "/tournaments/#{@weight.tournament.id}", :class=>"btn btn-default" %> +

    +<%= @weight.max %> lbs Matches are being generated. This can take anywhere from 1-5 minutes to finish. It is recommended to delete all delegated school permissions to prevent lineup changes after the tournament has started. \ No newline at end of file diff --git a/app/views/weights/show.html.erb b/app/views/weights/show.html.erb index e65339c..c57c886 100644 --- a/app/views/weights/show.html.erb +++ b/app/views/weights/show.html.erb @@ -4,6 +4,9 @@ <%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %> <% if can? :manage, @tournament %> | <%= link_to "Edit #{@weight.max} Weight Class", edit_weight_path(@weight), :class=>"btn btn-primary" %> + | <%= form_for(@weight, url: regen_weight_path(@weight.id), :method => "post") do |f| %> + <%= submit_tag "Regenerate Weight Class Matches", :class=>"btn"%> + <% end %> <% end %>
    diff --git a/config/routes.rb b/config/routes.rb index 94cc729..8a0b0c2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -51,6 +51,7 @@ Wrestling::Application.routes.draw do get 'tournaments/:id/error' => 'tournaments#error' post "/tournaments/:id/swap" => "tournaments#swap", :as => :swap_wrestlers + post 'weights/:id/re_gen' => 'weights#re_gen', :as => :regen_weight #API get "/api/tournaments" => "api#tournaments" diff --git a/db/schema.rb b/db/schema.rb index e320d6e..f37635e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160126173424) do +ActiveRecord::Schema.define(version: 20160112152946) do create_table "delayed_jobs", force: :cascade do |t| t.integer "priority", default: 0, null: false From 67c64e94d1d30cf53002fc6a388c93973a310575 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Thu, 8 Dec 2016 13:40:05 -0500 Subject: [PATCH 43/46] Fixed dev dockerfile to start up quicker by not adding the rails code. This code gets mounted instead with rails-dev.sh. Added git logs and node_modules folder to dockerignore. Added node_modules folder to gitignore. --- .dockerignore | 4 +++- .gitignore | 1 + rails-dev-Dockerfile | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 5ffbd26..6f794ee 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,3 @@ -./.git \ No newline at end of file +.git +frontend/node_modules +log \ No newline at end of file diff --git a/.gitignore b/.gitignore index b057d17..a096644 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ /tmp .rvmrc /deploy/prod.env +frontend/node_modules diff --git a/rails-dev-Dockerfile b/rails-dev-Dockerfile index 6626f8b..fd70897 100644 --- a/rails-dev-Dockerfile +++ b/rails-dev-Dockerfile @@ -18,7 +18,7 @@ RUN npm install -g lineman RUN mkdir /rails WORKDIR /rails -ADD . /rails +#ADD . /rails VOLUME ["/rails"] From c16ec26ecb1435acd57a982793e4f23262261c09 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Tue, 17 Jan 2017 03:30:20 +0000 Subject: [PATCH 44/46] Re-added source code to the dev docker image for jenkins to use --- rails-dev-Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rails-dev-Dockerfile b/rails-dev-Dockerfile index fd70897..6626f8b 100644 --- a/rails-dev-Dockerfile +++ b/rails-dev-Dockerfile @@ -18,7 +18,7 @@ RUN npm install -g lineman RUN mkdir /rails WORKDIR /rails -#ADD . /rails +ADD . /rails VOLUME ["/rails"] From b7775172a34e21325e343a3b4d2be337ec053ca0 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Tue, 17 Jan 2017 03:32:38 +0000 Subject: [PATCH 45/46] Updated active record and ruby version --- Gemfile.lock | 5 ++++- db/schema.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 98334b4..c4d6ee0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -220,5 +220,8 @@ DEPENDENCIES turbolinks uglifier (>= 1.3.0) +RUBY VERSION + ruby 2.3.0p0 + BUNDLED WITH - 1.11.2 + 1.13.5 diff --git a/db/schema.rb b/db/schema.rb index f37635e..e320d6e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160112152946) do +ActiveRecord::Schema.define(version: 20160126173424) do create_table "delayed_jobs", force: :cascade do |t| t.integer "priority", default: 0, null: false From d7c82a8d710d7b9eadff753683d4b6deef41d096 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Wed, 18 Jan 2017 13:53:17 +0000 Subject: [PATCH 46/46] Fixed bug on wrestler form to allow a tournament director to move a wrestler to another school --- app/controllers/wrestlers_controller.rb | 1 + app/views/wrestlers/_form.html.erb | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/wrestlers_controller.rb b/app/controllers/wrestlers_controller.rb index 2a6caa8..e83a7c6 100644 --- a/app/controllers/wrestlers_controller.rb +++ b/app/controllers/wrestlers_controller.rb @@ -31,6 +31,7 @@ class WrestlersController < ApplicationController def edit @weight = @wrestler.weight @weights = @school.tournament.weights.sort_by{|w| w.max} + @school = @wrestler.school end # POST /wrestlers diff --git a/app/views/wrestlers/_form.html.erb b/app/views/wrestlers/_form.html.erb index b827403..bb1a141 100644 --- a/app/views/wrestlers/_form.html.erb +++ b/app/views/wrestlers/_form.html.erb @@ -17,14 +17,12 @@ <%= f.text_field :name %> <% if can? :manage, @wrestler.tournament %> - <% if @tournament %> - <%= f.hidden_field :school_id, :value => @school.id %> - <% else %>
    <%= f.label 'School' %>
    <%= f.collection_select :school_id, @school.tournament.schools, :id, :name %>
    - <% end %> + <% else %> + <%= f.hidden_field :school_id, :value => @school.id %> <% end %>
    <%= f.label 'Weight Class' %>
    Round