aranha-rails 0.8.4 → 0.9.1

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: 26eb70930f47095800bebbc88be94c5d44434dc018631e9f03a5783736fc322c
4
- data.tar.gz: 86e7e889983b3d370924e79e8d9127f7fc55845a3bec8205a816493a74e0b522
3
+ metadata.gz: 1fac4b4415a0b0c6b57e859f927db71d2f774614a079948ac20c0b6fffa98dfe
4
+ data.tar.gz: 53158ba946e3084892549d6c05129cc07a564d2d9297964e688438a0d6b85363
5
5
  SHA512:
6
- metadata.gz: f22e1064e807d5fdfcc42a6af3fb4322a7ee74e3824f6536f54d9d71cfb241254a5c74660b4f1123818eec65c34cb513657e7d5ddd3c27a1ccdd9e25af17ad28
7
- data.tar.gz: a4671ab1a659124ce76fb0af5cb2a38933eac2dbba603d984e8b23c8556bfcd93c12e9e51acabcb3dc16dba937a924ee4cf3b238615f0d9136abfcdf0fb77364
6
+ metadata.gz: 3e9710b331f294a61fda19477d14f3f8da64b6402700defd075f1218ce6243207738eabcb3944d85a335481e8423ad244b50b584b7880c700a61ca15ce273434
7
+ data.tar.gz: 7b4d994930b0c115509a47eaaacb87df9f48d0ed0adf1b528674cda54355d108c8e7e804f108f0908723857fc17f4833573b4512f0df1d24caa1f368e35c624c
@@ -9,7 +9,7 @@ module Aranha
9
9
  common_constructor :address_id
10
10
 
11
11
  def perform
12
- ::Rails.logger.info("Processing \"#{address.url}\"")
12
+ ::Rails.logger.info("Processing \"#{address}\"")
13
13
  address_processor.successful? ? perform_on_success : perform_on_error
14
14
  end
15
15
 
@@ -11,6 +11,8 @@ module Aranha
11
11
  module Scheduling
12
12
  common_concern
13
13
 
14
+ DEFAULT_PRIORITY = 0
15
+
14
16
  module ClassMethods
15
17
  # @return [Array<Aranha::Address>]
16
18
  def expired(time = ::Time.zone.now)
@@ -24,7 +26,8 @@ module Aranha
24
26
 
25
27
  job = ::Delayed::Job.enqueue(
26
28
  ::Aranha::Address::DelayedJob.new(id),
27
- queue: ::Aranha::Rails::Process::QUEUE
29
+ queue: ::Aranha::Rails::Process::QUEUE,
30
+ priority: priority
28
31
  )
29
32
  update!(delayed_job: job)
30
33
  end
@@ -43,6 +46,10 @@ module Aranha
43
46
  tries_count < ::Aranha::Processor::DEFAULT_MAX_TRIES
44
47
  end
45
48
 
49
+ def priority
50
+ processor_configuration.if_present(DEFAULT_PRIORITY, &:priority)
51
+ end
52
+
46
53
  def schedule?
47
54
  processed_at.blank? && allow_retry? && delayed_job.blank? && enabled?
48
55
  end
@@ -31,6 +31,7 @@ module Aranha
31
31
  end
32
32
  end
33
33
 
34
+ validates :priority, numericality: { only_integer: true }
34
35
  validates :processor_class, presence: true
35
36
  validate :processor_class_in_list
36
37
  validates :timeout_seconds, allow_blank: true,
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddPriorityToAranhaProcessorConfigurations < ActiveRecord::Migration[5.2]
4
+ def change
5
+ add_column :aranha_processor_configurations, :priority, :integer, default: 0, null: false
6
+ end
7
+ end
@@ -9,7 +9,7 @@ module Aranha
9
9
  include ::Singleton
10
10
 
11
11
  def add_address(url, processor, extra_data = nil)
12
- ::Rails.logger.info("Adding \"#{url}\"")
12
+ ::Rails.logger.info("Adding \"#{url} | #{processor} | #{extra_data}\"")
13
13
  a = ::Aranha::Address.find_or_initialize_by(url: ::Aranha::Address.sanitize_url(url))
14
14
  a.processor = processor
15
15
  a.extra_data = extra_data.to_yaml
@@ -43,7 +43,7 @@ module Aranha
43
43
  end
44
44
 
45
45
  def unprocessed_addresses
46
- ::Aranha::Address.all.select(&:schedule?)
46
+ ::Aranha::Address.all.select(&:schedule?).sort_by { |a| [a.priority] }
47
47
  end
48
48
  end
49
49
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aranha
4
4
  module Rails
5
- VERSION = '0.8.4'
5
+ VERSION = '0.9.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aranha-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-22 00:00:00.000000000 Z
11
+ date: 2023-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha
@@ -16,54 +16,54 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.18'
19
+ version: '0.19'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.19.2
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '0.18'
29
+ version: '0.19'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.19.2
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: aranha-parsers
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '0.14'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 0.14.4
39
+ version: '0.20'
37
40
  type: :runtime
38
41
  prerelease: false
39
42
  version_requirements: !ruby/object:Gem::Requirement
40
43
  requirements:
41
44
  - - "~>"
42
45
  - !ruby/object:Gem::Version
43
- version: '0.14'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.14.4
46
+ version: '0.20'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eac_active_scaffold
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.2'
53
+ version: '0.5'
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 0.2.3
56
+ version: 0.5.1
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '0.2'
63
+ version: '0.5'
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 0.2.3
66
+ version: 0.5.1
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: eac_rails_delayed_job
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -73,7 +73,7 @@ dependencies:
73
73
  version: '0.1'
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: 0.1.3
76
+ version: 0.1.4
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
@@ -83,47 +83,41 @@ dependencies:
83
83
  version: '0.1'
84
84
  - - ">="
85
85
  - !ruby/object:Gem::Version
86
- version: 0.1.3
86
+ version: 0.1.4
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: eac_rails_utils
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
91
  - - "~>"
92
92
  - !ruby/object:Gem::Version
93
- version: '0.17'
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 0.17.1
93
+ version: '0.19'
97
94
  type: :runtime
98
95
  prerelease: false
99
96
  version_requirements: !ruby/object:Gem::Requirement
100
97
  requirements:
101
98
  - - "~>"
102
99
  - !ruby/object:Gem::Version
103
- version: '0.17'
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- version: 0.17.1
100
+ version: '0.19'
107
101
  - !ruby/object:Gem::Dependency
108
102
  name: eac_ruby_utils
109
103
  requirement: !ruby/object:Gem::Requirement
110
104
  requirements:
111
105
  - - "~>"
112
106
  - !ruby/object:Gem::Version
113
- version: '0.107'
107
+ version: '0.117'
114
108
  - - ">="
115
109
  - !ruby/object:Gem::Version
116
- version: 0.107.1
110
+ version: 0.117.1
117
111
  type: :runtime
118
112
  prerelease: false
119
113
  version_requirements: !ruby/object:Gem::Requirement
120
114
  requirements:
121
115
  - - "~>"
122
116
  - !ruby/object:Gem::Version
123
- version: '0.107'
117
+ version: '0.117'
124
118
  - - ">="
125
119
  - !ruby/object:Gem::Version
126
- version: 0.107.1
120
+ version: 0.117.1
127
121
  - !ruby/object:Gem::Dependency
128
122
  name: rails
129
123
  requirement: !ruby/object:Gem::Requirement
@@ -190,6 +184,7 @@ files:
190
184
  - db/migrate/20210721185222_add_last_error_to_aranha_addresses.rb
191
185
  - db/migrate/20210814220540_create_aranha_processor_configurations.rb
192
186
  - db/migrate/20210815160543_add_enabled_to_aranha_processor_configurations.rb
187
+ - db/migrate/20230602212759_add_priority_to_aranha_processor_configurations.rb
193
188
  - lib/aranha/rails.rb
194
189
  - lib/aranha/rails/engine.rb
195
190
  - lib/aranha/rails/fixtures_download.rb