Skip to content

Commit

Permalink
Update Providers Reports index
Browse files Browse the repository at this point in the history
  Add Recruitment Performance report
  • Loading branch information
inulty-dfe committed May 13, 2024
1 parent 557c969 commit 0d6795b
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 34 deletions.
3 changes: 2 additions & 1 deletion app/controllers/provider_interface/reports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module ProviderInterface
class ReportsController < ProviderInterfaceController
def index
@providers = current_user.providers
@providers = current_user.providers.preload(:performance_reports)
@performance_reports = current_user.providers.any? { _1.performance_reports.present? }
end
end
end
2 changes: 2 additions & 0 deletions app/models/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Provider < ApplicationRecord
has_many :vendor_api_requests
has_many :vendor_api_tokens

has_many :performance_reports, class_name: 'Publications::ProviderRecruitmentPerformanceReport'

enum region_code: {
east_midlands: 'east_midlands',
eastern: 'eastern',
Expand Down
67 changes: 34 additions & 33 deletions app/views/provider_interface/reports/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,47 @@
<h1 class="govuk-heading-l">
<%= t('page_titles.provider.reports') %>
</h1>

<% if @performance_reports %>
<h2 class="govuk-heading-m">
Weekly recruitment performance report
</h2>
<% end %>
<% @providers.select { _1.performance_reports.any? }.each do |provider| %>
<h3 class="govuk-heading-s"><%= provider.name %></h3>
<% report = provider.performance_reports.last %>
<ul class="govuk-list govuk-list--spaced">
<li><%= govuk_link_to("Weekly report for week ending #{report.publication_date.to_fs(:date_and_time)}", provider_interface_reports_provider_recruitment_performance_report_path(provider.id)) %></li>
</ul>
<% end %>

<h2 class="govuk-heading-m">Application data for this recruitment cycle</h2>
<% @providers.each do |provider| %>
<% if @providers.many? %>
<h3 class="govuk-heading-s"><%= provider.name %></h3>
<% end %>
<ul class="govuk-list govuk-list--spaced">
<li>
<%= govuk_link_to t('page_titles.provider.status_of_active_applications'), provider_interface_reports_provider_status_of_active_applications_path(provider_id: provider) %>
</li>
<li>
<%= govuk_link_to t('page_titles.provider.diversity_report'), provider_interface_reports_provider_diversity_report_path(provider_id: provider) %>
</li>
<li>
<%= govuk_link_to t('page_titles.provider.withdrawal_report'), provider_interface_reports_provider_withdrawal_report_path(provider_id: provider) %>
</li>
</ul>
<% end %>

<h2 class="govuk-heading-m">Download and export</h2>
<ul class="govuk-list govuk-list--spaced">
<li>
<%= govuk_link_to t('page_titles.provider.export_application_data'), provider_interface_new_application_data_export_path %>
</li>
<li>
<%= govuk_link_to t('page_titles.provider.export_hesa_data'), provider_interface_reports_hesa_exports_path %>
</li>
<% if @providers.one? %>
<li>
<%= govuk_link_to t('page_titles.provider.status_of_active_applications'), provider_interface_reports_provider_status_of_active_applications_path(provider_id: @providers.first) %>
</li>
<li>
<%= govuk_link_to t('page_titles.provider.diversity_report'), provider_interface_reports_provider_diversity_report_path(provider_id: @providers.first) %>
</li>
<li>
<%= govuk_link_to t('page_titles.provider.withdrawal_report'), provider_interface_reports_provider_withdrawal_report_path(provider_id: @providers.first) %>
</li>
<% if mid_cycle_report_present_for?(@providers.first) %>
<%= govuk_link_to mid_cycle_report_label_for(@providers.first), provider_interface_reports_provider_mid_cycle_report_path(provider_id: @providers.first) %>
<% end %>
<% end %>
</ul>
<% if @providers.many? %>
<% @providers.each do |provider| %>
<h2 class="govuk-heading-m"><%= provider.name %></h2>
<ul class="govuk-list govuk-list--spaced">
<li>
<%= govuk_link_to t('page_titles.provider.status_of_active_applications'), provider_interface_reports_provider_status_of_active_applications_path(provider_id: provider) %>
</li>
<li>
<%= govuk_link_to t('page_titles.provider.diversity_report'), provider_interface_reports_provider_diversity_report_path(provider_id: provider) %>
</li>
<li>
<%= govuk_link_to t('page_titles.provider.withdrawal_report'), provider_interface_reports_provider_withdrawal_report_path(provider_id: provider) %>
</li>
<% if mid_cycle_report_present_for?(provider) %>
<%= govuk_link_to mid_cycle_report_label_for(provider), provider_interface_reports_provider_mid_cycle_report_path(provider_id: provider) %>
<% end %>
</ul>
<% end %>
<% end %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'rails_helper'

RSpec.feature 'Provider reports index' do
include DfESignInHelpers
scenario 'when' do
given_a_provider_and_provider_user_exists
and_i_am_signed_in_as_provider_user
expect(page).to have_current_path('/provider/applications', ignore_query: true)
when_i_visit_the_reports_index
expect(page).to have_current_path('/provider/reports', ignore_query: true)
then_the_page_has_the_right_content
end

def when_i_visit_the_reports_index
visit provider_interface_reports_path
end

def given_a_provider_and_provider_user_exists
@provider_user = create(:provider_user, :with_dfe_sign_in, email_address: '[email protected]')
@provider = @provider_user.providers.first
end

def then_the_page_has_the_right_content
expect(page).to have_css('h1', text: 'Reports')
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)')
expect(page).to have_css('h2', text: 'Application data for this recruitment cycle')
expect(page).to have_css('a', text: 'Status of active applications').once
expect(page).to have_css('a', text: 'Sex, disability, ethnicity and age of candidates').once
expect(page).to have_css('h2', text: 'Download and export')
expect(page).to have_css('a', text: 'Export application data')
expect(page).to have_css('a', text: 'Withdrawals').once
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)').once
end

def and_i_am_signed_in_as_provider_user
provider_exists_in_dfe_sign_in
provider_signs_in_using_dfe_sign_in
end
alias_method :given_i_am_signed_in_as_provider_user, :and_i_am_signed_in_as_provider_user
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'rails_helper'

RSpec.feature 'Provider with two providers reports index' do
include DfESignInHelpers
scenario 'when a provider user has more than one provider' do
given_a_provider_user_with_two_providers_exists
and_i_am_signed_in_as_provider_user
when_i_visit_the_reports_index
and_the_page_has_all_the_right_elements
end

def when_i_visit_the_reports_index
visit provider_interface_reports_path
expect(page).to have_current_path('/provider/reports')
end

def given_a_provider_user_with_two_providers_exists
@provider_user = create(:provider_user, :with_dfe_sign_in, email_address: '[email protected]')
@provider = @provider_user.providers.first
@second_provider = create(:provider)
# add a second provider to the users account
@provider_user.providers << @second_provider
end

def and_the_page_has_all_the_right_elements
expect(page).to have_css('h1', text: 'Reports')
expect(page).to have_css('h2', text: 'Application data for this recruitment cycle')
expect(page).to have_css('a', text: 'Export application data')
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)')
expect(page).to have_css('h3', text: @provider.name)
expect(page).to have_css('a', text: 'Status of active applications')
expect(page).to have_css('a', text: 'Sex, disability, ethnicity and age of candidates')
expect(page).to have_css('a', text: 'Withdrawals')
expect(page).to have_css('h3', text: @second_provider.name)
expect(page).to have_css('a', text: 'Status of active applications')
expect(page).to have_css('a', text: 'Sex, disability, ethnicity and age of candidates')
expect(page).to have_css('a', text: 'Withdrawals')
expect(page).to have_css('h2', text: 'Download and export')
expect(page).to have_css('a', text: 'Export application data')
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)')
end

def and_i_am_signed_in_as_provider_user
provider_exists_in_dfe_sign_in
provider_signs_in_using_dfe_sign_in
expect(page).to have_current_path('/provider/applications')
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
require 'rails_helper'

RSpec.feature 'Provider with two providers reports index' do
include DfESignInHelpers
before { FeatureFlag.activate(:recruitment_performance_report) }

scenario 'when' do
given_a_provider_user_with_two_providers_exists
and_a_provider_has_a_recruitment_peroformance_report
and_i_am_signed_in_as_provider_user
when_i_visit_the_reports_index
then_the_page_has_the_right_content
end

def when_i_visit_the_reports_index
visit provider_interface_reports_path
expect(page).to have_current_path('/provider/reports', ignore_query: true)
end

def and_a_provider_has_a_recruitment_peroformance_report
create(:provider_recruitment_performance_report, provider: @provider)
end

def given_a_provider_user_with_two_providers_exists
@provider_user = create(:provider_user, :with_dfe_sign_in, email_address: '[email protected]')
@provider = @provider_user.providers.first
@second_provider = create(:provider)
@provider_user.providers << @second_provider
end

def then_the_page_has_the_right_content
expect(page).to have_css('h1', text: 'Reports')
expect(page).to have_css('h2', text: 'Weekly recruitment performance report')
expect(page).to have_css('a', text: 'Weekly report for week ending 2024-06-25')
expect(page).to have_css('h2', text: 'Application data for this recruitment cycle')
expect(page).to have_css('a', text: 'Export application data')
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)')
expect(page).to have_css('h3', text: @provider.name)
expect(page).to have_css('a', text: 'Status of active applications')
expect(page).to have_css('a', text: 'Sex, disability, ethnicity and age of candidates')
expect(page).to have_css('a', text: 'Withdrawals')
expect(page).to have_css('h3', text: @second_provider.name)
expect(page).to have_css('a', text: 'Status of active applications')
expect(page).to have_css('a', text: 'Sex, disability, ethnicity and age of candidates')
expect(page).to have_css('a', text: 'Withdrawals')
expect(page).to have_css('h2', text: 'Download and export')
expect(page).to have_css('a', text: 'Export application data')
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)')
end

def and_i_am_signed_in_as_provider_user
provider_exists_in_dfe_sign_in
provider_signs_in_using_dfe_sign_in
expect(page).to have_current_path('/provider/applications', ignore_query: true)
end
end

0 comments on commit 0d6795b

Please sign in to comment.