kithe 2.9.1 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93c4a833066e2a68f5d9c83832d8f1447d38273d3c8072a03107355a966d31eb
4
- data.tar.gz: 4a385e4a556d8c10cd19a30eb777c2734fbbb8e24fa9d8708f190b30d078322f
3
+ metadata.gz: 2442db92e7c22e24d345483d17020d6025c42e4b24b9fe2dbdf0d9ad8625309e
4
+ data.tar.gz: 8d15649504ce721fd2c8b5ee1dc8a7f64b9486e64e3f4f3b5a983ce8d295e5ed
5
5
  SHA512:
6
- metadata.gz: 02f4f4a6e5883b48ebd7c404817119b079ebce79c280cbb55861ba08c5d22002954884835d03ef3e8eab9eaac5dab023d605726f36780b53a0c1840b030ac5c9
7
- data.tar.gz: 57b9a9aa6fd4e56a1831cdba2f793ae9ed2aa9f934b604fe270805a67c866d27df36aa3a2551870b9f8da88ffd99db826efe2b3b85fdbb55b9f12044d6f799ae
6
+ metadata.gz: 788253f8998adb2a6cd1799b4b124d7e301737477a002c6541f7de5b33f8c6744b818d8aee40de67e3eea316ca6be3411f28a6a2c1951a2ca921416e810cfc45
7
+ data.tar.gz: dac26e54710bef716c27833bf822763fc54f784a009835ee43d71fe7e39e63f315cce90dbd6b9a34af54e7ec5ab604b9bf9d749a5450bb94fdc4ebbcdcc4cbf6
@@ -1,7 +1,23 @@
1
1
  module Kithe
2
+ # Create derivatives in a bg job.
3
+ #
4
+ # Used as part of kithe standard ingest flow, to create all derivatives in bg job for new
5
+ # ingest
6
+ #
7
+ # Can also be used explicitly, with args, to create only certain derivs, optionally lazily
8
+ #
9
+ # @example
10
+ #
11
+ # CreateDerivativesJob.new(asset).perform_later
12
+ #
13
+ # CreateDerivativesJob.new(asset, lazy: true).perform_later
14
+ #
15
+ # CreateDerivativesJob.new(asset, only: :some_deriv, lazy: true).perform_later
16
+ #
17
+ # CreateDerivativesJob.new(asset, except: :other_deriv, lazy: true).perform_later
2
18
  class CreateDerivativesJob < Job
3
- def perform(asset)
4
- asset.create_derivatives
19
+ def perform(asset, lazy: false, only: nil, except: nil)
20
+ asset.create_derivatives(lazy: lazy, only: only, except: except)
5
21
  end
6
22
  # This error typically occurs when several large assets, whose derivatives
7
23
  # take a long time to generate, are deleted immediately after ingest.
data/lib/kithe/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kithe
2
- VERSION = '2.9.1'
2
+ VERSION = '2.10.0'
3
3
  end
@@ -12,6 +12,7 @@ namespace :kithe do
12
12
  opts.on("--lazy", "Lazy create") { options[:lazy] = true }
13
13
  opts.on("--asset-id=FRIENDLIER_IDS", "comma-seperated list of asset (friendlier) ids") { |ids| options[:asset_ids] = ids.split(",") }
14
14
  opts.on("--work-id=FRIENDLIER_IDS", "comma-seperated list of work (friendlier) ids") { |ids| options[:work_ids] = ids.split(",") }
15
+ opts.on("--bg[=QUEUE_NAME]", "queue up ActiveJob per asset to create, with optional queue name") { |queue| options[:bg] = queue || true}
15
16
  end.tap do |parser|
16
17
  parser.parse!(parser.order(ARGV) {})
17
18
  end
@@ -27,10 +28,25 @@ namespace :kithe do
27
28
  scope.find_each do |asset|
28
29
  begin
29
30
  progress_bar.title = asset.friendlier_id
30
- asset.create_derivatives(
31
- only: options[:derivative_keys],
32
- lazy: !!options[:lazy]
33
- )
31
+
32
+ if options[:bg]
33
+ job_scope = Kithe::CreateDerivativesJob
34
+
35
+ if options[:bg].kind_of?(String)
36
+ job_scope = job_scope.set(queue: options[:bg])
37
+ end
38
+
39
+ job_scope.perform_later(
40
+ asset,
41
+ only: options[:derivative_keys],
42
+ lazy: !!options[:lazy]
43
+ )
44
+ else
45
+ asset.create_derivatives(
46
+ only: options[:derivative_keys],
47
+ lazy: !!options[:lazy]
48
+ )
49
+ end
34
50
  rescue Shrine::FileNotFound => e
35
51
  progress_bar.log("original missing for #{asset.friendlier_id}")
36
52
  # it's cool, skip it
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kithe
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.1
4
+ version: 2.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-12 00:00:00.000000000 Z
11
+ date: 2023-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails