Skip to content

Commit

Permalink
Adds rake task to attach a file to a file inventory job (#1329)
Browse files Browse the repository at this point in the history
* Adds rake task to attach a file to a file inventory job

* Populate the project title in the job details
  • Loading branch information
hectorcorrea authored Feb 28, 2025
1 parent e980dd3 commit 7b40e79
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/tasks/file_inventory.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

namespace :file_inventory do
desc "Attaches a file to a file inventory job"
task :attach_file, [:job_id, :filename] => [:environment] do |_, args|
job_id = args[:job_id]
filename = args[:filename]

request = FileInventoryRequest.where(job_id: job_id).first
raise "Job #{job_id} not found" if request.nil?
raise "File #{filename} not found" unless File.exist?(filename)

puts "Attaching file #{filename} to job #{job_id}"
request.completion_time = Time.current.in_time_zone("America/New_York")
request.state = "completed"
request.request_details = { file_size: File.size(filename), output_file: filename, project_title: request.project.title }
request.save!
end
end

0 comments on commit 7b40e79

Please sign in to comment.