bulk_ops 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/bulk_ops/operations_controller.rb +2 -16
- data/lib/bulk_ops/create_work_job.rb +8 -0
- data/lib/bulk_ops/update_work_job.rb +16 -0
- data/lib/bulk_ops/version.rb +1 -1
- data/lib/bulk_ops/work_job.rb +15 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f55b62bd327612efa466184efc9249133480ace66e3069fc7d20705eedfddf0f
|
4
|
+
data.tar.gz: 109e4e3cf3567864eeb15e73d3c6603219ee9577c8333c6cfb012409cac1b957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1172dd5be0f063944505b86da8a6a8b28913c69f1447523de9685d85524a55cb8a148f48ad112dbd7c158e9b63cab9ca50fbab0d2ff49c3ddd759dbd5940b52
|
7
|
+
data.tar.gz: 119bb5c71f7be6eb8c8514307eead3dcebf31304f1d4221575790ce3d4c931c5f57e9f3eb1157592ce3cbe805dfa2a815141196904a3f38cb533ea804f60a9b8
|
@@ -6,6 +6,7 @@ module BulkOps
|
|
6
6
|
before_action :define_presenter
|
7
7
|
before_action :github_auth
|
8
8
|
load_and_authorize_resource
|
9
|
+
|
9
10
|
before_action :initialize_options, only: [:new,:show,:edit, :update]
|
10
11
|
before_action :initialize_operation, only: [:edit, :destroy, :show, :request_apply, :approve, :csv, :errors, :log, :update, :request, :duplicate]
|
11
12
|
|
@@ -25,7 +26,7 @@ module BulkOps
|
|
25
26
|
branches = BulkOps::GithubAccess.list_branch_names current_user
|
26
27
|
BulkOps::Operation.all.each{|op| op.destroy! unless branches.include?(op.name) }
|
27
28
|
@active_operations = BulkOps::Operation.where.not(stage: ['completed','discarded'])
|
28
|
-
@active_operations.each {|op| op.destroy! unless branches.include?(op.name) }
|
29
|
+
@active_operations.each {|op| op.destroy! unless (op.stage == "running") or branches.include?(op.name) }
|
29
30
|
@old_operations = BulkOps::Operation.where(stage: ['completed','discarded']) if params["show_old_ops"]
|
30
31
|
end
|
31
32
|
|
@@ -167,25 +168,10 @@ module BulkOps
|
|
167
168
|
#If new options have been defined, update them in github
|
168
169
|
if params['edit_options']
|
169
170
|
if filtered_options_params && @operation.name
|
170
|
-
|
171
171
|
options = @operation.options
|
172
|
-
|
173
|
-
puts "BULKOPS UPDATING OPTIONS"
|
174
|
-
puts "all params: #{params.inspect}"
|
175
|
-
puts "Updating bulk_ops options"
|
176
|
-
puts "new options:"
|
177
|
-
puts filtered_options_params.inspect
|
178
|
-
puts "old options:"
|
179
|
-
puts options.inspect
|
180
|
-
|
181
|
-
|
182
172
|
filtered_options_params.each do |option_name, option_value|
|
183
173
|
options[option_name] = option_value
|
184
174
|
end
|
185
|
-
|
186
|
-
puts "final options:"
|
187
|
-
puts options.inspect
|
188
|
-
|
189
175
|
BulkOps::GithubAccess.update_options(@operation.name, options, message: params['git_message'])
|
190
176
|
flash[:notice] = "The operation options were updated successfully"
|
191
177
|
redirect_to action: "show", id: @operation.id
|
@@ -11,4 +11,12 @@ class BulkOps::CreateWorkJob < BulkOps::WorkJob
|
|
11
11
|
:create
|
12
12
|
end
|
13
13
|
|
14
|
+
def define_work workClass
|
15
|
+
if record_exists?(@work_proxy.work_id)
|
16
|
+
report_error "trying to ingest a work proxy that already has a work attached. Work id: #{@work_proxy.work_id} Proxy id: #{@work_proxy.id}"
|
17
|
+
return false
|
18
|
+
end
|
19
|
+
@work = workClass.capitalize.constantize.new
|
20
|
+
end
|
21
|
+
|
14
22
|
end
|
@@ -11,4 +11,20 @@ class BulkOps::UpdateWorkJob < BulkOps::WorkJob
|
|
11
11
|
:update
|
12
12
|
end
|
13
13
|
|
14
|
+
def define_work workClass=nil
|
15
|
+
# report an error if we can't find the work in solr
|
16
|
+
unless record_exists?(@work_proxy.work_id)
|
17
|
+
report_error "Could not find work to update with id: #{@work_proxy.work_id} referenced by work proxy: #{@work_proxy.id}"
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
# Report an error if we can't retrieve the work from Fedora.
|
21
|
+
begin
|
22
|
+
@work = ActiveFedora::Base.find(@work_proxy.work_id)
|
23
|
+
rescue ActiveFedora::ObjectNotFoundError
|
24
|
+
report_error "Could not find work to update in Fedora (though it shows up in Solr). Work id: #{@work_proxy.work_id}"
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
return @work
|
28
|
+
end
|
29
|
+
|
14
30
|
end
|
data/lib/bulk_ops/version.rb
CHANGED
data/lib/bulk_ops/work_job.rb
CHANGED
@@ -9,7 +9,7 @@ class BulkOps::WorkJob < ActiveJob::Base
|
|
9
9
|
after_perform do |job|
|
10
10
|
|
11
11
|
# update BulkOperationsWorkProxy status
|
12
|
-
@work ||= ActiveFedora.find(@work_proxy.work_id)
|
12
|
+
@work ||= ActiveFedora::Base.find(@work_proxy.work_id)
|
13
13
|
if @work.id.nil?
|
14
14
|
status = "error"
|
15
15
|
else
|
@@ -41,10 +41,15 @@ class BulkOps::WorkJob < ActiveJob::Base
|
|
41
41
|
|
42
42
|
# Check if the parent operation is finished
|
43
43
|
# and do any cleanup if so
|
44
|
-
|
44
|
+
|
45
|
+
if @work_proxy.operation.present? && @work_proxy.operation.respond_to?(:check_if_finished)
|
46
|
+
@work_proxy.operation.check_if_finished
|
47
|
+
end
|
48
|
+
|
45
49
|
end
|
46
50
|
|
47
51
|
def perform(workClass,user_email,attributes,work_proxy_id,visibility=nil)
|
52
|
+
return if status == "complete"
|
48
53
|
update_status "starting", "Initializing the job"
|
49
54
|
attributes['visibility']= visibility if visibility.present?
|
50
55
|
@work_proxy = BulkOps::WorkProxy.find(work_proxy_id)
|
@@ -52,23 +57,9 @@ class BulkOps::WorkJob < ActiveJob::Base
|
|
52
57
|
report_error("Cannot find work proxy with id: #{work_proxy_id}")
|
53
58
|
return
|
54
59
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
begin
|
59
|
-
@work = ActiveFedora::Base.find(@work_proxy.work_id)
|
60
|
-
rescue ActiveFedora::ObjectNotFoundError
|
61
|
-
report_error "Could not find work to update in Fedora (though it shows up in Solr). Work id: #{@work_proxy.work_id}"
|
62
|
-
return
|
63
|
-
end
|
64
|
-
else # The work is not found in Solr. If we're trying to update a work, we're in trouble.
|
65
|
-
if (type.to_s == "update")
|
66
|
-
report_error "Could not find work to update with id: #{@work_proxy.work_id}"
|
67
|
-
return
|
68
|
-
end
|
69
|
-
# Create the work we are ingesting
|
70
|
-
@work = workClass.capitalize.constantize.new
|
71
|
-
end
|
60
|
+
|
61
|
+
return unless define_work
|
62
|
+
|
72
63
|
user = User.find_by_email(user_email)
|
73
64
|
update_status "running", "Started background task at #{DateTime.now.strftime("%d/%m/%Y %H:%M")}"
|
74
65
|
ability = Ability.new(user)
|
@@ -102,4 +93,9 @@ class BulkOps::WorkJob < ActiveJob::Base
|
|
102
93
|
@work_proxy.update(atts)
|
103
94
|
end
|
104
95
|
|
96
|
+
def define_work(workClass)
|
97
|
+
#override this unless you want a simple ingest
|
98
|
+
@work = workClass.capitalize.constantize.new
|
99
|
+
end
|
100
|
+
|
105
101
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulk_ops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ned Henry, UCSC Library Digital Initiatives
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|