diff --git a/app/controllers/admin/ccms_queues_controller.rb b/app/controllers/admin/ccms_queues_controller.rb index 164ebde9e5..1a4d8674d6 100644 --- a/app/controllers/admin/ccms_queues_controller.rb +++ b/app/controllers/admin/ccms_queues_controller.rb @@ -2,6 +2,7 @@ module Admin class CCMSQueuesController < AdminBaseController def index @in_progress = CCMS::Submission.where.not(aasm_state: %w[completed abandoned]).order(created_at: :desc) + @paused = BaseStateMachine.where(aasm_state: :submission_paused).order(:created_at).map(&:legal_aid_application) end def show diff --git a/app/models/concerns/base_state_machine.rb b/app/models/concerns/base_state_machine.rb index e508eb62e9..5cf76d675e 100644 --- a/app/models/concerns/base_state_machine.rb +++ b/app/models/concerns/base_state_machine.rb @@ -8,6 +8,10 @@ def allow_ccms_submission? EnableCCMSSubmission.call || ENV.fetch("LOCAL_CCMS_OVERRIDE", "false") == "true" end + def log_status_change + Rails.logger.info "BaseStateMachine::StateChange, laa_id: #{legal_aid_application.id}, event: #{aasm.current_event}, from: #{aasm.from_state}, to: #{aasm.to_state}" + end + VALID_CCMS_REASONS = %i[ no_online_banking no_applicant_consent @@ -43,6 +47,8 @@ def allow_ccms_submission? state :use_ccms state :delegated_functions_used + after_all_transitions :log_status_change + event :enter_applicant_details do transitions from: %i[ initiated diff --git a/app/views/admin/ccms_queues/index.html.erb b/app/views/admin/ccms_queues/index.html.erb index 23fa14cfbc..798b25d297 100644 --- a/app/views/admin/ccms_queues/index.html.erb +++ b/app/views/admin/ccms_queues/index.html.erb @@ -3,8 +3,9 @@ back_link: :none, ) %> +

<%= t(".progress_queue.heading") %>

<% if @in_progress.empty? %> -

Queue is empty

+

<%= t(".progress_queue.empty") %>

<% else %>
@@ -40,3 +41,39 @@
<% end %> + +

<%= t(".paused_submission.heading") %>

+<% if @paused.empty? %> +

<%= t(".paused_submission.empty") %>

+<% else %> +
+
+ + <%= govuk_table do |table| + table.with_caption(html_attributes: { class: "govuk-visually-hidden" }, text: t(".page_title")) + + table.with_head do |head| + head.with_row do |row| + row.with_cell(text: t(".case_reference")) + row.with_cell(text: t(".state")) + row.with_cell(text: t(".created_at")) + end + end + + table.with_body do |body| + @paused.each do |application| + body.with_row do |row| + row.with_cell do + govuk_link_to(application.application_ref, admin_legal_aid_applications_submission_path(application)) + end + row.with_cell(text: application.state.humanize) + row.with_cell(text: l(application.created_at, format: :long_date_time)) + end + end + end + end %> + +
+
+ +<% end %> diff --git a/app/workers/reports_creator_worker.rb b/app/workers/reports_creator_worker.rb index 466c485ca1..a1c231c382 100644 --- a/app/workers/reports_creator_worker.rb +++ b/app/workers/reports_creator_worker.rb @@ -1,6 +1,7 @@ class ReportsCreatorWorker include Sidekiq::Worker include Sidekiq::Status::Worker + sidekiq_options queue: :report_creator def perform(legal_aid_application_id) legal_aid_application = LegalAidApplication.find(legal_aid_application_id) diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 6598be50dd..a03ec80d2a 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -15,6 +15,10 @@ Sidekiq.configure_server do |config| config.redis = { url: redis_url } + config.capsule("report_capsule") do |cap| + cap.concurrency = 2 + cap.queues = %w[report_creator] + end # accepts :expiration (optional) Sidekiq::Status.configure_server_middleware config, expiration: 30.minutes.to_i diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 93be70387e..40aa37dc18 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -35,8 +35,15 @@ en: ccms_queues: index: page_title: Incomplete CCMS Submissions + progress_queue: + heading: Processing queue + empty: The sidekiq queue is empty + paused_submission: + heading: Paused submissions + empty: There are no paused submissions applicant_name: Client's name references: CCMS & case reference + case_reference: Case reference created_at: Date started state: State sidekiq: diff --git a/spec/requests/admin/ccms_queues_controller_spec.rb b/spec/requests/admin/ccms_queues_controller_spec.rb index b34c2d936f..27def42e7f 100644 --- a/spec/requests/admin/ccms_queues_controller_spec.rb +++ b/spec/requests/admin/ccms_queues_controller_spec.rb @@ -23,7 +23,7 @@ context "when there are no applications on the queue" do it "displays a warning message" do get_index - expect(response.body).to include("Queue is empty") + expect(response.body).to include("The sidekiq queue is empty") end end @@ -35,6 +35,22 @@ expect(response.body).to include(admin_ccms_queue_path(ccms_submission.id)) end end + + context "when there are no paused applications" do + it "displays a warning message" do + get_index + expect(response.body).to include("There are no paused submissions") + end + end + + context "when there is a paused application" do + let!(:legal_aid_application) { create(:legal_aid_application, :submission_paused) } + + it "has a link to the application" do + get_index + expect(response.body).to include(admin_legal_aid_applications_submission_path(legal_aid_application)) + end + end end describe "GET show" do