-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: cdpt-1850-commissioning-and-chase-redesign
Are you sure you want to change the base?
Update existing data requests #2503
Conversation
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 |
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}" |
There was a problem hiding this comment.
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
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
|
…858-update-existing-data-requests
…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}" |
There was a problem hiding this comment.
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
db/data_migrations/20241024131255_migrate_data_request_areas.rb
Outdated
Show resolved
Hide resolved
data_request_area.commissioning_document = request.commissioning_document | ||
else | ||
template_name = data_request_area_type == "mappa" ? "mappa" : "standard" | ||
data_request_area.build_commissioning_document(template_name: template_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this happen automatically with the after_create block on data_request_area?
You will need to adjust that to allow for an existing commissioning_document to be linked without a new one being created.
end | ||
|
||
# Ensure that any uploaded attachments are kept | ||
if request.commissioning_document&.attachment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem necessary. Aren't request.commissioning_document
and data_request_area.commissioning_document
the same object?
After the migration, should we delete all of the commissioning documents from the DataRequests? |
Test script to confirm that the commissioning_documents have been successfully transferred from data_request to data_request_area
|
Another test script to ensure the 1 to 1 transfer is done. After the migration the count should be the same.
|
…858-update-existing-data-requests
…858-update-existing-data-requests
db/data_migrations/20241024131255_migrate_data_request_areas.rb
Outdated
Show resolved
Hide resolved
end | ||
|
||
# Update DataRequest with the correct data_request_area_id | ||
request.update(data_request_area_id: data_request_area.id) # rubocop:disable Rails/SaveBang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update
will save the record, so this line is the issue. You can replace with update_attribute
which won't run validation but will still run callbacks.
The additional save is not required.
Description
All existing data requests need to be associated to their relevant data request area
Self-review checklist
CT-7654 ...
Screenshots
Related JIRA tickets
https://dsdmoj.atlassian.net/jira/software/c/projects/CDPT/boards/1152?selectedIssue=CDPT-1858
Deployment
Manual testing instructions