Skip to content

Commit 853bcd9

Browse files
committed
WIP
1 parent d6a8e0f commit 853bcd9

File tree

7 files changed

+434
-0
lines changed

7 files changed

+434
-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: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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 breached_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 breached_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 breached_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 breached_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+
assessment: {
108+
verification_started_at: nil,
109+
prioritised: true,
110+
},
111+
)
112+
.where.not(assessment: { prioritisation_work_history_checks: nil })
113+
.distinct
114+
end
115+
116+
attr_reader :params
117+
end
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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">Breached 10 day SLA</h3>
8+
<%= govuk_inset_text { @view_object.breached_sla_for_starting_prioritisation_checks_count } %>
9+
</div>
10+
<div class="govuk-grid-column-one-half">
11+
<h3 class="govuk-heading-m">Breached 40 day SLA</h3>
12+
<%= govuk_inset_text { @view_object.breached_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</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</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">10 day SLA relates to application forms that are going through prioritisation checks and expect checks to begin within 10 days of being submitted. For these applications, we consider them as nearing SLA once they are within 2 days of breaching the SLA.</p>
29+
<p class="govuk-body">40 day SLA relates to application forms are prioritised and expect initial assessment to be completed and moved to verification within 40 days of being submitted. For these applications, we consider them as nearing SLA once they are within 5 days of breaching the SLA.</p>
30+
<% end %>
31+
32+
<hr class="govuk-section-break govuk-section-break--m govuk-section-break--visible">
33+
34+
<h2 class="govuk-heading-l">Application forms</h2>
35+
36+
<div class="govuk-tabs" data-module="govuk-tabs">
37+
<h2 class="govuk-tabs__title">
38+
Contents
39+
</h2>
40+
<ul class="govuk-tabs__list">
41+
<li class="govuk-tabs__list-item <%= 'govuk-tabs__list-item--selected' if params[:tab] != "completed" %>">
42+
<%= link_to "10 day SLA", assessor_interface_service_level_agreements_path %>
43+
</li>
44+
<li class="govuk-tabs__list-item <%= 'govuk-tabs__list-item--selected' if params[:tab] == "completed" %>">
45+
<%= link_to "40 day SLA", assessor_interface_service_level_agreements_path(tab: "completed") %>
46+
</li>
47+
</ul>
48+
<div class="govuk-tabs__panel">
49+
<% if (records = @view_object.application_forms_records).present? %>
50+
<%=
51+
govuk_table(classes: "application-forms-sla") do |table|
52+
table.with_head do |head|
53+
head.with_row do |row|
54+
row.with_cell(header: true, text: "Reference")
55+
row.with_cell(header: true, text: "Country/Region")
56+
row.with_cell(header: true, text: "Working days since submission")
57+
end
58+
end
59+
60+
table.with_body do |body|
61+
records.each do |application_form|
62+
body.with_row do |row|
63+
row.with_cell { govuk_link_to application_form.reference, [:assessor_interface, application_form] }
64+
row.with_cell { CountryName.from_region(application_form.region) }
65+
row.with_cell do
66+
if params[:tab] == "completed"
67+
govuk_tag(text: application_form.working_days_between_submitted_and_today, colour: @view_object.breached_sla_to_complete_prioritised_application?(application_form) ? "red" : "yellow" )
68+
else
69+
govuk_tag(text: application_form.working_days_between_submitted_and_today, colour: @view_object.breached_sla_to_start_prioritisation_checks?(application_form) ? "red" : "yellow" )
70+
end
71+
end
72+
end
73+
end
74+
end
75+
end
76+
%>
77+
<%= govuk_pagination(pagy: @view_object.application_forms_pagy) %>
78+
<% else %>
79+
<h2 class="govuk-heading-m"><%= t(".results.empty") %></h2>
80+
<% end %>
81+
</div>
82+
</div>
83+

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/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)