diff --git a/bin/yacs-purge-development b/bin/yacs-purge-development index 914b101f..b7f385ad 100755 --- a/bin/yacs-purge-development +++ b/bin/yacs-purge-development @@ -6,5 +6,8 @@ bin/yacs-compose-development stop kafka zookeeper redis core-consumer bin/yacs-compose-development rm -vf kafka bin/yacs-compose-development rm -vf zookeeper bin/yacs-compose-development rm -vf redis +echo "Term.create(shortname: \"201901\", longname: \"Spring 2019\")" | bin/yacs-compose-development run --rm core rails c echo "Term.create(shortname: \"202009\", longname: \"Fall 2020\")" | bin/yacs-compose-development run --rm core rails c -# echo "Term.create(shortname: \"201901\", longname: \"Spring 2019\")" | bin/yacs-compose-development run --rm core rails c +echo "Term.create(shortname: \"202101\", longname: \"Spring 2021\")" | bin/yacs-compose-development run --rm core rails c +echo "Term.create(shortname: \"202105\", longname: \"Summer 2021\")" | bin/yacs-compose-development run --rm core rails c +echo "Term.create(shortname: \"202109\", longname: \"Fall 2021\")" | bin/yacs-compose-development run --rm core rails c diff --git a/bin/yacs-purge-production b/bin/yacs-purge-production index 21119ed2..358a2828 100755 --- a/bin/yacs-purge-production +++ b/bin/yacs-purge-production @@ -6,4 +6,8 @@ bin/yacs-compose-production stop kafka zookeeper redis core-consumer bin/yacs-compose-production rm -vf kafka bin/yacs-compose-production rm -vf zookeeper bin/yacs-compose-production rm -vf redis +echo "Term.create(shortname: \"201901\", longname: \"Spring 2019\")" | bin/yacs-compose-production run --rm core rails c echo "Term.create(shortname: \"202009\", longname: \"Fall 2020\")" | bin/yacs-compose-production run --rm core rails c +echo "Term.create(shortname: \"202101\", longname: \"Spring 2021\")" | bin/yacs-compose-production run --rm core rails c +echo "Term.create(shortname: \"202105\", longname: \"Summer 2021\")" | bin/yacs-compose-production run --rm core rails c +echo "Term.create(shortname: \"202109\", longname: \"Fall 2021\")" | bin/yacs-compose-production run --rm core rails c diff --git a/core/Gemfile b/core/Gemfile index 97fba25f..69b1e5e3 100644 --- a/core/Gemfile +++ b/core/Gemfile @@ -9,7 +9,8 @@ gem 'pg', '~> 0.21' # gem 'sass-rails', '~> 5.0' gem 'handlebars_assets' -gem 'sprockets-rails', :require => 'sprockets/railtie' +gem 'sprockets', '~> 3.7.2' +gem 'sprockets-rails', '~> 3.2.1', :require => 'sprockets/railtie' gem 'actionpack-page_caching' gem 'actionpack-action_caching' @@ -37,8 +38,7 @@ gem 'redis' gem 'redis-rails' gem 'redis-store', '~> 1.4.0' -gem 'karafka', '~> 1.2.1' -gem 'ruby-kafka', '~> 0.6.8' +gem 'karafka', '~> 1.3.0' gem 'rubyzip', '~> 1.3.0' gem 'listen' diff --git a/core/Gemfile.lock b/core/Gemfile.lock index 526d869f..c18cc44f 100644 --- a/core/Gemfile.lock +++ b/core/Gemfile.lock @@ -18,10 +18,10 @@ GEM rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionpack-action_caching (1.2.0) - actionpack (>= 4.0.0, < 6) - actionpack-page_caching (1.1.1) - actionpack (>= 4.0.0, < 6) + actionpack-action_caching (1.2.1) + actionpack (>= 4.0.0) + actionpack-page_caching (1.2.3) + actionpack (>= 5.0.0) actionview (5.1.4) activesupport (= 5.1.4) builder (~> 3.1) @@ -42,221 +42,256 @@ GEM i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.6.0) - public_suffix (>= 2.0.2, < 4.0) + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) arel (8.0.0) - backports (3.11.4) - binding_of_caller (0.8.0) + binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) - builder (3.2.3) + builder (3.2.4) byebug (2.7.0) columnize (~> 0.3) debugger-linecache (~> 1.2) - capybara (3.13.2) + capybara (3.35.3) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.2) + regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - childprocess (0.9.0) - ffi (~> 1.0, >= 1.0.11) + childprocess (3.0.0) cliver (0.3.2) - coderay (1.1.2) + coderay (1.1.3) columnize (0.9.0) - concurrent-ruby (1.1.4) - coveralls (0.8.22) + concurrent-ruby (1.1.8) + coveralls (0.8.23) json (>= 1.8, < 3) simplecov (~> 0.16.1) term-ansicolor (~> 1.3) - thor (~> 0.19.4) + thor (>= 0.19.4, < 2.0) tins (~> 1.6) - crass (1.0.4) + crass (1.0.6) crono (1.1.2) activerecord (>= 4.0) activesupport (>= 4.0) - cucumber (3.1.2) - builder (>= 2.1.2) - cucumber-core (~> 3.2.0) - cucumber-expressions (~> 6.0.1) - cucumber-wire (~> 0.0.1) - diff-lcs (~> 1.3) - gherkin (~> 5.1.0) - multi_json (>= 1.7.5, < 2.0) - multi_test (>= 0.1.2) - cucumber-core (3.2.1) - backports (>= 3.8.0) - cucumber-tag_expressions (~> 1.1.0) - gherkin (~> 5.0) - cucumber-expressions (6.0.1) - cucumber-rails (1.6.0) - capybara (>= 1.1.2, < 4) - cucumber (>= 3.0.2, < 4) - mime-types (>= 1.17, < 4) + cucumber (5.3.0) + builder (~> 3.2, >= 3.2.4) + cucumber-core (~> 8.0, >= 8.0.1) + cucumber-create-meta (~> 2.0, >= 2.0.2) + cucumber-cucumber-expressions (~> 10.3, >= 10.3.0) + cucumber-gherkin (~> 15.0, >= 15.0.2) + cucumber-html-formatter (~> 9.0, >= 9.0.0) + cucumber-messages (~> 13.1, >= 13.1.0) + cucumber-wire (~> 4.0, >= 4.0.1) + diff-lcs (~> 1.4, >= 1.4.4) + multi_test (~> 0.1, >= 0.1.2) + sys-uname (~> 1.2, >= 1.2.1) + cucumber-core (8.0.1) + cucumber-gherkin (~> 15.0, >= 15.0.2) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-tag-expressions (~> 2.0, >= 2.0.4) + cucumber-create-meta (2.0.4) + cucumber-messages (~> 13.1, >= 13.1.0) + sys-uname (~> 1.2, >= 1.2.1) + cucumber-cucumber-expressions (10.3.0) + cucumber-gherkin (15.0.2) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-html-formatter (9.0.0) + cucumber-messages (~> 13.0, >= 13.0.1) + cucumber-messages (13.2.1) + protobuf-cucumber (~> 3.10, >= 3.10.8) + cucumber-rails (2.2.0) + capybara (>= 2.18, < 4) + cucumber (>= 3.0.2, < 6) + mime-types (~> 3.2) nokogiri (~> 1.8) - railties (>= 4, < 6) - cucumber-tag_expressions (1.1.1) - cucumber-wire (0.0.1) - database_cleaner (1.7.0) - debug_inspector (0.0.3) + rails (>= 5.0, < 7) + cucumber-tag-expressions (2.0.4) + cucumber-wire (4.0.1) + cucumber-core (~> 8.0, >= 8.0.1) + cucumber-cucumber-expressions (~> 10.3, >= 10.3.0) + cucumber-messages (~> 13.0, >= 13.0.1) + database_cleaner (2.0.1) + database_cleaner-active_record (~> 2.0.0) + database_cleaner-active_record (2.0.0) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0.0) + database_cleaner-core (2.0.1) + debug_inspector (1.0.0) debugger-linecache (1.2.0) - delivery_boy (0.2.7) - king_konf (~> 0.2) - ruby-kafka (~> 0.5) - diff-lcs (1.3) - docile (1.3.1) - dry-configurable (0.7.0) + delivery_boy (1.1.0) + king_konf (~> 1.0) + ruby-kafka (~> 1.0) + diff-lcs (1.4.4) + digest-crc (0.6.3) + rake (>= 12.0.0, < 14.0.0) + docile (1.3.5) + dry-configurable (0.12.1) concurrent-ruby (~> 1.0) - dry-container (0.6.0) + dry-core (~> 0.5, >= 0.5.0) + dry-container (0.7.2) concurrent-ruby (~> 1.0) dry-configurable (~> 0.1, >= 0.1.3) - dry-core (0.4.7) + dry-core (0.5.0) concurrent-ruby (~> 1.0) - dry-equalizer (0.2.1) - dry-events (0.1.0) + dry-equalizer (0.3.0) + dry-events (0.2.0) concurrent-ruby (~> 1.0) dry-core (~> 0.4) dry-equalizer (~> 0.2) - dry-inflector (0.1.2) - dry-logic (0.5.0) - dry-container (~> 0.2, >= 0.2.6) - dry-core (~> 0.2) - dry-equalizer (~> 0.2) - dry-monitor (0.3.0) + dry-inflector (0.2.0) + dry-initializer (3.0.4) + dry-logic (1.1.0) + concurrent-ruby (~> 1.0) + dry-core (~> 0.5, >= 0.5) + dry-monitor (0.3.2) dry-configurable (~> 0.5) dry-core (~> 0.4) dry-equalizer (~> 0.2) - dry-events (~> 0.1) - dry-types (0.14.0) + dry-events (~> 0.2) + dry-schema (1.6.1) + concurrent-ruby (~> 1.0) + dry-configurable (~> 0.8, >= 0.8.3) + dry-core (~> 0.5, >= 0.5) + dry-initializer (~> 3.0) + dry-logic (~> 1.0) + dry-types (~> 1.5) + dry-types (1.5.1) concurrent-ruby (~> 1.0) dry-container (~> 0.3) - dry-core (~> 0.4, >= 0.4.4) - dry-equalizer (~> 0.2) + dry-core (~> 0.5, >= 0.5) dry-inflector (~> 0.1, >= 0.1.2) - dry-logic (~> 0.5, >= 0.5) - dry-validation (0.13.0) + dry-logic (~> 1.0, >= 1.0.2) + dry-validation (1.6.0) concurrent-ruby (~> 1.0) - dry-configurable (~> 0.1, >= 0.1.3) - dry-core (~> 0.2, >= 0.2.1) + dry-container (~> 0.7, >= 0.7.1) + dry-core (~> 0.4) dry-equalizer (~> 0.2) - dry-logic (~> 0.5, >= 0.5.0) - dry-types (~> 0.14, >= 0.14) - envlogic (1.1.0) + dry-initializer (~> 3.0) + dry-schema (~> 1.5, >= 1.5.2) + envlogic (1.1.2) dry-inflector (~> 0.1) - erubi (1.8.0) + erubi (1.10.0) execjs (2.7.0) - factory_bot (5.0.0) - activesupport (>= 4.2.0) - factory_bot_rails (5.0.0) - factory_bot (~> 5.0.0) - railties (>= 4.2.0) - faker (1.9.1) - i18n (>= 0.7) - ffi (1.10.0) - gherkin (5.1.0) + factory_bot (6.1.0) + activesupport (>= 5.0.0) + factory_bot_rails (6.1.0) + factory_bot (~> 6.1.0) + railties (>= 5.0.0) + faker (2.2.1) + i18n (>= 0.8) + ffi (1.15.0) globalid (0.4.2) activesupport (>= 4.2.0) - graphiti (1.0.rc.12) - activesupport (>= 4.1, < 6) + graphiti (1.2.33) + activesupport (>= 4.1) concurrent-ruby (~> 1.0) - dry-types (~> 0.13) - graphiti_errors (~> 1.0.beta.1) + dry-types (>= 0.15.0, < 2.0) + graphiti_errors (~> 1.1.0) + jsonapi-renderer (~> 0.2, >= 0.2.2) jsonapi-serializable (~> 0.3.0) - graphiti_errors (1.0.beta.2) + graphiti_errors (1.1.2) jsonapi-serializable (~> 0.1) - graphiti_spec_helpers (1.0.beta.4) + graphiti_spec_helpers (1.0.5) graphiti (>= 1.0.alpha.1) rspec (~> 3.0) - handlebars_assets (0.23.2) + handlebars_assets (0.23.8) execjs (~> 2.0) sprockets (>= 2.0.0) tilt (>= 1.2) httpclient (2.8.3) i18n (0.9.5) concurrent-ruby (~> 1.0) - jbuilder (2.8.0) - activesupport (>= 4.2.0) - multi_json (>= 1.2) - json (2.1.0) + io-console (0.5.8) + irb (1.3.4) + reline (>= 0.1.5) + jbuilder (2.11.2) + activesupport (>= 5.0.0) + json (2.5.1) json-schema (2.8.1) addressable (>= 2.4) - jsonapi-renderer (0.2.0) - jsonapi-serializable (0.3.0) + jsonapi-renderer (0.2.2) + jsonapi-serializable (0.3.1) jsonapi-renderer (~> 0.2.0) - kaminari (1.1.1) + kaminari (1.2.1) activesupport (>= 4.1.0) - kaminari-actionview (= 1.1.1) - kaminari-activerecord (= 1.1.1) - kaminari-core (= 1.1.1) - kaminari-actionview (1.1.1) + kaminari-actionview (= 1.2.1) + kaminari-activerecord (= 1.2.1) + kaminari-core (= 1.2.1) + kaminari-actionview (1.2.1) actionview - kaminari-core (= 1.1.1) - kaminari-activerecord (1.1.1) + kaminari-core (= 1.2.1) + kaminari-activerecord (1.2.1) activerecord - kaminari-core (= 1.1.1) - kaminari-core (1.1.1) - karafka (1.2.10) - activesupport (>= 4.0) - dry-configurable (~> 0.7) + kaminari-core (= 1.2.1) + kaminari-core (1.2.1) + karafka (1.3.7) + dry-configurable (~> 0.8) dry-inflector (~> 0.1) - dry-monitor (~> 0.1) - dry-validation (~> 0.11) - envlogic (~> 1.0) + dry-monitor (~> 0.3) + dry-validation (~> 1.2) + envlogic (~> 1.1) + irb (~> 1.0) multi_json (>= 1.12) rake (>= 11.3) - require_all (>= 1.4) - ruby-kafka (>= 0.6) - thor (~> 0.19) - waterdrop (~> 1.2.4) - king_konf (0.3.7) + ruby-kafka (>= 1.0.0) + thor (>= 0.20) + waterdrop (~> 1.3.0) + zeitwerk (~> 2.1) + king_konf (1.0.0) libv8 (3.16.14.19) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - loofah (2.2.3) + listen (3.4.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + loofah (2.9.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - method_source (0.9.2) - mime-types (3.2.2) + method_source (1.0.0) + middleware (0.1.0) + mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2018.0812) - mini_mime (1.0.1) - mini_portile2 (2.4.0) - minitest (5.11.3) - multi_json (1.13.1) + mime-types-data (3.2021.0225) + mini_mime (1.0.2) + mini_portile2 (2.5.0) + minitest (5.14.4) + multi_json (1.15.0) multi_test (0.1.2) - newrelic_rpm (6.0.0.351) - nio4r (2.3.1) - nokogiri (1.10.1) - mini_portile2 (~> 2.4.0) - null-logger (0.1.5) + newrelic_rpm (6.15.0) + nio4r (2.5.7) + nokogiri (1.11.1) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) pg (0.21.0) - pickle (0.5.5) - cucumber (>= 0.8, < 4.0) + pickle (0.6.0) + cucumber (>= 3.0, < 6.0) rake poltergeist (1.18.1) capybara (>= 2.1, < 4) cliver (~> 0.3.1) websocket-driver (>= 0.2.0) - pry (0.12.2) - coderay (~> 1.1.0) - method_source (~> 0.9.0) + protobuf-cucumber (3.10.8) + activesupport (>= 3.2) + middleware + thor + thread_safe + pry (0.14.0) + coderay (~> 1.1) + method_source (~> 1.0) pry-byebug (1.3.3) byebug (~> 2.7) pry (~> 0.10) pry-remote (0.1.8) pry (~> 0.9) slop (~> 3.0) - pry-stack_explorer (0.4.9.3) - binding_of_caller (>= 0.7) - pry (>= 0.9.11) - public_suffix (3.0.3) + pry-stack_explorer (0.6.1) + binding_of_caller (~> 1.0) + pry (~> 0.13) + public_suffix (4.0.6) puma (3.11.0) - rack (2.0.8) + racc (1.5.2) + rack (2.2.3) rack-test (1.1.0) rack (>= 1.0, < 3) railroady (1.5.3) @@ -275,8 +310,8 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) rails-observers (0.1.5) activemodel (>= 4.0) railties (5.1.4) @@ -285,20 +320,20 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (12.3.2) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) + rake (13.0.3) + rb-fsevent (0.10.4) + rb-inotify (0.10.1) ffi (~> 1.0) - redis (4.1.0) - redis-actionpack (5.0.2) - actionpack (>= 4.0, < 6) - redis-rack (>= 1, < 3) + redis (4.2.5) + redis-actionpack (5.2.0) + actionpack (>= 5, < 7) + redis-rack (>= 2.1.0, < 3) redis-store (>= 1.1.0, < 2) - redis-activesupport (5.0.7) - activesupport (>= 3, < 6) + redis-activesupport (5.2.0) + activesupport (>= 3, < 7) redis-store (>= 1.3, < 2) - redis-rack (2.0.5) - rack (>= 1.5, < 3) + redis-rack (2.1.3) + rack (>= 2.0.8, < 3) redis-store (>= 1.2, < 2) redis-rails (5.0.2) redis-actionpack (>= 5.0, < 6) @@ -307,74 +342,78 @@ GEM redis-store (1.4.1) redis (>= 2.2, < 5) ref (2.0.0) - regexp_parser (1.3.0) - require_all (2.0.0) - responders (2.4.1) - actionpack (>= 4.2.0, < 6.0) - railties (>= 4.2.0, < 6.0) - rspec (3.8.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.2) + regexp_parser (2.1.1) + reline (0.2.4) + io-console (~> 0.5) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) + rspec-core (3.10.1) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.1) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) - ruby-kafka (0.6.8) - ruby_dep (1.5.0) + rspec-support (~> 3.10.0) + rspec-rails (4.1.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.10.2) + ruby-kafka (1.3.0) + digest-crc rubyzip (1.3.0) - selenium-webdriver (3.141.0) - childprocess (~> 0.5) - rubyzip (~> 1.2, >= 1.2.2) + selenium-webdriver (3.142.7) + childprocess (>= 0.5, < 4.0) + rubyzip (>= 1.2.2) simplecov (0.16.1) docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) slop (3.6.0) - spring (2.0.2) - activesupport (>= 4.2) + spring (2.1.1) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) swagger-diff (1.1.2) json-schema (~> 2.6) rspec-expectations (~> 3.3) + sync (0.5.0) + sys-uname (1.2.2) + ffi (~> 1.1) term-ansicolor (1.7.1) tins (~> 1.0) therubyracer (0.12.3) libv8 (~> 3.16.14.15) ref - thor (0.19.4) + thor (1.1.0) thread_safe (0.3.6) - tilt (2.0.9) - tins (1.20.2) - tzinfo (1.2.5) + tilt (2.0.10) + tins (1.28.0) + sync + tzinfo (1.2.9) thread_safe (~> 0.1) - waterdrop (1.2.4) - delivery_boy (~> 0.2) - dry-configurable (~> 0.7) - dry-monitor (~> 0.1) - dry-validation (~> 0.11) - null-logger (~> 0.1) - ruby-kafka (>= 0.6) + waterdrop (1.3.4) + delivery_boy (>= 0.2, < 2.x) + dry-configurable (~> 0.8) + dry-monitor (~> 0.3) + dry-validation (~> 1.2) + ruby-kafka (>= 0.7.8) + zeitwerk (~> 2.1) web-console (2.3.0) activemodel (>= 4.0) binding_of_caller (>= 0.7.2) @@ -382,9 +421,10 @@ GEM sprockets-rails (>= 2.0, < 4.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) + websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.4.2) PLATFORMS ruby @@ -405,7 +445,7 @@ DEPENDENCIES httpclient jbuilder kaminari - karafka (~> 1.2.1) + karafka (~> 1.3.0) listen newrelic_rpm pg (~> 0.21) @@ -424,17 +464,17 @@ DEPENDENCIES redis-store (~> 1.4.0) responders rspec-rails - ruby-kafka (~> 0.6.8) rubyzip (~> 1.3.0) selenium-webdriver spring - sprockets-rails + sprockets (~> 3.7.2) + sprockets-rails (~> 3.2.1) swagger-diff therubyracer web-console (~> 2.0) RUBY VERSION - ruby 2.4.2p198 + ruby 2.6.3p62 BUNDLED WITH - 1.16.0 + 1.17.2 diff --git a/core/app/consumers/application_consumer.rb b/core/app/consumers/application_consumer.rb index 5dd3f147..d4b256d4 100644 --- a/core/app/consumers/application_consumer.rb +++ b/core/app/consumers/application_consumer.rb @@ -19,22 +19,18 @@ class ApplicationConsumer < Karafka::BaseConsumer { instructors: [], periods: %i(day start end type location) } }.with_indifferent_access.freeze - include Karafka::Consumers::Callbacks - - after_fetch do - @type = params['type'] - @method = params['method'] + def consume + @params = params['payload'] + @type = @params['type'] + @method = @params['method'] unless ALLOWED_TYPES.include? @type - STDERR.puts params + STDERR.puts @params throw "ERROR: Disallowed Type: #{@type}" end unless ALLOWED_METHODS.include? @method throw "ERROR: Disallowed Method: #{@method}" end @data = safe_params - end - - def consume begin send "transform_#{@type}" send "consume_#{@type}" @@ -86,7 +82,7 @@ def consume_section private def safe_params - safe_params = ActionController::Parameters.new params + safe_params = ActionController::Parameters.new @params safe_params.require(@type).permit(*ALLOWED_PARAMS[@type]) end diff --git a/docker-compose.development.yml b/docker-compose.development.yml index c1142957..98024ac6 100644 --- a/docker-compose.development.yml +++ b/docker-compose.development.yml @@ -25,7 +25,7 @@ services: build: ./core environment: - RAILS_ENV=development - - TERM_SHORTNAME=202009 + - TERM_SHORTNAME=201901,202009,202101,202105,202109 - UNI_SHORTNAME volumes: - ./core:/usr/src/app @@ -47,7 +47,7 @@ services: volumes: - "./malg:/usr/src/app" environment: - - TERM_SHORTNAME=202009 + - TERM_SHORTNAME=201901,202009,202101,202105,202109 - UNI_SHORTNAME # Dependency services diff --git a/malg/Gemfile b/malg/Gemfile index a6921fdf..9ba0ee23 100644 --- a/malg/Gemfile +++ b/malg/Gemfile @@ -12,5 +12,5 @@ gem 'sinatra' gem 'sinatra-contrib' gem 'rest-client' gem 'redis_orm' -gem 'waterdrop' -gem 'redis' \ No newline at end of file +gem 'waterdrop', '<2.0' +gem 'redis' diff --git a/pipelines/rpi/adapters/quacs-rpi/Dockerfile b/pipelines/rpi/adapters/quacs-rpi/Dockerfile new file mode 100644 index 00000000..c86cb943 --- /dev/null +++ b/pipelines/rpi/adapters/quacs-rpi/Dockerfile @@ -0,0 +1,13 @@ +FROM ruby:2.6.3 + +ENV INSTALL_PATH /usr/src/app/ +RUN mkdir -p $INSTALL_PATH + +WORKDIR $INSTALL_PATH + +COPY Gemfile Gemfile.lock $INSTALL_PATH +RUN bundle install + +COPY . $INSTALL_PATH + +CMD ["ruby", "app.rb"] diff --git a/pipelines/rpi/adapters/quacs-rpi/Gemfile b/pipelines/rpi/adapters/quacs-rpi/Gemfile new file mode 100644 index 00000000..fd5cd47c --- /dev/null +++ b/pipelines/rpi/adapters/quacs-rpi/Gemfile @@ -0,0 +1,9 @@ +source 'https://rubygems.org' + +ruby '2.6.3' + +gem 'sinatra' +gem 'sinatra-contrib' +gem 'oj' +gem 'httpclient' +gem 'pry' diff --git a/pipelines/rpi/adapters/quacs-rpi/Gemfile.lock b/pipelines/rpi/adapters/quacs-rpi/Gemfile.lock new file mode 100644 index 00000000..15715839 --- /dev/null +++ b/pipelines/rpi/adapters/quacs-rpi/Gemfile.lock @@ -0,0 +1,45 @@ +GEM + remote: https://rubygems.org/ + specs: + coderay (1.1.3) + httpclient (2.8.3) + method_source (1.0.0) + multi_json (1.15.0) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + oj (3.11.2) + pry (0.14.0) + coderay (~> 1.1) + method_source (~> 1.0) + rack (2.2.3) + rack-protection (2.1.0) + rack + ruby2_keywords (0.0.4) + sinatra (2.1.0) + mustermann (~> 1.0) + rack (~> 2.2) + rack-protection (= 2.1.0) + tilt (~> 2.0) + sinatra-contrib (2.1.0) + multi_json + mustermann (~> 1.0) + rack-protection (= 2.1.0) + sinatra (= 2.1.0) + tilt (~> 2.0) + tilt (2.0.10) + +PLATFORMS + ruby + +DEPENDENCIES + httpclient + oj + pry + sinatra + sinatra-contrib + +RUBY VERSION + ruby 2.6.3p62 + +BUNDLED WITH + 1.17.2 diff --git a/pipelines/rpi/adapters/quacs-rpi/app.rb b/pipelines/rpi/adapters/quacs-rpi/app.rb new file mode 100644 index 00000000..72c496e6 --- /dev/null +++ b/pipelines/rpi/adapters/quacs-rpi/app.rb @@ -0,0 +1,16 @@ +require 'sinatra' +require 'sinatra/json' +require 'oj' +require_relative 'quacs_client' +require 'pry' + +set :bind, '0.0.0.0' +set :port, 4600 + +get "/:term_shortname" do + json subjects: QuacsClient.new(params[:term_shortname]).listings_by_subject +end + +get "/seats/:term_shortname" do + json sections: QuacsClient.new(params[:term_shortname]).sections +end diff --git a/pipelines/rpi/adapters/quacs-rpi/quacs_client.rb b/pipelines/rpi/adapters/quacs-rpi/quacs_client.rb new file mode 100644 index 00000000..5f33aaa4 --- /dev/null +++ b/pipelines/rpi/adapters/quacs-rpi/quacs_client.rb @@ -0,0 +1,95 @@ +require 'httpclient' + +class QuacsClient + + def initialize term_shortname + @courses_uri = "https://raw.githubusercontent.com/quacs/quacs-data/master/semester_data/#{term_shortname}/courses.json" + @http_client = HTTPClient.new + end + + def sections + get_json(@courses_uri).map do |dept| + dept["courses"].map do |course| + course["sections"].map do |section| + { + :crn => section["crn"], + :shortname => section["crse"], + :seats => section["cap"], + :seats_taken => section["act"], + } + end + end + end.flatten + end + + def listings + get_json(@courses_uri).map do |dept| + dept["courses"].map do |course| + sections = course["sections"] + { + :min_credits => sections[0]["credMin"], + :max_credits => sections[0]["credMax"], + :shortname => course["crse"], + :longname => course["title"], + :subject => { shortname: course["subj"] }, + :sections => extract_sections(sections) + } + end + end.flatten + end + + def listings_by_subject + subjects = {} + listings.each do |listing| + subjects[listing[:subject][:shortname]] ||= [] + subjects[listing[:subject][:shortname]] << listing + listing.delete :subject + end + subjects.map { |k, v| { shortname: k, listings: v } } + end + + private + + def get_json uri + JSON.parse(@http_client.get(uri).body) + end + + def parse_instructors timeslot + timeslot["instructor"].split(", ") + end + + def parse_day day + "MTWRFSU".index(day) + 1 + end + + def parse_timeslot_day timeslot, day + { + :start => timeslot["timeStart"], + :end => timeslot["timeEnd"], + :instructor => parse_instructors(timeslot), + :location => timeslot["location"], + :day => parse_day(day), + } + end + + def parse_timeslots timeslots + timeslots.map do |timeslot| + timeslot["days"].map do |day| + parse_timeslot_day timeslot, day + end + end.flatten + end + + def extract_sections sections + sections.map do |section| + { + :shortname => section["crse"], + :crn => section["crn"], + :seats => section["cap"], + :seats_taken => section["act"], + :instructors => parse_instructors(section["timeslots"][0]), + :periods => parse_timeslots(section["timeslots"]), + } + end + end +end diff --git a/pipelines/rpi/config/sources.yml b/pipelines/rpi/config/sources.yml index f7806dc9..e0b7ca7b 100644 --- a/pipelines/rpi/config/sources.yml +++ b/pipelines/rpi/config/sources.yml @@ -1,7 +1,15 @@ -version: '1' +version: "1" sources: sources: + quacs: + location: http://adapter-quacs:4600 + poll: 43200 # 12 hours + root: subjects + quacs-seats: + location: http://adapter-quacs:4600/seats + poll: 43200 # 12 hours + root: sections acalog: location: http://adapter-acalog:4600 poll: 86400 # 1 day @@ -36,6 +44,8 @@ priorities: default: fields: # - admin + - quacs-seats + - quacs - banner-seats - csv-topics - acalog @@ -47,10 +57,11 @@ priorities: subjects: existence: yaml-schools listings: - existence: banner + existence: quacs fields: longname: # - admin + - quacs - csv-topics - acalog - banner @@ -59,13 +70,17 @@ priorities: - admin - acalog sections: - existence: banner + existence: quacs fields: seats: # - admin + - quacs-seats + - quacs - banner-seats - banner seats_available: # - admin + - quacs-seats + - quacs - banner-seats - banner diff --git a/pipelines/rpi/docker-compose.pipeline.development.yml b/pipelines/rpi/docker-compose.pipeline.development.yml index cb9debbc..15abe881 100644 --- a/pipelines/rpi/docker-compose.pipeline.development.yml +++ b/pipelines/rpi/docker-compose.pipeline.development.yml @@ -1,8 +1,9 @@ -version: '3.2' +version: "3.2" services: malg: links: + - adapter-quacs - adapter-acalog - adapter-banner - adapter-yaml @@ -10,6 +11,16 @@ services: volumes: - ./pipelines/${UNI_SHORTNAME}/config/sources.yml:/usr/src/app/config/sources.yml + adapter-quacs: + build: ./pipelines/${UNI_SHORTNAME}/adapters/quacs-rpi + expose: + - "4600" + ports: + - "4600:4600" + volumes: + - ./pipelines/${UNI_SHORTNAME}/adapters/quacs-rpi:/usr/src/app + tty: true + stdin_open: true adapter-acalog: build: ./pipelines/${UNI_SHORTNAME}/adapters/acalog-rpi expose: diff --git a/pipelines/rpi/docker-compose.pipeline.production.yml b/pipelines/rpi/docker-compose.pipeline.production.yml index 760a3b69..a248a7fa 100644 --- a/pipelines/rpi/docker-compose.pipeline.production.yml +++ b/pipelines/rpi/docker-compose.pipeline.production.yml @@ -1,8 +1,9 @@ -version: '3.2' +version: "3.2" services: malg: links: + - adapter-quacs - adapter-acalog - adapter-banner - adapter-yaml @@ -11,6 +12,10 @@ services: volumes: - ./pipelines/${UNI_SHORTNAME}/config/sources.yml:/usr/src/app/config/sources.yml + adapter-quacs: + build: ./pipelines/${UNI_SHORTNAME}/adapters/quacs-rpi + expose: + - "4600" adapter-acalog: build: ./pipelines/${UNI_SHORTNAME}/adapters/acalog-rpi expose: