worker_plugins 0.0.5 → 0.0.6

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: 8010aee14c8aa6b008bd0ab626f52a3e9da9c14c560d04f0c757f13781d4cbca
4
- data.tar.gz: 3aba5e574d71e6671c0d45b68fea71a50b1d8c31ec13e166679f74eee0c09c9f
3
+ metadata.gz: 45f9e6adbbcb13324a929a4acae8113a369f940bc737fa7656c7a98f9d4d4c4b
4
+ data.tar.gz: fcadd8920cbabc6f9bc183782a65aa3fabbb902dd6e6bcd44ab31ee0bf7e42ef
5
5
  SHA512:
6
- metadata.gz: 44dfebac2c28da2dba9e4f8cf746088daa85b33729f46e00e5548ac252d09425904b182eef34980fe72e9b6b3c0289ba0d71dd4c7b2170f2bbc7924ef4ce26be
7
- data.tar.gz: affd58ce192d134c0c4918f114d5a2423b0aadde3e21be1ccbda039b96162e88f2ab54cb779914692ddbe54a18e060a144e19179efe45e4b8d342b26f9d7e597
6
+ metadata.gz: f758a4bf34e0f0970cab4051e1688883dbf52014cb75303ed91f5d95c387ac8631ee9643df41e07c7fcd75e50726d4be3fd90ac46b7c3ab24c1901f120827009
7
+ data.tar.gz: 6f32eb60a99eccb55f3da1881e314a31a5d53e838795482f4e2389afc9e8af1679e41f32eae97aced2c3f2121017b8cbf477a5e53637d2ea2a658b29bc87db91
@@ -0,0 +1,3 @@
1
+ class WorkerPlugins::ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -1,9 +1,9 @@
1
- class WorkerPlugins::Workplace < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
1
+ class WorkerPlugins::Workplace < WorkerPlugins::ApplicationRecord
2
2
  self.table_name = "worker_plugins_workplaces"
3
3
 
4
4
  has_many :workplace_links, dependent: :destroy
5
5
 
6
- belongs_to :user, polymorphic: true
6
+ belongs_to :user, polymorphic: WorkerPlugins::UserRelationshipPolymorphic.execute!
7
7
 
8
8
  validates :name, presence: true
9
9
 
@@ -25,7 +25,7 @@ class WorkerPlugins::Workplace < ActiveRecord::Base # rubocop:disable Rails/Appl
25
25
  workplace_links.group("worker_plugins_workplace_links.resource_type").order("worker_plugins_workplace_links.id").each do |workplace_link|
26
26
  resource_type = workplace_link.resource_type
27
27
  constant = Object.const_get(resource_type)
28
- ids = workplace_links.select(:resource_id).where(resource_type: workplace_link.resource_type).map(&:resource_id)
28
+ ids = workplace_links.where(resource_type: workplace_link.resource_type).pluck(:resource_id)
29
29
 
30
30
  ids.each_slice(500) do |ids_slice|
31
31
  query = constant.where(id: ids_slice)
@@ -1,4 +1,4 @@
1
- class WorkerPlugins::WorkplaceLink < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord
1
+ class WorkerPlugins::WorkplaceLink < WorkerPlugins::ApplicationRecord
2
2
  self.table_name = "worker_plugins_workplace_links"
3
3
 
4
4
  belongs_to :workplace
@@ -0,0 +1,10 @@
1
+ class WorkerPlugins::UserRelationshipPolymorphic
2
+ def self.execute!
3
+ WorkerPlugins::Workplace.columns_hash.key?("user_type")
4
+ rescue ActiveRecord::StatementInvalid => e
5
+ # Fall back to true if we are in the middle of a migration or something
6
+ return true if e.message.start_with?("Could not find table")
7
+
8
+ raise e
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module WorkerPlugins
2
- VERSION = "0.0.5".freeze
2
+ VERSION = "0.0.6".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worker_plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johanmsen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-09 00:00:00.000000000 Z
11
+ date: 2023-12-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rails framework for easily choosing and creating lists of objects and
14
14
  execute plugins against them.
@@ -21,6 +21,7 @@ files:
21
21
  - MIT-LICENSE
22
22
  - README.md
23
23
  - Rakefile
24
+ - app/models/worker_plugins/application_record.rb
24
25
  - app/models/worker_plugins/workplace.rb
25
26
  - app/models/worker_plugins/workplace_link.rb
26
27
  - app/services/worker_plugins/add_query.rb
@@ -29,6 +30,7 @@ files:
29
30
  - app/services/worker_plugins/remove_query.rb
30
31
  - app/services/worker_plugins/select_column_with_type_cast.rb
31
32
  - app/services/worker_plugins/switch_query.rb
33
+ - app/services/worker_plugins/user_relationship_polymorphic.rb
32
34
  - config/locales/awesome_translations/models/worker_plugins__workplace/da.yml
33
35
  - config/locales/awesome_translations/models/worker_plugins__workplace/en.yml
34
36
  - config/locales/awesome_translations/models/worker_plugins__workplace_link/da.yml
@@ -46,7 +48,7 @@ homepage: https://www.github.com/kaspernj/worker_plugins
46
48
  licenses: []
47
49
  metadata:
48
50
  rubygems_mfa_required: 'true'
49
- post_install_message:
51
+ post_install_message:
50
52
  rdoc_options: []
51
53
  require_paths:
52
54
  - lib
@@ -54,15 +56,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
56
  requirements:
55
57
  - - ">="
56
58
  - !ruby/object:Gem::Version
57
- version: 2.7.5
59
+ version: 2.7.8
58
60
  required_rubygems_version: !ruby/object:Gem::Requirement
59
61
  requirements:
60
62
  - - ">="
61
63
  - !ruby/object:Gem::Version
62
64
  version: '0'
63
65
  requirements: []
64
- rubygems_version: 3.1.6
65
- signing_key:
66
+ rubygems_version: 3.4.10
67
+ signing_key:
66
68
  specification_version: 4
67
69
  summary: Rails framework for easily choosing and creating lists of objects and execute
68
70
  plugins against them.