Skip to content

Commit

Permalink
Add commits from v5.0.4 back to main (#7023)
Browse files Browse the repository at this point in the history
* Prevent loss of attributes with reschedule

This commit changes to use a temporary variable to hold the
job attributes, so that when CreateWorkJob is rescheduled due to
any errors, the attributes that were deleted do not get left out
of the resubmitted job's attributes.

* BatchCreateJob loses attributes

When the job is rescheduled, the attributes are lost.

This commit removes the reassignment of attributes so
a job autoretry has all of the attributes of the original job.

* Version bump to 5.0.4

* Fixing rubocop violation

* Fix chars eaten by merge conflict

---------

Co-authored-by: LaRita Robinson <[email protected]>
Co-authored-by: LaRita Robinson <[email protected]>
Co-authored-by: Daniel Pierce <[email protected]>
  • Loading branch information
4 people authored Feb 28, 2025
1 parent e88c89e commit 8c9f7f1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
11 changes: 6 additions & 5 deletions app/jobs/batch_create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ def perform(user, titles, resource_types, uploaded_files, attributes, operation)
private

def create(user, titles, resource_types, uploaded_files, attributes, operation)
model = attributes.delete(:model) || attributes.delete('model')
job_attributes = attributes
model = job_attributes.delete(:model) || job_attributes.delete('model')
raise ArgumentError, 'attributes must include "model" => ClassName.to_s' unless model
uploaded_files.each do |upload_id|
title = [titles[upload_id]] if titles[upload_id]
resource_type = Array.wrap(resource_types[upload_id]) if resource_types[upload_id]
attributes = attributes.merge(uploaded_files: [upload_id],
title: title,
resource_type: resource_type)
job_attributes = job_attributes.merge(uploaded_files: [upload_id],
title: title,
resource_type: resource_type)
child_operation = Hyrax::Operation.create!(user: user,
operation_type: "Create Work",
parent: operation)
CreateWorkJob.perform_later(user, model, attributes, child_operation)
CreateWorkJob.perform_later(user, model, job_attributes, child_operation)
end
end
end
7 changes: 4 additions & 3 deletions app/jobs/create_work_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ def batch_create_af_work(work, attributes, user)
end

def batch_create_valkyrie_work(work, attributes, user)
uploaded_file_ids = attributes.delete(:uploaded_files)
form_attributes = attributes
uploaded_file_ids = form_attributes.delete(:uploaded_files)
files = Hyrax::UploadedFile.find(uploaded_file_ids)
permissions_params = attributes.delete(:permissions_attributes)
permissions_params = form_attributes.delete(:permissions_attributes)
form = Hyrax::FormFactory.new.build(work, nil, nil)
form.validate(attributes)
form.validate(form_attributes)

transactions['change_set.create_work']
.with_step_args(
Expand Down
4 changes: 2 additions & 2 deletions documentation/developing-your-hyrax-based-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ You can also try [Running Hyrax-based application in local VM](https://github.co
During development, running only the dependent services in a container environment may be beneficial. This avoids potential headaches concerning file permissions and eases the use of debugging tools. The application generation instructions below use [Lando](https://lando.dev) to achieve this setup.

This document contains instructions specific to setting up an app with __Hyrax
v5.0.3__. If you are looking for instructions on installing a different
v5.0.4__. If you are looking for instructions on installing a different
version, be sure to select the appropriate branch or tag from the drop-down
menu above.

Expand Down Expand Up @@ -148,7 +148,7 @@ Generate a new Rails application using the template.
**NOTE:** `HYRAX_SKIP_WINGS` is needed here to avoid loading the Wings compatibility layer during the application generation process.

```shell
HYRAX_SKIP_WINGS=true rails _6.1.7.7_ new my_app --database=postgresql -m https://raw.githubusercontent.com/samvera/hyrax/hyrax-v5.0.3/template.rb
HYRAX_SKIP_WINGS=true rails _6.1.7.7_ new my_app --database=postgresql -m https://raw.githubusercontent.com/samvera/hyrax/hyrax-v5.0.4/template.rb
```

Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including:
Expand Down
2 changes: 1 addition & 1 deletion lib/hyrax/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
module Hyrax
VERSION = '5.0.3'
VERSION = '5.0.4'
end
2 changes: 1 addition & 1 deletion template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"\n config.add_autoload_paths_to_load_path = true"
end

gem 'hyrax', '5.0.3'
gem 'hyrax', '5.0.4'
run 'bundle install'
generate 'hyrax:install', '-f'

0 comments on commit 8c9f7f1

Please sign in to comment.