worker_plugins 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e84dd175df29b54e897c3419a3651eaad8720a7448d6b6ae1213e04512257814
4
- data.tar.gz: ab7a00dbe5b64bad121b082dab5e21f577070ef64c65cf8e5bc612d348b98f64
3
+ metadata.gz: a100e9889c3079f041cc886244ec356192af2f4463be274981149d7343b60883
4
+ data.tar.gz: 38f45e3ec7bfd644156db849907c723bd138595bc5ee8c97de60953a908df0c4
5
5
  SHA512:
6
- metadata.gz: 34f102da30a84f0372d49a97f523587674e1aac79cc7f439e0c9214edcdc52751613d9844efa75baa60e3c2b4c4cc252e219a9a61ad8da56d1204744a2d96e55
7
- data.tar.gz: a3f2d50025aa0ea2b4672d222a11c6068f960fe3481c5a3ce5cdbe012817ea34071f67f6626134a6ff1a17f16c228d55bc2d15a0051f968d6ab61006ea9c4388
6
+ metadata.gz: e5ccaad363855757ddbb62704900ed90ca0c33d5217633f82423b1d6f6c34ce2ae93a5ca302b38751c628121a2afe2aafa82fccb2be568930df806b40a4c4f47
7
+ data.tar.gz: 425085627b54a01e29865258303a836dba930f81af0f564157e4d08c83e76ec2c122bf6b3973fd08f06ee57b50ddd64c56c006c72adaab19dd3da7f5e7d51afa
@@ -3,9 +3,10 @@ class WorkerPlugins::Workplace < WorkerPlugins::ApplicationRecord
3
3
 
4
4
  has_many :workplace_links, dependent: :destroy
5
5
 
6
- belongs_to :user, polymorphic: WorkerPlugins::UserRelationshipPolymorphic.execute!
6
+ belongs_to :user, polymorphic: WorkerPlugins::UserRelationshipPolymorphic.execute!, optional: true
7
7
 
8
8
  validates :name, presence: true
9
+ validate :validate_owner
9
10
 
10
11
  def each_resource(limit: nil, types: nil)
11
12
  count = 0
@@ -59,4 +60,12 @@ private
59
60
 
60
61
  inserted_ids
61
62
  end
63
+
64
+ def validate_owner
65
+ if user.present? && session_id.present?
66
+ errors.add(:base, "Workplace can't belong to both a user and a session")
67
+ elsif user.blank? && session_id.blank?
68
+ errors.add(:base, "Workplace must belong to a user or a session")
69
+ end
70
+ end
62
71
  end
@@ -4,14 +4,12 @@ class WorkerPlugins::SelectColumnWithTypeCast < WorkerPlugins::ApplicationServic
4
4
  def perform
5
5
  return succeed! query.select(column_name_to_select) if same_type?
6
6
 
7
- if column_to_compare_with.type == :string
8
- succeed! query_with_varchar
9
- elsif column_to_compare_with.type == :integer
7
+ if column_to_compare_with.type == :integer
10
8
  succeed! query_with_integer
9
+ elsif column_to_compare_with.type == :uuid
10
+ succeed! query_with_uuid
11
11
  else
12
- raise "Cant handle type cast between types: " \
13
- "#{model_class.table_name}.#{column_name_to_select} (#{column_to_select.type}) " \
14
- "#{column_to_compare_with.name} (#{column_to_compare_with.type})"
12
+ succeed! query_with_varchar
15
13
  end
16
14
  end
17
15
 
@@ -31,6 +29,10 @@ class WorkerPlugins::SelectColumnWithTypeCast < WorkerPlugins::ApplicationServic
31
29
  query.select("CAST(#{model_class.table_name}.#{column_name_to_select} AS VARCHAR)")
32
30
  end
33
31
 
32
+ def query_with_uuid
33
+ query.select("CAST(#{model_class.table_name}.#{column_name_to_select} AS UUID)")
34
+ end
35
+
34
36
  def same_type?
35
37
  column_to_select.type == column_to_compare_with.type
36
38
  end
@@ -2,7 +2,7 @@ class WorkerPlugins::SwitchQuery < WorkerPlugins::ApplicationService
2
2
  arguments :query, :workplace
3
3
 
4
4
  def perform
5
- if resources_to_add.count.zero?
5
+ if resources_to_add.none?
6
6
  result = WorkerPlugins::RemoveQuery.execute!(query:, workplace:)
7
7
  succeed!(
8
8
  destroyed: result.fetch(:destroyed),
@@ -0,0 +1,9 @@
1
+ class AddSessionIdToWorkerPluginsWorkplaces < ActiveRecord::Migration[5.2]
2
+ def change
3
+ change_table :worker_plugins_workplaces, bulk: true do |t|
4
+ t.string :session_id
5
+ end
6
+
7
+ add_index :worker_plugins_workplaces, :session_id, unique: true
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module WorkerPlugins
2
- VERSION = "0.0.8".freeze
2
+ VERSION = "0.0.10".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.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Stöckel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-10 00:00:00.000000000 Z
11
+ date: 2026-03-23 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.
@@ -40,6 +40,7 @@ files:
40
40
  - db/migrate/20150521114659_create_worker_plugins_workplace_links.rb
41
41
  - db/migrate/20200702072306_change_workplace_links_resource_id_to_string_to_support_uuids.rb
42
42
  - db/migrate/20210106190349_change_resource_id_to_string_to_support_uuid.rb
43
+ - db/migrate/20260322194625_add_session_id_to_worker_plugins_workplaces.rb
43
44
  - lib/tasks/worker_plugins_tasks.rake
44
45
  - lib/worker_plugins.rb
45
46
  - lib/worker_plugins/engine.rb