Class: WorkUploadsEditService
- Inherits:
-
Object
- Object
- WorkUploadsEditService
- Defined in:
- app/services/work_uploads_edit_service.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#s3_service ⇒ Object
readonly
Returns the value of attribute s3_service.
-
#work ⇒ Object
readonly
Returns the value of attribute work.
Instance Method Summary collapse
- #find_post_curation_uploads(upload_keys: []) ⇒ Object
-
#initialize(work, current_user) ⇒ WorkUploadsEditService
constructor
A new instance of WorkUploadsEditService.
-
#snapshot_uppy_and_delete_files(deleted_files) ⇒ Object
Delete any files the user has decided not to keep and add all files that were uploaded in the backgroud via uppy and any files deleted to an upload snapshot.
- #update_precurated_file_list(added_files, deleted_files) ⇒ Object
Constructor Details
#initialize(work, current_user) ⇒ WorkUploadsEditService
Returns a new instance of WorkUploadsEditService.
5 6 7 8 9 |
# File 'app/services/work_uploads_edit_service.rb', line 5 def initialize(work, current_user) @work = work @s3_service = work.s3_query_service @current_user = current_user end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
3 4 5 |
# File 'app/services/work_uploads_edit_service.rb', line 3 def current_user @current_user end |
#s3_service ⇒ Object (readonly)
Returns the value of attribute s3_service.
3 4 5 |
# File 'app/services/work_uploads_edit_service.rb', line 3 def s3_service @s3_service end |
#work ⇒ Object (readonly)
Returns the value of attribute work.
3 4 5 |
# File 'app/services/work_uploads_edit_service.rb', line 3 def work @work end |
Instance Method Details
#find_post_curation_uploads(upload_keys: []) ⇒ Object
39 40 41 42 |
# File 'app/services/work_uploads_edit_service.rb', line 39 def find_post_curation_uploads(upload_keys: []) return [] unless work.approved? && !upload_keys.empty? work.post_curation_uploads.select { |upload| upload_keys.include?(upload.key) } end |
#snapshot_uppy_and_delete_files(deleted_files) ⇒ Object
Delete any files the user has decided not to keep and
add all files that were uploaded in the backgroud via uppy and any files deleted to an upload snapshot
29 30 31 32 33 34 35 36 37 |
# File 'app/services/work_uploads_edit_service.rb', line 29 def snapshot_uppy_and_delete_files(deleted_files) deleted_files.each do |filename| s3_service.delete_s3_object(filename) end # assigns all backgroun changes and deletes to the current user work.reload_snapshots(user_id: current_user.id) work end |
#update_precurated_file_list(added_files, deleted_files) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/work_uploads_edit_service.rb', line 11 def update_precurated_file_list(added_files, deleted_files) delete_uploads(deleted_files) add_uploads(added_files) file_list_changed = deleted_files.count > 0 || added_files.count > 0 if file_list_changed s3_service.client_s3_files(reload: true) # Pick up the changes in the attachments and assings them to the current user work.reload work.reload_snapshots(user_id: current_user.id) end work end |