diff --git a/Pearlception/.vscode/tasks.json b/Pearlception/.vscode/tasks.json new file mode 100644 index 0000000..ad6585c --- /dev/null +++ b/Pearlception/.vscode/tasks.json @@ -0,0 +1,12 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "taskName": "echo", + "command": "echo Hello", + "type": "shell" + } + ] +} \ No newline at end of file diff --git a/Pearlception/.yardoc/checksums b/Pearlception/.yardoc/checksums index 12f2e8b..9a429eb 100644 --- a/Pearlception/.yardoc/checksums +++ b/Pearlception/.yardoc/checksums @@ -1,5 +1,5 @@ lib/subdomain.rb 05d09bad9914c8468f62d18a7490bbff2a169e5b -app/models/run.rb d365dad32d163ba2cb7dd1fa3c990b4c4023aeef +app/models/run.rb 56667b48dc818963ee8e6576af6850be1388c4b9 app/models/user.rb efde248eefff583ab5d6cc0efb455d33cdf8e0f8 app/models/grade.rb 06b261d77e0f248d01783be7b756ef994287c386 app/models/oyster.rb 7e618ccfa0ed1fc599cb10c7f015d8b5ebdc7add @@ -23,10 +23,10 @@ app/controllers/runs_controller.rb cb314018e6aa86e0c9afc9d6a2fe563924000bca app/helpers/registrations_helper.rb 37b2a26d7a107fb24d0dc648ad6d739722dfec0f app/controllers/grades_controller.rb 30dc672b7759ad606bba5a9790a3c3bed7ac258d app/controllers/oysters_controller.rb eca3e0163cb4ec7f95c9f07f9991d1bd747fd52b -app/controllers/sessions_controller.rb 83c887b904faf26afafa69872dce1250e638f225 +app/controllers/sessions_controller.rb 5fe6b0a8ddd3859642258e3fbb2ce58db84efd14 app/controllers/companies_controller.rb 66866c361bc088440a0eb3a7704985171e4d96e6 app/controllers/dashboard_controller.rb f9e7b2eec29e56c58c16524dca676b087678ad02 -app/controllers/statistics_controller.rb 38331e4fe96e77828c9f2029fe35533e84679e1f +app/controllers/statistics_controller.rb bb0c96b7567285ca3c8a437ffcd8d8f95b3f1b51 app/channels/application_cable/channel.rb 54156ee2853cfdea4e3147cdb260776b8d90b646 app/controllers/application_controller.rb 7db6f6f427cff75fc496475e8f7226fc0d4deb88 app/controllers/registrations_controller.rb bcb576011beb61b83c113556afe5db1091aaf8a2 diff --git a/Pearlception/.yardoc/objects/root.dat b/Pearlception/.yardoc/objects/root.dat index 3b18c45..2dcc07c 100644 Binary files a/Pearlception/.yardoc/objects/root.dat and b/Pearlception/.yardoc/objects/root.dat differ diff --git a/Pearlception/Gemfile b/Pearlception/Gemfile index 07f5318..11ef0d7 100644 --- a/Pearlception/Gemfile +++ b/Pearlception/Gemfile @@ -48,6 +48,7 @@ gem 'rack-subdomain' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platform: :mri + gem 'meta_request' end group :development do diff --git a/Pearlception/Gemfile.lock b/Pearlception/Gemfile.lock index 3370f70..096b51f 100644 --- a/Pearlception/Gemfile.lock +++ b/Pearlception/Gemfile.lock @@ -53,6 +53,7 @@ GEM bootstrap-popover-rails (0.1.0) builder (3.2.2) byebug (9.0.6) + callsite (0.0.11) chart-js-rails (0.1.2) railties (> 3.1) coderay (1.1.1) @@ -110,6 +111,10 @@ GEM nokogiri (>= 1.5.9) mail (2.6.4) mime-types (>= 1.16, < 4) + meta_request (0.4.3) + callsite (~> 0.0, >= 0.0.11) + rack-contrib (>= 1.1, < 3) + railties (>= 3.0.0, < 5.2.0) method_source (0.8.2) mime-types (3.1) mime-types-data (~> 3.2015) @@ -136,6 +141,8 @@ GEM pry (>= 0.9.11) puma (3.6.2) rack (2.0.1) + rack-contrib (1.2.0) + rack (>= 0.9.1) rack-subdomain (0.0.2) rack-test (0.6.3) rack (>= 1.0) @@ -230,6 +237,7 @@ DEPENDENCIES jquery-ui-rails kaminari listen (~> 3.0.5) + meta_request mysql2 (>= 0.3.18, < 0.5) pry-byebug pry-stack_explorer @@ -245,4 +253,4 @@ DEPENDENCIES web-console (>= 3.3.0) BUNDLED WITH - 1.13.7 + 1.14.3 diff --git a/Pearlception/app/assets/javascripts/statistics.js b/Pearlception/app/assets/javascripts/statistics.js index 1911156..507a4dc 100644 --- a/Pearlception/app/assets/javascripts/statistics.js +++ b/Pearlception/app/assets/javascripts/statistics.js @@ -7,18 +7,46 @@ $('#to_datepicker').datepicker() $('#dateFilterButton').on('click',function(){ var fromDate = $('#from_datepicker')[0].value; var toDate = $('#to_datepicker')[0].value; - var queryString = ""; + var supplier = $('#supplier').find(":selected").text(); + var distributor = $('#distributor').find(":selected").text(); + var queryString = "statistics.json"; if(fromDate != "" && toDate != ""){ - queryString = "statistics.json/?from_date="+encodeURI(fromDate)+"&to_date="+encodeURI(toDate); - } - else{ - queryString = "statistics.json" - } + queryString = queryString + "/?from_date="+encodeURI(fromDate)+"&to_date="+encodeURI(toDate); + } + if(supplier != ""){ + if(queryString.includes("/")){ + queryString = queryString + "&supplier="+encodeURI(supplier); + }else{ + queryString = queryString + "/?supplier="+encodeURI(supplier); + } + } + + if(distributor != ""){ + if(queryString.includes("/")){ + queryString = queryString + "&distributor="+encodeURI(distributor); + }else{ + queryString = queryString + "/?distributor="+encodeURI(distributor); + } + } + $.get(queryString, function(gradeData){ constructGradesGraph(gradeData); }) }); +(function($){ $(window).on("load",function(){ + $('.filter-dropdown').find('.filter-form').click(function (e) { + e.stopPropagation(); + if ($(e.target).is('[name=supplier]')) { + $($(e.target).data('target')).modal() + } + }); +}); +})(jQuery); + + + + $(document).ready( $.get("statistics.json", function(gradeData){ constructGradesGraph(gradeData); diff --git a/Pearlception/app/controllers/sessions_controller.rb b/Pearlception/app/controllers/sessions_controller.rb index a437024..e2b9c03 100644 --- a/Pearlception/app/controllers/sessions_controller.rb +++ b/Pearlception/app/controllers/sessions_controller.rb @@ -1,3 +1,5 @@ +#@FIXME: When logging out users are prompted that there accounts have been cancelled when really they +#just logged out. class SessionsController < Devise::RegistrationsController include ApplicationHelper diff --git a/Pearlception/app/controllers/statistics_controller.rb b/Pearlception/app/controllers/statistics_controller.rb index 10b2ce4..7451754 100644 --- a/Pearlception/app/controllers/statistics_controller.rb +++ b/Pearlception/app/controllers/statistics_controller.rb @@ -1,13 +1,26 @@ class StatisticsController < ApplicationController def index + @suppliers = Supplier.all + @distributors = Distributor.all + #filterUsed = false + runs = Run.all if params[:from_date] != nil && params[:to_date] != nil from_date = Date.strptime(params[:from_date], '%m/%d/%Y') to_date = Date.strptime(params[:to_date], '%m/%d/%Y') - runs = Run.where(:runDate => from_date.beginning_of_day..to_date.end_of_day) - else - runs = Run.all + #runs = Run.where(:runDate => from_date.beginning_of_day..to_date.end_of_day) + runs = runs.by_date(from_date.beginning_of_day..to_date.end_of_day) end + + if params[:supplier] != nil + runs = runs.by_supplier(params[:supplier]) + end + + if params[:distributor] != nil + runs = runs.by_distributor(params[:distributor]) + end + # runs = Run.all + #end puts runs.inspect oysterData = [] all_oysters = [] diff --git a/Pearlception/app/models/run.rb b/Pearlception/app/models/run.rb index 8b28af0..93eb518 100644 --- a/Pearlception/app/models/run.rb +++ b/Pearlception/app/models/run.rb @@ -1,3 +1,6 @@ class Run < ApplicationRecord has_many :oysters + scope :by_date, lambda { |runDate| where(:runDate => runDate)} + scope :by_supplier, lambda { |supplier| where(:supplier => supplier)} + scope :by_distributor, lambda { |distributor| where(:distributor => distributor)} end diff --git a/Pearlception/app/views/oysters/index.html.erb b/Pearlception/app/views/oysters/index.html.erb index 54ede02..31d1aa6 100644 --- a/Pearlception/app/views/oysters/index.html.erb +++ b/Pearlception/app/views/oysters/index.html.erb @@ -61,7 +61,7 @@ -->
@FIXME: When logging out users are prompted that there accounts have been +cancelled when really they just logged out.
+-8 -9 10 11 12 @@ -215,10 +225,12 @@ 19 20 21 -22+22 +23 +24
# File 'app/controllers/sessions_controller.rb', line 8 +# File 'app/controllers/sessions_controller.rb', line 10 def create params = sign_in_params @@ -255,12 +267,12 @@-4 -5 -6+6 +7 +8
# File 'app/controllers/sessions_controller.rb', line 4 +# File 'app/controllers/sessions_controller.rb', line 6 def new super @@ -275,7 +287,7 @@ diff --git a/Pearlception/doc/SessionsHelper.html b/Pearlception/doc/SessionsHelper.html index f86087d..8857199 100644 --- a/Pearlception/doc/SessionsHelper.html +++ b/Pearlception/doc/SessionsHelper.html @@ -95,7 +95,7 @@ diff --git a/Pearlception/doc/StatisticsController.html b/Pearlception/doc/StatisticsController.html index 5e90c03..cae2f29 100644 --- a/Pearlception/doc/StatisticsController.html +++ b/Pearlception/doc/StatisticsController.html @@ -192,20 +192,46 @@ 21 22 23 -24+24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37
# File 'app/controllers/statistics_controller.rb', line 3 def index + @suppliers = Supplier.all + @distributors = Distributor.all + #filterUsed = false + runs = Run.all if params[:from_date] != nil && params[:to_date] != nil from_date = Date.strptime(params[:from_date], '%m/%d/%Y') to_date = Date.strptime(params[:to_date], '%m/%d/%Y') - runs = Run.where(:runDate => from_date.beginning_of_day..to_date.end_of_day) - else - runs = Run.all + #runs = Run.where(:runDate => from_date.beginning_of_day..to_date.end_of_day) + runs = runs.by_date(from_date.beginning_of_day..to_date.end_of_day) end - puts runs.inspect + + if params[:supplier] != nil + runs = runs.by_supplier(params[:supplier]) + end + + if params[:distributor] != nil + runs = runs.by_distributor(params[:distributor]) + end + # runs = Run.all + #end + puts runs.inspect oysterData = [] all_oysters = [] runs.each do |run| @@ -229,7 +255,7 @@ diff --git a/Pearlception/doc/StatisticsHelper.html b/Pearlception/doc/StatisticsHelper.html index 75cc8c8..b724ae0 100644 --- a/Pearlception/doc/StatisticsHelper.html +++ b/Pearlception/doc/StatisticsHelper.html @@ -95,7 +95,7 @@ diff --git a/Pearlception/doc/Subdomain.html b/Pearlception/doc/Subdomain.html index 6eb9591..d0b9fc0 100644 --- a/Pearlception/doc/Subdomain.html +++ b/Pearlception/doc/Subdomain.html @@ -202,7 +202,7 @@ diff --git a/Pearlception/doc/Supplier.html b/Pearlception/doc/Supplier.html index 455b3e7..a89ba67 100644 --- a/Pearlception/doc/Supplier.html +++ b/Pearlception/doc/Supplier.html @@ -122,7 +122,7 @@ diff --git a/Pearlception/doc/SuppliersDistributorsController.html b/Pearlception/doc/SuppliersDistributorsController.html index 360231d..b2dbe3c 100644 --- a/Pearlception/doc/SuppliersDistributorsController.html +++ b/Pearlception/doc/SuppliersDistributorsController.html @@ -677,7 +677,7 @@ diff --git a/Pearlception/doc/SuppliersDistributorsHelper.html b/Pearlception/doc/SuppliersDistributorsHelper.html index c86c158..f134acf 100644 --- a/Pearlception/doc/SuppliersDistributorsHelper.html +++ b/Pearlception/doc/SuppliersDistributorsHelper.html @@ -95,7 +95,7 @@ diff --git a/Pearlception/doc/User.html b/Pearlception/doc/User.html index c7b8aae..0b96eef 100644 --- a/Pearlception/doc/User.html +++ b/Pearlception/doc/User.html @@ -199,7 +199,7 @@ diff --git a/Pearlception/doc/_index.html b/Pearlception/doc/_index.html index 46dfa41..883b277 100644 --- a/Pearlception/doc/_index.html +++ b/Pearlception/doc/_index.html @@ -343,7 +343,7 @@ diff --git a/Pearlception/doc/file.README.html b/Pearlception/doc/file.README.html index 6d9576b..52ff165 100644 --- a/Pearlception/doc/file.README.html +++ b/Pearlception/doc/file.README.html @@ -86,7 +86,7 @@ application up and running. diff --git a/Pearlception/doc/index.html b/Pearlception/doc/index.html index 36ef6fa..b81fa98 100644 --- a/Pearlception/doc/index.html +++ b/Pearlception/doc/index.html @@ -86,7 +86,7 @@ application up and running. diff --git a/Pearlception/doc/top-level-namespace.html b/Pearlception/doc/top-level-namespace.html index 19f6c0d..079de3b 100644 --- a/Pearlception/doc/top-level-namespace.html +++ b/Pearlception/doc/top-level-namespace.html @@ -102,7 +102,7 @@