worker_plugins 0.0.4 → 0.0.5

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: 0200fe1c8fd8d1618539ea3306191456ec929cd8f6e70ae2fb707f9ba79d314f
4
- data.tar.gz: 1d78c88a6aabfa667bf9d7f8533a52dfb12c3edfe9908c45da97fc85e4234d79
3
+ metadata.gz: 8010aee14c8aa6b008bd0ab626f52a3e9da9c14c560d04f0c757f13781d4cbca
4
+ data.tar.gz: 3aba5e574d71e6671c0d45b68fea71a50b1d8c31ec13e166679f74eee0c09c9f
5
5
  SHA512:
6
- metadata.gz: c9b8c48f468ddd91c47b784472a87f860e98982ec7aba4674cf701395ce8ea27434e1c2de115d3f6033268930a6ed30c4d8a69953b82707b5b66d0780ae2fbdf
7
- data.tar.gz: c1d0d739c588beacb9aa44c44ff627f7ad838546d39ccceef936022babf539d7fe57819294ae2becaa416da26f0cef47651901667e02964b8e470c4c6df9111c
6
+ metadata.gz: 44dfebac2c28da2dba9e4f8cf746088daa85b33729f46e00e5548ac252d09425904b182eef34980fe72e9b6b3c0289ba0d71dd4c7b2170f2bbc7924ef4ce26be
7
+ data.tar.gz: affd58ce192d134c0c4918f114d5a2423b0aadde3e21be1ccbda039b96162e88f2ab54cb779914692ddbe54a18e060a144e19179efe45e4b8d342b26f9d7e597
@@ -4,6 +4,5 @@ class WorkerPlugins::WorkplaceLink < ActiveRecord::Base # rubocop:disable Rails/
4
4
  belongs_to :workplace
5
5
  belongs_to :resource, polymorphic: true
6
6
 
7
- validates :workplace, :resource, presence: true
8
7
  validates :resource_id, uniqueness: {scope: [:resource_type, :workplace_id]}
9
8
  end
@@ -1,4 +1,4 @@
1
- class WorkerPlugins::AddCollection < WorkerPlugins::ApplicationService
1
+ class WorkerPlugins::AddQuery < WorkerPlugins::ApplicationService
2
2
  attr_reader :query, :workplace
3
3
 
4
4
  def initialize(query:, workplace:)
@@ -63,7 +63,7 @@ class WorkerPlugins::AddCollection < WorkerPlugins::ApplicationService
63
63
  .select("
64
64
  #{db_now_value},
65
65
  #{quote(resources_to_add.klass.name)},
66
- \"#{resources_to_add.klass.table_name}\".\"#{primary_key}\",
66
+ #{quote_table(resources_to_add.klass.table_name)}.#{quote_column(primary_key)},
67
67
  #{db_now_value},
68
68
  #{select_workplace_id_sql}
69
69
  ")
@@ -15,6 +15,14 @@ class WorkerPlugins::ApplicationService < ServicePattern::Service
15
15
  WorkerPlugins::Workplace.connection.quote(value)
16
16
  end
17
17
 
18
+ def quote_column(value)
19
+ WorkerPlugins::Workplace.connection.quote_column_name(value)
20
+ end
21
+
22
+ def quote_table(value)
23
+ WorkerPlugins::Workplace.connection.quote_table_name(value)
24
+ end
25
+
18
26
  def postgres?
19
27
  ActiveRecord::Base.connection.instance_values["config"][:adapter].downcase.include?("postgres")
20
28
  end
@@ -0,0 +1,19 @@
1
+ class WorkerPlugins::QueryLinksStatus < WorkerPlugins::ApplicationService
2
+ arguments :query, :workplace
3
+
4
+ def perform
5
+ checked_count = workplace
6
+ .workplace_links
7
+ .where(resource_id: query.distinct.select(query.klass.primary_key))
8
+ .count
9
+
10
+ query_count = query.count
11
+
12
+ succeed!(
13
+ all_checked: query_count == checked_count,
14
+ checked_count: checked_count,
15
+ query_count: query_count,
16
+ some_checked: checked_count.positive? && checked_count < query_count
17
+ )
18
+ end
19
+ end
@@ -1,10 +1,7 @@
1
- class WorkerPlugins::RemoveCollection < WorkerPlugins::ApplicationService
2
- attr_reader :destroyed, :query, :workplace
1
+ class WorkerPlugins::RemoveQuery < WorkerPlugins::ApplicationService
2
+ arguments :query, :workplace
3
3
 
4
- def initialize(query:, workplace:)
5
- @query = query
6
- @workplace = workplace
7
- end
4
+ attr_reader :destroyed
8
5
 
9
6
  def perform
10
7
  remove_query_from_workplace
@@ -25,7 +22,7 @@ class WorkerPlugins::RemoveCollection < WorkerPlugins::ApplicationService
25
22
  WorkerPlugins::SelectColumnWithTypeCast.execute!(
26
23
  column_name_to_select: :id,
27
24
  column_to_compare_with: WorkerPlugins::WorkplaceLink.column_for_attribute(:resource_id),
28
- query: query
25
+ query: query.except(:order)
29
26
  )
30
27
  end
31
28
  end
@@ -1,11 +1,5 @@
1
1
  class WorkerPlugins::SelectColumnWithTypeCast < WorkerPlugins::ApplicationService
2
- attr_reader :column_name_to_select, :column_to_compare_with, :query
3
-
4
- def initialize(column_name_to_select:, column_to_compare_with:, query:)
5
- @column_name_to_select = column_name_to_select
6
- @column_to_compare_with = column_to_compare_with
7
- @query = query
8
- end
2
+ arguments :column_name_to_select, :column_to_compare_with, :query
9
3
 
10
4
  def perform
11
5
  return succeed! query.select(column_name_to_select) if same_type?
@@ -1,20 +1,15 @@
1
- class WorkerPlugins::SwitchCollection < WorkerPlugins::ApplicationService
2
- attr_reader :query, :workplace
3
-
4
- def initialize(query:, workplace:)
5
- @query = query
6
- @workplace = workplace
7
- end
1
+ class WorkerPlugins::SwitchQuery < WorkerPlugins::ApplicationService
2
+ arguments :query, :workplace
8
3
 
9
4
  def perform
10
5
  if resources_to_add.count.zero?
11
- result = WorkerPlugins::RemoveCollection.execute!(query: query, workplace: workplace)
6
+ result = WorkerPlugins::RemoveQuery.execute!(query: query, workplace: workplace)
12
7
  succeed!(
13
8
  destroyed: result.fetch(:destroyed),
14
9
  mode: :destroyed
15
10
  )
16
11
  else
17
- result = WorkerPlugins::AddCollection.execute!(query: query, workplace: workplace)
12
+ result = WorkerPlugins::AddQuery.execute!(query: query, workplace: workplace)
18
13
  succeed!(
19
14
  created: result.fetch(:created),
20
15
  mode: :created
data/config/routes.rb CHANGED
@@ -1,2 +1,2 @@
1
- Rails.application.routes.draw do
1
+ Rails.application.routes.draw do # rubocop:disable Lint/EmptyBlock
2
2
  end
@@ -1,5 +1,9 @@
1
- class ChangeWorkplaceLinksResourceIdToStringToSupportUuids < ActiveRecord::Migration[6.0]
2
- def change
1
+ class ChangeWorkplaceLinksResourceIdToStringToSupportUuids < ActiveRecord::Migration[7.0]
2
+ def up
3
3
  change_column :worker_plugins_workplace_links, :resource_id, :string
4
4
  end
5
+
6
+ def down
7
+ change_column :worker_plugins_workplace_links, :resource_id, :bigint
8
+ end
5
9
  end
@@ -1,5 +1,9 @@
1
1
  class ChangeResourceIdToStringToSupportUuid < ActiveRecord::Migration[6.1]
2
- def change
2
+ def up
3
3
  change_column :worker_plugins_workplace_links, :resource_id, :string
4
4
  end
5
+
6
+ def down
7
+ change_column :worker_plugins_workplace_links, :resource_id, :bigint
8
+ end
5
9
  end
@@ -1,6 +1,6 @@
1
1
  module WorkerPlugins; end
2
2
 
3
- class WorkerPlugins::Engine < ::Rails::Engine
3
+ class WorkerPlugins::Engine < Rails::Engine
4
4
  isolate_namespace WorkerPlugins
5
5
 
6
6
  # Add translations to load path.
@@ -1,3 +1,3 @@
1
1
  module WorkerPlugins
2
- VERSION = "0.0.4".freeze
2
+ VERSION = "0.0.5".freeze
3
3
  end
metadata CHANGED
@@ -1,169 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worker_plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johanmsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-04 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 5.0.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 5.0.0
27
- - !ruby/object:Gem::Dependency
28
- name: service_pattern
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.0.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 1.0.0
41
- - !ruby/object:Gem::Dependency
42
- name: awesome_translations
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: factory_bot_rails
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry-rails
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rspec-rails
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop-performance
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop-rails
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop-rspec
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: sqlite3
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
11
+ date: 2023-05-09 00:00:00.000000000 Z
12
+ dependencies: []
167
13
  description: Rails framework for easily choosing and creating lists of objects and
168
14
  execute plugins against them.
169
15
  email:
@@ -177,11 +23,12 @@ files:
177
23
  - Rakefile
178
24
  - app/models/worker_plugins/workplace.rb
179
25
  - app/models/worker_plugins/workplace_link.rb
180
- - app/services/worker_plugins/add_collection.rb
26
+ - app/services/worker_plugins/add_query.rb
181
27
  - app/services/worker_plugins/application_service.rb
182
- - app/services/worker_plugins/remove_collection.rb
28
+ - app/services/worker_plugins/query_links_status.rb
29
+ - app/services/worker_plugins/remove_query.rb
183
30
  - app/services/worker_plugins/select_column_with_type_cast.rb
184
- - app/services/worker_plugins/switch_collection.rb
31
+ - app/services/worker_plugins/switch_query.rb
185
32
  - config/locales/awesome_translations/models/worker_plugins__workplace/da.yml
186
33
  - config/locales/awesome_translations/models/worker_plugins__workplace/en.yml
187
34
  - config/locales/awesome_translations/models/worker_plugins__workplace_link/da.yml
@@ -197,7 +44,8 @@ files:
197
44
  - lib/worker_plugins/version.rb
198
45
  homepage: https://www.github.com/kaspernj/worker_plugins
199
46
  licenses: []
200
- metadata: {}
47
+ metadata:
48
+ rubygems_mfa_required: 'true'
201
49
  post_install_message:
202
50
  rdoc_options: []
203
51
  require_paths:
@@ -206,7 +54,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
54
  requirements:
207
55
  - - ">="
208
56
  - !ruby/object:Gem::Version
209
- version: 2.5.7
57
+ version: 2.7.5
210
58
  required_rubygems_version: !ruby/object:Gem::Requirement
211
59
  requirements:
212
60
  - - ">="