Class: Blogger
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Blogger
- Extended by:
- FriendlyId
- Includes:
- IdentityCache
- Defined in:
- app/models/blogger.rb
Overview
typed: ignore Blogger or Partner model
Class Method Summary collapse
-
.valid_channel_for_me(blogger) ⇒ Object
Used by simple form to display blogger's channel association.
-
.valid_utm_names ⇒ Object
if the UTM value is same with one of following names then we will track it as blogger referral.
Instance Method Summary collapse
Methods inherited from ApplicationRecord
Class Method Details
.valid_channel_for_me(blogger) ⇒ Object
Used by simple form to display blogger's channel association
30 31 32 33 34 35 36 37 38 |
# File 'app/models/blogger.rb', line 30 def self.valid_channel_for_me(blogger) selected_channels = Blogger.pluck(:channel_id) channel_id = Channel.arel_table[:channel_id] if blogger.new_record? Channel.where(channel_id.not_in(selected_channels)) else Channel.where(channel_id.not_in(selected_channels.reject { |c_id| c_id == blogger.channel_id })) end end |
.valid_utm_names ⇒ Object
if the UTM value is same with one of following names then we will track it as blogger referral
42 43 44 45 46 47 48 |
# File 'app/models/blogger.rb', line 42 def self.valid_utm_names Rails.cache.fetch("blogger:valid_utm_names:#{Blogger.maximum(:updated_at)}", expires_in: CACHEFLOW.generate_expiry) do Channel.where(channel_id: Blogger.pluck(:channel_id)). pluck(:uri_name).reject(&:blank?).map(&:to_s).map(&:downcase) end end |
Instance Method Details
#to_param ⇒ Object
25 26 27 |
# File 'app/models/blogger.rb', line 25 def to_param id end |