Skip to content

Commit bd3a66d

Browse files
committed
WIP
1 parent d6a8e0f commit bd3a66d

File tree

7 files changed

+230
-0
lines changed

7 files changed

+230
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
class AssessorInterface::ServiceLevelAgreementsController < AssessorInterface::BaseController
4+
def index
5+
authorize %i[assessor_interface service_level_agreement]
6+
7+
@view_object =
8+
AssessorInterface::ServiceLevelAgreementIndexViewObject.new(params:)
9+
10+
render layout: "full_from_desktop"
11+
end
12+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
class AssessorInterface::ServiceLevelAgreementPolicy < ApplicationPolicy
4+
def index?
5+
user.manage_staff_permission? && !user.archived?
6+
end
7+
end
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# frozen_string_literal: true
2+
3+
class AssessorInterface::ServiceLevelAgreementIndexViewObject
4+
include ActionView::Helpers::FormOptionsHelper
5+
include Pagy::Backend
6+
7+
def initialize(params:)
8+
@params = params
9+
end
10+
11+
def application_forms_pagy
12+
application_forms_with_pagy.first
13+
end
14+
15+
def application_forms_records
16+
application_forms_with_pagy.last
17+
end
18+
19+
def failed_sla_for_starting_prioritisation_checks_count
20+
application_forms_with_prioritisation_checks_not_started
21+
.where(
22+
"working_days_between_submitted_and_today > ?",
23+
WORKING_DAYS_TO_START_PRIORITISATION_CHECKS,
24+
)
25+
.count
26+
.to_s
27+
end
28+
29+
def nearing_sla_for_starting_prioritisation_checks_count
30+
application_forms_with_prioritisation_checks_not_started
31+
.where(
32+
working_days_between_submitted_and_today:
33+
DAYS_CONSIDERED_CLOSE_TO_START_PRIORITISATION_CHECKS_DEADLINE..WORKING_DAYS_TO_START_PRIORITISATION_CHECKS,
34+
)
35+
.count
36+
.to_s
37+
end
38+
39+
def failed_sla_for_completing_prioritised_applications_count
40+
application_forms_with_prioritisation_checks_not_completed
41+
.where(
42+
"working_days_between_submitted_and_today > ?",
43+
WORKING_TO_FINISH_ASSESSMENT_FOR_PRIORITISED,
44+
)
45+
.count
46+
.to_s
47+
end
48+
49+
def nearing_sla_for_completing_prioritised_applications_failed
50+
application_forms_with_prioritisation_checks_not_completed
51+
.where(
52+
working_days_between_submitted_and_today:
53+
DAYS_CONSIDERED_CLOSE_TO_FINISH_ASSESSMENT_FOR_PRIORITISED_DEADLINE..WORKING_TO_FINISH_ASSESSMENT_FOR_PRIORITISED,
54+
)
55+
.count
56+
.to_s
57+
end
58+
59+
def failing_sla_to_start_prioritisation_checks?(application_form)
60+
application_form.working_days_between_submitted_and_today.to_i >
61+
WORKING_DAYS_TO_START_PRIORITISATION_CHECKS
62+
end
63+
64+
def failing_sla_to_complete_prioritised_application?(application_form)
65+
application_form.working_days_between_submitted_and_today.to_i >
66+
WORKING_TO_FINISH_ASSESSMENT_FOR_PRIORITISED
67+
end
68+
69+
private
70+
71+
WORKING_DAYS_TO_START_PRIORITISATION_CHECKS = 10
72+
DAYS_CONSIDERED_CLOSE_TO_START_PRIORITISATION_CHECKS_DEADLINE = 8
73+
74+
WORKING_TO_FINISH_ASSESSMENT_FOR_PRIORITISED = 40
75+
DAYS_CONSIDERED_CLOSE_TO_FINISH_ASSESSMENT_FOR_PRIORITISED_DEADLINE = 35
76+
77+
def application_forms_with_pagy
78+
@application_forms_with_pagy ||=
79+
pagy(
80+
application_forms_with_filter.order(
81+
working_days_between_submitted_and_today: :desc,
82+
),
83+
)
84+
end
85+
86+
def application_forms_with_filter
87+
@application_forms_with_filter ||=
88+
if params[:tab] == "completed"
89+
application_forms_with_prioritisation_checks_not_completed
90+
else
91+
application_forms_with_prioritisation_checks_not_started
92+
end
93+
end
94+
95+
def application_forms_with_prioritisation_checks_not_started
96+
ApplicationForm
97+
.joins(assessment: :prioritisation_work_history_checks)
98+
.where(assessment: { started_at: nil })
99+
.where.not(assessment: { prioritisation_work_history_checks: nil })
100+
.distinct
101+
end
102+
103+
def application_forms_with_prioritisation_checks_not_completed
104+
ApplicationForm
105+
.joins(assessment: :prioritisation_work_history_checks)
106+
.where(
107+
awarded_at: nil,
108+
declined_at: nil,
109+
withdrawn_at: nil,
110+
assessment: {
111+
prioritised: true,
112+
},
113+
)
114+
.where.not(assessment: { prioritisation_work_history_checks: nil })
115+
.distinct
116+
end
117+
118+
attr_reader :params
119+
end
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<% content_for :page_title, "SLA Status" %>
2+
3+
<h1 class="govuk-heading-xl">SLA Status (Prioritisation)</h1>
4+
5+
<div class="govuk-grid-row">
6+
<div class="govuk-grid-column-one-half">
7+
<h3 class="govuk-heading-m">Failed SLA for 10 day to start</h3>
8+
<%= govuk_inset_text { @view_object.failed_sla_for_starting_prioritisation_checks_count } %>
9+
</div>
10+
<div class="govuk-grid-column-one-half">
11+
<h3 class="govuk-heading-m">Failed SLA for 40 day to complete</h3>
12+
<%= govuk_inset_text { @view_object.failed_sla_for_completing_prioritised_applications_count } %>
13+
</div>
14+
</div>
15+
16+
<div class="govuk-grid-row">
17+
<div class="govuk-grid-column-one-half">
18+
<h3 class="govuk-heading-m">Nearing 10 day SLA to start</h3>
19+
<%= govuk_inset_text { @view_object.nearing_sla_for_starting_prioritisation_checks_count } %>
20+
</div>
21+
<div class="govuk-grid-column-one-half">
22+
<h3 class="govuk-heading-m">Nearing 40 day SLA to complete</h3>
23+
<%= govuk_inset_text { @view_object.nearing_sla_for_completing_prioritised_applications_failed } %>
24+
</div>
25+
</div>
26+
27+
<%= govuk_details(summary_text: "What is considered as nearing?") do %>
28+
<p class="govuk-body">Any application form within 2 working days of hitting the SLA will be considered as nearing SLA.</p>
29+
<% end %>
30+
31+
<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible">
32+
33+
<h2 class="govuk-heading-l">Application forms</h2>
34+
35+
<div class="govuk-tabs" data-module="govuk-tabs">
36+
<h2 class="govuk-tabs__title">
37+
Contents
38+
</h2>
39+
<ul class="govuk-tabs__list">
40+
<li class="govuk-tabs__list-item <%= 'govuk-tabs__list-item--selected' if params[:tab] != "completed" %>">
41+
<%= link_to "10 day SLA", assessor_interface_service_level_agreements_path %>
42+
</li>
43+
<li class="govuk-tabs__list-item <%= 'govuk-tabs__list-item--selected' if params[:tab] == "completed" %>">
44+
<%= link_to "40 day SLA", assessor_interface_service_level_agreements_path(tab: "completed") %>
45+
</li>
46+
</ul>
47+
<div class="govuk-tabs__panel">
48+
<% if (records = @view_object.application_forms_records).present? %>
49+
<%=
50+
govuk_table(classes: "application-forms-sla") do |table|
51+
table.with_head do |head|
52+
head.with_row do |row|
53+
row.with_cell(header: true, text: "Reference")
54+
row.with_cell(header: true, text: "Country/Region")
55+
row.with_cell(header: true, text: "Working days since submission")
56+
end
57+
end
58+
59+
table.with_body do |body|
60+
records.each do |application_form|
61+
body.with_row do |row|
62+
row.with_cell { govuk_link_to application_form.reference, [:assessor_interface, application_form] }
63+
row.with_cell { CountryName.from_region(application_form.region) }
64+
row.with_cell do
65+
if params[:tab] == "completed"
66+
govuk_tag(text: application_form.working_days_between_submitted_and_today, colour: @view_object.failing_sla_to_complete_prioritised_application?(application_form) ? "red" : "yellow" )
67+
else
68+
govuk_tag(text: application_form.working_days_between_submitted_and_today, colour: @view_object.failing_sla_to_start_prioritisation_checks?(application_form) ? "red" : "yellow" )
69+
end
70+
end
71+
end
72+
end
73+
end
74+
end
75+
%>
76+
<%= govuk_pagination(pagy: @view_object.application_forms_pagy) %>
77+
<% else %>
78+
<h2 class="govuk-heading-m"><%= t(".results.empty") %></h2>
79+
<% end %>
80+
</div>
81+
</div>
82+

app/views/shared/_header.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
href: main_app.assessor_interface_staff_index_path,
3232
active: current_page?(main_app.assessor_interface_staff_index_path)
3333
) %>
34+
<% service_navigation.with_navigation_item(
35+
text: "SLA Status",
36+
href: main_app.assessor_interface_service_level_agreements_path,
37+
active: current_page?(main_app.assessor_interface_service_level_agreements_path)
38+
) %>
3439
<% end %>
3540
<% service_navigation.with_navigation_item(text: "Sign out", href: main_app.destroy_staff_session_path) %>
3641
<% end %>

config/analytics.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
:shared:
22
:application_forms:
3+
- requires_private_email_for_referee
4+
- started_with_private_email_for_referee
35
- action_required_by
46
- age_range_max
57
- age_range_min
@@ -131,6 +133,7 @@
131133
- id
132134
- updated_at
133135
:eligibility_checks:
136+
- work_experience_referee
134137
- completed_at
135138
- country_code
136139
- created_at

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
namespace :assessor_interface, path: "/assessor" do
1515
root to: redirect("/assessor/applications")
1616

17+
resources :service_level_agreements, only: %i[index]
18+
1719
resources :staff, only: %i[index edit update] do
1820
member do
1921
get "archive", to: "staff#edit_archive"

0 commit comments

Comments
 (0)