Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only show scoreboard activity that has points #4282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/scoreboard_summary_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def limit

def observations
scope = other_schools? ? scoreboard.observations : Observation
scope.for_visible_schools.not_including(school).recorded_since(school.current_academic_year.start_date..).by_date.limit(limit)
scope.for_visible_schools.not_including(school).recorded_since(school.current_academic_year.start_date..).by_date.with_points.sample(limit)
end

def timeline_title
Expand Down
1 change: 1 addition & 0 deletions app/models/observation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class Observation < ApplicationRecord

accepts_nested_attributes_for :temperature_recordings, reject_if: :reject_temperature_recordings

scope :with_points, -> { where('points IS NOT NULL AND points > 0') }
scope :visible, -> { where(visible: true) }
scope :by_date, ->(order = :desc) { order(at: order) }
scope :for_school, ->(school) { where(school: school) }
Expand Down
14 changes: 14 additions & 0 deletions spec/components/scoreboard_summary_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,18 @@
it { expect(component.other_schools?).to be(true) }
end
end

describe '#observations' do
context 'with points' do
let!(:other_school) { create :school, :with_points, score_points: 50, scoreboard: scoreboard }

it { expect(component.observations).not_to be_empty }
end

context 'with no points' do
let!(:other_school) { create :school, :with_points, score_points: 0, scoreboard: scoreboard }

it { expect(component.observations).to be_empty }
end
end
end