content_signals 0.1.11 → 0.1.15

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: 79d109a0ff6e808dd29af442535c5041b0870b82057c9b9bad365c995d1267b2
4
- data.tar.gz: 130730c5ad2c79beec04216b1d939cd359945e3af5c6c389e55f37c87b0d9ec7
3
+ metadata.gz: e2c1d01c7f6f684b573250d04429a365fa3ab703cb8dddac8ddac0a7131580b8
4
+ data.tar.gz: bb343e43a050d8007817062d8de52f64f3ed54ee51d459b1a4988689e420083d
5
5
  SHA512:
6
- metadata.gz: fd2c5897912d51787f2a2f9b4cc025d15a29782253e05bb12f1d5f35376e1392a786b4caf81563752d4f6ac05a309b28788673f6d10da88df94df411ffacde61
7
- data.tar.gz: 87a2efb0694d43192fefef083f8e12fe815a54859a463833213c1d091b00ca1b7b2584d2576d0dae907ca384ec8785639f6a59d17182bcf749757f6dadb50758
6
+ metadata.gz: 4ca85cd8372d706ff93c3c9faa11ecf2920eff399fd7fa276f7f6cd09d7e81b569a8977cb1998189c43790c510500b8530f00a88a2d9860819909bc656eaa85e
7
+ data.tar.gz: 86dd62f5920ddc4565f4a619ba34ff9c57ef130e12f3a08af719fa11e6895bb28cd869d3278f338f3ef7004e231122b97cf9f1fe399f0d737d771cea3bff21c2
@@ -6,33 +6,21 @@ module ContentSignals
6
6
 
7
7
  # Associations
8
8
  belongs_to :trackable, polymorphic: true, counter_cache: :page_views_count
9
- belongs_to :tenant, optional: true if ContentSignals.configuration.multitenancy?
10
9
  belongs_to :user, optional: true
11
10
 
11
+ # tenant_id is a plain string (UUID), not a foreign key — declare explicitly
12
+ # Guard allows db:migrate to run on a fresh DB before the table exists
13
+ attribute :tenant_id, :string if connection.table_exists?(table_name) rescue nil
14
+
12
15
  # Validations
13
16
  validates :trackable_type, :trackable_id, :visitor_id, :viewed_at, presence: true
14
17
  validates :country_code, length: { maximum: 2 }, allow_nil: true
15
18
  validates :device_type, inclusion: { in: %w[desktop mobile tablet] }, allow_nil: true
16
19
  validates :app_platform, inclusion: { in: %w[hybrid native] }, allow_nil: true
17
20
 
18
- # Default scope for tenant isolation (when multitenancy is enabled)
19
- if ContentSignals.configuration.multitenancy?
20
- default_scope -> { where(tenant_id: current_tenant_id) }
21
-
22
- def self.current_tenant_id
23
- return nil unless ContentSignals.configuration.multitenancy?
24
-
25
- method_name = ContentSignals.configuration.current_tenant_method
26
- return nil unless method_name
27
-
28
- # Try to get tenant_id from Current, controller, or thread
29
- if defined?(Current) && Current.respond_to?(method_name)
30
- Current.send(method_name)
31
- elsif Thread.current[method_name]
32
- Thread.current[method_name]
33
- end
34
- end
35
- end
21
+ # Tenant filtering use explicitly instead of default_scope to avoid
22
+ # silent NULL filtering in background jobs, console, and migrations.
23
+ scope :for_tenant, ->(id) { where(tenant_id: id) }
36
24
 
37
25
  # Time period scopes
38
26
  scope :today, -> { where("viewed_at >= ?", Time.current.beginning_of_day) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContentSignals
4
- VERSION = "0.1.11"
4
+ VERSION = "0.1.15"
5
5
  end
@@ -1,8 +1,8 @@
1
1
  class CreateContentSignalsPageViews < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  create_table :content_signals_page_views do |t|
4
- # Multi-tenancy support (optional)
5
- t.integer :tenant_id, index: true
4
+ # Multi-tenancy support (optional, string to support both UUID and integer tenant IDs)
5
+ t.string :tenant_id, index: true
6
6
 
7
7
  # Polymorphic trackable (Page, Profile, Event, etc.)
8
8
  t.string :trackable_type, null: false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: content_signals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ionuț Munteanu Alexandru