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

Update existing data requests #2503

Conversation

lucas-shaw
Copy link
Contributor

Description

All existing data requests need to be associated to their relevant data request area

Self-review checklist

  • (1) Quick stakeholder demo done OR
  • (2) ...bug with before and after screenshots
  • (3) Tests passing
  • (4) Branch ready to be merged (not work in progress)
  • (5) No superfluous changes in diff
  • (6) No TODO's without new ticket numbers
  • (7) PR Prefixed with ticket number e.g. CT-7654 ...
  • (8) Data migration script is created if any of letter templates is changed

Screenshots

Related JIRA tickets

https://dsdmoj.atlassian.net/jira/software/c/projects/CDPT/boards/1152?selectedIssue=CDPT-1858

Deployment

Manual testing instructions

@lucas-shaw lucas-shaw changed the base branch from main to cdpt-1850-commissioning-and-chase-redesign October 23, 2024 09:08
@lucas-shaw
Copy link
Contributor Author

lucas-shaw commented Oct 23, 2024

I havent added in the below areas as they dont exist in the live data

SECURITY_DATA_REQUEST_TYPES = %w[g2_security g3_security].freeze
OTHER_DEPARTMENT_DATA_REQUEST_TYPES = %w[other_department].freeze

request.update!(data_request_area_id: data_request_area.id)

# TEMP LOGGING INFO
Rails.logger.debug "Updated DataRequest ##{request.id} - #{request.request_type}, with data_request_area_id: #{data_request_area.id} (area_type: #{data_request_area_type}, contact_id: #{data_request_area.contact_id}, data_request_area.user_id: #{data_request_area.user_id}, data_request_area.case_id: #{data_request_area.case_id}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left in for local testing purposes, will remove when ready

@lucas-shaw
Copy link
Contributor Author

lucas-shaw commented Oct 24, 2024

The script used to generate data requests for local testing purposes.

This has to be used as creating a DataRequest normally through the service, no longer gives a value to location or contact_id, as this is now done when creating a DataRequestArea

# SEED FOR LOCAL TESTING
request_types = %w[all_prison_records cctv bwcf probation_records security_records mappa telephone_recordings probation_archive dps cross_borders cctv_and_bwcf court other]

# Create multiple DataRequest records
request_types.cycle(10) do |request_type|

  # Create DataRequest
  data_request = DataRequest.create!(
    user_id: 19, # RELEVANT USER ID NEEDED
    case_id: [1, 2, 3, 4, 5, 6, 7].sample, # Covers the different case states - ready_to_dispatch, ready_to_copy, waiting_for_data, data_to_be_requested, ready_for_vetting, vetting_in_progress, closed
    request_type:,
    date_requested: Time.zone.today - rand(50..100),
    cached_num_pages: rand(1..10),
    completed: false,
    contact_id: [1, 2, 3].sample,
    request_type_note: "other information",
    location: ["location_one", "location_two", nil].sample,
  )

  # Create a commissioning document for a data request rather than an area to imitate existing process
  # purposefully dont always create a commissioning document
  if [true, false].sample
    # Create a commissioning document only for specific types if needed
    doc = CommissioningDocument.new(
      data_request:,
      template_name: %w[cctv cat_a cross_border mappa pdp prison probation security telephone].sample,
      attachment_id: [1, 2, 3].sample,
    )
    doc.save!(validate: false) # skip validation to allow saving without a data_request_area
  end

  # Log creation for verification
  Rails.logger.debug "Created DataRequest ##{data_request.id} (#{request_type}, case_id: #{case_id}, completed: #{data_request.completed})"
end


lucas-shaw and others added 4 commits October 24, 2024 14:37
…ministryofjustice/correspondence_tool_staff into cdpt-1858-update-existing-data-requests
# Get the data_request_area_type for this request
data_request_area_type = data_request_area_type_for(request.request_type)

Rails.logger.debug "Finding DataRequestArea with user_id: #{request.user_id}, case_id: #{request.case_id}, contact_id: #{request.contact_id.presence}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left in for local testing purposes, will remove when ready

Copy link
Contributor

@vertism vertism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you remove the debug logging then this should be ready to merge.

@lucas-shaw lucas-shaw marked this pull request as ready for review December 17, 2024 13:44
@lucas-shaw lucas-shaw requested review from a team as code owners December 17, 2024 13:44
Copy link
Contributor

@vertism vertism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lucas-shaw lucas-shaw merged commit 1d04c1e into cdpt-1850-commissioning-and-chase-redesign Dec 17, 2024
14 checks passed
@lucas-shaw lucas-shaw deleted the cdpt-1858-update-existing-data-requests branch December 17, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants