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

Merged
Changes from 12 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
da6e7ae
data migration script
lucas-shaw Oct 23, 2024
e65143e
Trigger Build
lucas-shaw Oct 23, 2024
62515de
rubobop
lucas-shaw Oct 23, 2024
e8d757f
update migration
lucas-shaw Oct 24, 2024
39e3728
rubocop
lucas-shaw Oct 24, 2024
6ff841e
rubocop
lucas-shaw Oct 24, 2024
45bf1d8
consider court cctv_and_bwcf and other requst types
lucas-shaw Oct 24, 2024
ea969b7
rubocop
lucas-shaw Oct 24, 2024
76708fd
refactor
lucas-shaw Oct 24, 2024
8dd126b
Merge branch 'cdpt-1850-commissioning-and-chase-redesign' into cdpt-1…
lucas-shaw Oct 24, 2024
044da5c
just create the new area
lucas-shaw Oct 24, 2024
2dbedc9
Merge branch 'cdpt-1858-update-existing-data-requests' of github.com:…
lucas-shaw Oct 24, 2024
ef8c259
add presence to contact_id
lucas-shaw Oct 25, 2024
94affaa
all data requests are associated with Offender Sar and complaints
lucas-shaw Oct 25, 2024
c9c1b12
move all others into other_department area
lucas-shaw Oct 25, 2024
5960425
preserve existing comm documents
lucas-shaw Oct 29, 2024
09b7ffb
add commissioning_document association back to DataRequest
lucas-shaw Oct 31, 2024
775bcc0
rubocop
lucas-shaw Oct 31, 2024
4cca9f7
remove attachment conditional
lucas-shaw Nov 4, 2024
7c7a932
temp skip callback for migration
lucas-shaw Nov 6, 2024
b1e30c6
rubocop
lucas-shaw Nov 6, 2024
f75a6e6
remove unless
lucas-shaw Nov 6, 2024
61d72f4
rubocop
lucas-shaw Nov 6, 2024
661b981
rubocop
lucas-shaw Nov 6, 2024
03e9758
rubocop
lucas-shaw Nov 6, 2024
1f2075a
destroy and replace existing comm doc
lucas-shaw Nov 8, 2024
f0e1b47
Merge branch 'cdpt-1850-commissioning-and-chase-redesign' into cdpt-1…
lucas-shaw Nov 27, 2024
94f844c
Merge branch 'cdpt-1850-commissioning-and-chase-redesign' into cdpt-1…
lucas-shaw Nov 29, 2024
1df5e02
skip validation
lucas-shaw Dec 3, 2024
2cc33dc
rubocop ignore
lucas-shaw Dec 3, 2024
b5f8733
update attribute
lucas-shaw Dec 3, 2024
300eb4f
update attribute
lucas-shaw Dec 3, 2024
cfb893a
add rescue block to catch errors
lucas-shaw Dec 5, 2024
9f0b6ce
add rescue block to catch errors
lucas-shaw Dec 5, 2024
1304eea
remove begin
lucas-shaw Dec 5, 2024
f39dbc9
more log info
lucas-shaw Dec 5, 2024
35b404c
more log info
lucas-shaw Dec 5, 2024
d366ccb
provide unknown location for blank values
lucas-shaw Dec 5, 2024
ce4d84b
add comment
lucas-shaw Dec 5, 2024
bdb6500
migrate the data request emails to the data request area
lucas-shaw Dec 6, 2024
7765d2d
Merge branch 'cdpt-1850-commissioning-and-chase-redesign' into cdpt-1…
lucas-shaw Dec 13, 2024
e8fe71d
Merge branch 'cdpt-1850-commissioning-and-chase-redesign' into cdpt-1…
lucas-shaw Dec 13, 2024
e3c848d
Merge branch 'cdpt-1850-commissioning-and-chase-redesign' into cdpt-1…
lucas-shaw Dec 13, 2024
9471e8f
Merge branch 'cdpt-1850-commissioning-and-chase-redesign' into cdpt-1…
vertism Dec 13, 2024
4813776
Merge branch 'cdpt-1850-commissioning-and-chase-redesign' into cdpt-1…
vertism Dec 13, 2024
b3060c8
remove logging
lucas-shaw Dec 17, 2024
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
48 changes: 48 additions & 0 deletions db/data_migrations/20241024131255_migrate_data_request_areas.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# frozen_string_literal: true

class MigrateDataRequestAreas < ActiveRecord::DataMigration
def data_request_area_type_for(request_type)
case request_type
when *DataRequest::BRANSTON_DATA_REQUEST_TYPES
vertism marked this conversation as resolved.
Show resolved Hide resolved
"branston"
when *DataRequest::BRANSTON_REGISTRY_DATA_REQUEST_TYPES
"branston_registry"
when *DataRequest::MAPPA_DATA_REQUEST_TYPES
"mappa"
when *DataRequest::PRISON_DATA_REQUEST_TYPES + %w[cctv_and_bwcf]
"prison"
when *DataRequest::PROBATION_DATA_REQUEST_TYPES + %w[court]
"probation"
when "other"
"other_department"
end
end

def up
# get DataRequests for only Offender and OffenderComplaint
data_requests = DataRequest.joins(:offender_sar_case)
lucas-shaw marked this conversation as resolved.
Show resolved Hide resolved
.where(offender_sar_case: { type: %w[Case::SAR::Offender Case::SAR::OffenderComplaint] })

# loop through the DataRequest records
data_requests.find_each do |request|
# 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


data_request_area = DataRequestArea.create!(
user_id: request.user_id,
case_id: request.case_id,
data_request_area_type:,
contact_id: request.contact_id,
location: request.location.presence,
)

# Update DataRequest with the correct data_request_area_id
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

end
end
end