Access the Argo CD Dashboard for Deployment Management:
Find the vets-api-web
node and start the Rails console with:
bundle exec rails c
Once logged in, use the following commands to interact with in-progress forms:
Sample Console Commands Get the last form entry for form number '5655':
InProgressForm.for_form('5655').last
To access the metadata for the last in-progress form:
InProgressForm.for_form('5655').last.metadata
- The
in_progress_form.rb
file is where theInProgressForm
ActiveRecord model is defined. - The
DebtsAPI
form5655_submission.rb - The
db/schema.rb
file contains the schema definition for the database
Warning - Don't mess with the update example unless you need to modify production data
Ruby cmds to iterate over Form5655Submission
records and updating the public_metadata
for each submission that has a 'streamlined' form:
// Get by uuid
DebtsApi::V0::Form5655Submission.where(user_uuid: 'your-uuid-here')
// Get the last streamlined short submission
DebtsApi::V0::Form5655Submission.where("public_metadata -> 'streamlined' ->> 'type' = ?", "short").last
// Get the # of all short submissions
DebtsApi::V0::Form5655Submission.where("public_metadata -> 'streamlined' ->> 'type' = ?", "short").length
// Get the # of all long submissions
DebtsApi::V0::Form5655Submission.where("public_metadata -> 'streamlined' ->> 'type' = ?", "long").length
// Get 20 random submissions by debt type
DebtsApi::V0::Form5655Submission.last(20).map { |sub| sub.public_metadata['debt_type'] }
// Get the last 20 by debt type
DebtsApi::V0::Form5655Submission.all.order(:created_at).last(20).map { |sub| sub.public_metadata['debt_type'] }
// Update data Example
DebtsApi::V0::Form5655Submission.find_each(batch_size: 300).with_index do |sub, index|
begin
form = sub.form
if form['streamlined']
puts "#{index}/#{total}" # Note: Ensure 'total' is defined as the total number of submissions.
metadata = sub.public_metadata
metadata['streamlined'] = form['streamlined']
sub.update!(public_metadata: metadata)
end
rescue => e # It's a good practice to specify what you're rescuing from, e.g., StandardError
trouble << sub.id # Ensure 'trouble' is initialized before this block.
puts "Error processing submission #{sub.id}: #{e.message}"
end
end
For more information on querying with Active Record, refer to the following guide:
- Rails Active Record Querying Guide: https://guides.rubyonrails.org/active_record_querying.html