Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LnD: investigation into restart submission report generation #7551

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions app/controllers/admin/ccms_queues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions app/models/concerns/base_state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 "Log::Status::Change laa: #{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
Expand Down Expand Up @@ -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
Expand Down
39 changes: 38 additions & 1 deletion app/views/admin/ccms_queues/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
back_link: :none,
) %>

<h2 class="govuk-heading-m"><%= t(".progress_queue.heading") %></h2>
<% if @in_progress.empty? %>
<h2 class="govuk-heading-m">Queue is empty</h2>
<h3 class="govuk-heading-s"><%= t(".progress_queue.empty") %></h3>
<% else %>

<div class="govuk-grid-row">
Expand Down Expand Up @@ -40,3 +41,39 @@
</div>

<% end %>

<h2 class="govuk-heading-m"><%= t(".paused_submission.heading") %></h2>
<% if @paused.empty? %>
<h3 class="govuk-heading-s"><%= t(".paused_submission.empty") %></h3>
<% else %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">

<%= 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 %>

</div>
</div>

<% end %>
1 change: 1 addition & 0 deletions app/workers/reports_creator_worker.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 4 additions & 0 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions config/locales/en/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading