From 5cecfc8374b98c488aaccb10449c66abdb9a14a9 Mon Sep 17 00:00:00 2001 From: Jared Cosulich Date: Sat, 21 Jul 2018 12:10:36 -0400 Subject: [PATCH] linking between years --- app/controllers/categories_controller.rb | 5 ++++- app/views/layouts/_school_header.html.haml | 3 +++ db/schema.rb | 1 + lib/tasks/data.rake | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 3ac50346..0ea50dfb 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -13,7 +13,9 @@ class CategoriesController < ApplicationController def show district = @school.district authenticate(district.name.downcase, "#{district.name.downcase}!") - @year = (params[:year] || "2017").to_i + school_categories = SchoolCategory.for(@school, @category) + @years = school_categories.map(&:year) + @year = (params[:year] || @years.first).to_i @school_category = SchoolCategory.for(@school, @category).in(@year).first @child_school_categories = SchoolCategory.for_parent_category(@school, @category).valid @questions = @category.questions @@ -82,5 +84,6 @@ class CategoriesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def category_params params.require(:category).permit(:name, :blurb, :description, :external_id, :parent_category_id) + raise params.inspect end end diff --git a/app/views/layouts/_school_header.html.haml b/app/views/layouts/_school_header.html.haml index d7307538..9949c9b1 100644 --- a/app/views/layouts/_school_header.html.haml +++ b/app/views/layouts/_school_header.html.haml @@ -8,6 +8,9 @@ Data from = "#{@year - 1}-#{@year}" school year. + Show: + - @years.each do |year| + = link_to(year, school_category_path(@school_category.school, @school_category.category, year: year)) - if @school.district.present? %p %strong District: diff --git a/db/schema.rb b/db/schema.rb index 1d4f1c40..74c627d8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,6 +14,7 @@ ActiveRecord::Schema.define(version: 20180711164051) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + enable_extension "pg_stat_statements" create_table "attempts", force: :cascade do |t| t.integer "recipient_id" diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index 9baa4c65..2d70f0f9 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -7,7 +7,14 @@ # run console: SchoolCategory.update_all(year: '2017') # rake data:load_questions_csv # rake data:load_responses +# sudo heroku run:detached rake data:load_responses -a mciea-beta --size performance-l +Access Key ID: +AKIAIU4VEKWV23W2WKSQ +Secret Access Key: +4BPB9kpNTUCj/pwWXA/u59zO5Jj4/y0gNWm3MjvN + +sudo heroku pg:backups:restore 'https://s3.amazonaws.com/irrationaldesign/latest.dump' DATABASE_URL -a mciea-beta # Add: #