mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
Set up bullet gem. Implement bullet gem suggestions.
This commit is contained in:
parent
3408ecd749
commit
5a8d032dd0
10 changed files with 39 additions and 17 deletions
1
Gemfile
1
Gemfile
|
|
@ -70,6 +70,7 @@ group :development do
|
||||||
gem 'seed_dump'
|
gem 'seed_dump'
|
||||||
gem 'spring'
|
gem 'spring'
|
||||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||||
|
gem 'bullet'
|
||||||
end
|
end
|
||||||
|
|
||||||
group 'test' do
|
group 'test' do
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,9 @@ GEM
|
||||||
bootsnap (1.9.1)
|
bootsnap (1.9.1)
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
builder (3.2.4)
|
builder (3.2.4)
|
||||||
|
bullet (7.0.0)
|
||||||
|
activesupport (>= 3.0.0)
|
||||||
|
uniform_notifier (~> 1.11)
|
||||||
byebug (11.1.3)
|
byebug (11.1.3)
|
||||||
capybara (3.35.3)
|
capybara (3.35.3)
|
||||||
addressable
|
addressable
|
||||||
|
|
@ -261,6 +264,7 @@ GEM
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
uglifier (4.2.0)
|
uglifier (4.2.0)
|
||||||
execjs (>= 0.3.0, < 3)
|
execjs (>= 0.3.0, < 3)
|
||||||
|
uniform_notifier (1.14.2)
|
||||||
warden (1.2.9)
|
warden (1.2.9)
|
||||||
rack (>= 2.0.9)
|
rack (>= 2.0.9)
|
||||||
web-console (4.1.0)
|
web-console (4.1.0)
|
||||||
|
|
@ -283,6 +287,7 @@ DEPENDENCIES
|
||||||
activerecord-import
|
activerecord-import
|
||||||
apparition!
|
apparition!
|
||||||
bootsnap
|
bootsnap
|
||||||
|
bullet
|
||||||
byebug
|
byebug
|
||||||
capybara
|
capybara
|
||||||
cssbundling-rails
|
cssbundling-rails
|
||||||
|
|
@ -320,4 +325,4 @@ RUBY VERSION
|
||||||
ruby 3.0.2p107
|
ruby 3.0.2p107
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.2.26
|
2.2.32
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
class HomeController < ApplicationController
|
class HomeController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@districts = District.all.order(:name)
|
@districts = District.all.order(:name)
|
||||||
@schools = School.all.order(:name)
|
@schools = School.all.includes([:district]).order(:name)
|
||||||
|
|
||||||
@categories = Category.sorted.map { |category| CategoryPresenter.new(category: category) }
|
@categories = Category.sorted.map { |category| CategoryPresenter.new(category: category) }
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ class SqmApplicationController < ApplicationController
|
||||||
def set_schools_and_districts
|
def set_schools_and_districts
|
||||||
@district = District.find_by_slug district_slug
|
@district = District.find_by_slug district_slug
|
||||||
@districts = District.all.order(:name)
|
@districts = District.all.order(:name)
|
||||||
@school = School.find_by_slug school_slug
|
@school = School.find_by_slug(school_slug)
|
||||||
@schools = School.where(district: @district).order(:name)
|
@schools = School.includes([:district]).where(district: @district).order(:name)
|
||||||
@academic_year = AcademicYear.find_by_range params[:year]
|
@academic_year = AcademicYear.find_by_range params[:year]
|
||||||
@has_empty_dataset = Measure.none_meet_threshold? school: @school, academic_year: @academic_year
|
@has_empty_dataset = Measure.none_meet_threshold? school: @school, academic_year: @academic_year
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ class Category < ActiveRecord::Base
|
||||||
include FriendlyId
|
include FriendlyId
|
||||||
friendly_id :name, use: [:slugged]
|
friendly_id :name, use: [:slugged]
|
||||||
|
|
||||||
scope :sorted, -> { order(:sort_index) }
|
scope :sorted, -> { order(:sort_index)}
|
||||||
|
|
||||||
has_many :subcategories
|
has_many :subcategories
|
||||||
has_many :measures, through: :subcategories
|
has_many :measures, through: :subcategories
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class CategoryPresenter
|
||||||
end
|
end
|
||||||
|
|
||||||
def subcategories(academic_year:, school:)
|
def subcategories(academic_year:, school:)
|
||||||
@category.subcategories.sort_by(&:subcategory_id).map do |subcategory|
|
@category.subcategories.includes([:measures]).sort_by(&:subcategory_id).map do |subcategory|
|
||||||
SubcategoryPresenter.new(
|
SubcategoryPresenter.new(
|
||||||
subcategory: subcategory,
|
subcategory: subcategory,
|
||||||
academic_year: academic_year,
|
academic_year: academic_year,
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class SubcategoryPresenter
|
||||||
end
|
end
|
||||||
|
|
||||||
def measure_presenters
|
def measure_presenters
|
||||||
@subcategory.measures.sort_by(&:measure_id).map do |measure|
|
@subcategory.measures.includes([:admin_data_items]).sort_by(&:measure_id).map do |measure|
|
||||||
MeasurePresenter.new(measure: measure, academic_year: @academic_year, school: @school)
|
MeasurePresenter.new(measure: measure, academic_year: @academic_year, school: @school)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -39,15 +39,15 @@ class SubcategoryPresenter
|
||||||
private
|
private
|
||||||
|
|
||||||
def scale
|
def scale
|
||||||
Scale.new(
|
Scale.new(
|
||||||
watch_low_benchmark: measures.map(&:watch_low_benchmark).average,
|
watch_low_benchmark: measures.map(&:watch_low_benchmark).average,
|
||||||
growth_low_benchmark: measures.map(&:growth_low_benchmark).average,
|
growth_low_benchmark: measures.map(&:growth_low_benchmark).average,
|
||||||
approval_low_benchmark: measures.map(&:approval_low_benchmark).average,
|
approval_low_benchmark: measures.map(&:approval_low_benchmark).average,
|
||||||
ideal_low_benchmark: measures.map(&:ideal_low_benchmark).average
|
ideal_low_benchmark: measures.map(&:ideal_low_benchmark).average
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def measures
|
def measures
|
||||||
@measures ||= @subcategory.measures.order(:measure_id)
|
@measures ||= @subcategory.measures.includes([:admin_data_items]).order(:measure_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,14 @@
|
||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
|
config.after_initialize do
|
||||||
|
Bullet.enable = true
|
||||||
|
Bullet.alert = true
|
||||||
|
Bullet.bullet_logger = true
|
||||||
|
Bullet.console = true
|
||||||
|
# Bullet.growl = true
|
||||||
|
Bullet.rails_logger = true
|
||||||
|
Bullet.add_footer = true
|
||||||
|
end
|
||||||
|
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
||||||
# In the development environment your application's code is reloaded on
|
# In the development environment your application's code is reloaded on
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,12 @@
|
||||||
# and recreated between test runs. Don't rely on the data there!
|
# and recreated between test runs. Don't rely on the data there!
|
||||||
|
|
||||||
Rails.application.configure do
|
Rails.application.configure do
|
||||||
|
# config.after_initialize do
|
||||||
|
# Bullet.enable = true
|
||||||
|
# Bullet.bullet_logger = true
|
||||||
|
# Bullet.raise = true # raise an error if n+1 query occurs
|
||||||
|
# end
|
||||||
|
|
||||||
# Settings specified here will take precedence over those in config/application.rb.
|
# Settings specified here will take precedence over those in config/application.rb.
|
||||||
|
|
||||||
config.cache_classes = false
|
config.cache_classes = false
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe CategoryPresenter do
|
describe CategoryPresenter do
|
||||||
let(:category_presenter) do
|
let(:category_presenter) do
|
||||||
subcategory1 = Subcategory.new(name: 'A subcategory', subcategory_id: '1')
|
subcategory1 = Subcategory.create(name: 'A subcategory', subcategory_id: '1')
|
||||||
subcategory2 = Subcategory.new(name: 'Another subcategory', subcategory_id: '2')
|
subcategory2 = Subcategory.create(name: 'Another subcategory', subcategory_id: '2')
|
||||||
|
|
||||||
category = Category.new(name: 'Some Category', subcategories: [subcategory1, subcategory2],
|
category = Category.create(name: 'Some Category', subcategories: [subcategory1, subcategory2],
|
||||||
description: 'A description for some Category', short_description: 'A short description for some Category', category_id: '1')
|
description: 'A description for some Category', short_description: 'A short description for some Category', category_id: '1')
|
||||||
return CategoryPresenter.new(category: category)
|
return CategoryPresenter.new(category: category)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue