Skip to content
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
14 changes: 14 additions & 0 deletions app/queries/rollover_progress_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def remaining_to_rollover_count

delegate :count, to: :rolled_over_study_sites, prefix: true

delegate :count, to: :eligible_schools, prefix: true

delegate :count, to: :rolled_over_schools, prefix: true

delegate :count, to: :rolled_over_courses, prefix: true

delegate :count, to: :eligible_partnerships, prefix: true
Expand Down Expand Up @@ -89,6 +93,16 @@ def rolled_over_study_sites
@rolled_over_study_sites ||= @target_cycle.study_sites
end

def eligible_schools
@eligible_schools ||= @previous_target_cycle.provider_schools
.with_available_gias_school
.where(provider_id: eligible_providers.select(:id))
end

def rolled_over_schools
@rolled_over_schools ||= @target_cycle.provider_schools.with_available_gias_school
end

def rolled_over_partnerships
ProviderPartnership.includes(:training_provider, :accredited_provider).where(
"accredited_provider_id IN (:id) OR training_provider_id IN (:id)",
Expand Down
5 changes: 5 additions & 0 deletions app/views/support/recruitment_cycles/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
<% row.with_value(text: t(".rollover_status.summary", total_eligible_count: @rollover_progress_query.eligible_study_sites_count, rolled_over_count: @rollover_progress_query.rolled_over_study_sites_count)) %>
<% end %>

<% summary_list.with_row do |row| %>
<% row.with_key(text: RolloverProgressQuery.human_attribute_name(:schools_summary)) %>
<% row.with_value(text: t(".rollover_status.summary", total_eligible_count: @rollover_progress_query.eligible_schools_count, rolled_over_count: @rollover_progress_query.rolled_over_schools_count)) %>
<% end %>

<% summary_list.with_row do |row| %>
<% row.with_key(text: RolloverProgressQuery.human_attribute_name(:partnerships_summary)) %>
<% row.with_value(text: t(".rollover_status.summary", total_eligible_count: @rollover_progress_query.eligible_partnerships_count, rolled_over_count: @rollover_progress_query.rolled_over_partnerships_count)) %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/en/activemodel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ en:
providers_summary: Rolled over providers
courses_summary: Rolled over courses
study_sites_summary: Rolled over study sites
schools_summary: Rolled over schools
remaining_to_rollover: Remaining to rollover
providers_without_published_courses: Providers without published courses (not rolled over)
errors:
Expand Down
36 changes: 36 additions & 0 deletions spec/queries/rollover_progress_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,42 @@
end
end

describe "#eligible_schools" do
let!(:eligible_school) { create(:provider_school, provider: provider_with_own_course) }
let!(:ineligible_school) { create(:provider_school, provider: provider_without_courses) }
let!(:closed_school) do
create(
:provider_school,
provider: provider_with_own_course,
gias_school: create(:gias_school, :closed),
)
end

before do
given_we_have_providers_and_courses_on_previous_target_cycle
end

it "includes available schools belonging to eligible providers" do
expect(rollover_progress.eligible_schools).to contain_exactly(eligible_school)
end

it "returns the correct count through delegation" do
expect(rollover_progress.eligible_schools_count).to eq(1)
end
end

describe "#rolled_over_schools" do
let!(:rolled_over_school) { create(:provider_school, provider: rolled_over_provider) }

it "includes available schools in the target cycle" do
expect(rollover_progress.rolled_over_schools).to contain_exactly(rolled_over_school)
end

it "returns the correct count through delegation" do
expect(rollover_progress.rolled_over_schools_count).to eq(1)
end
end

describe "#eligible_partnerships" do
let(:accredited_provider) { create(:provider, :accredited_provider) }
let(:rollable_partnership_one) do
Expand Down
Loading