* Initial setup work with error * Dropdown working with error fixed * Removed repition * Home page billboard dropdowns added * Created common file for dropdown * Complete display ad dropdown usage * Minor indentation fix * Minor UI updates * Minor test update * Dropdown for billboard optimisation * Added anchor tags * Display ad unified code * Design changes * Design changes * Changes to display ad click tracking * Style changes * Design change to admin display ad * Nit fix * Nit fix * Updated test
21 lines
841 B
Ruby
21 lines
841 B
Ruby
# @note When we destroy the related user, it's using dependent:
|
|
# :delete for the relationship. That means no before/after
|
|
# destroy callbacks will be called on this object.
|
|
class DisplayAdEvent < ApplicationRecord
|
|
belongs_to :display_ad
|
|
belongs_to :user, optional: true
|
|
|
|
CATEGORY_IMPRESSION = "impression".freeze
|
|
CATEGORY_CLICK = "click".freeze
|
|
VALID_CATEGORIES = [CATEGORY_CLICK, CATEGORY_IMPRESSION].freeze
|
|
|
|
CONTEXT_TYPE_HOME = "home".freeze
|
|
CONTEXT_TYPE_ARTICLE = "article".freeze
|
|
VALID_CONTEXT_TYPES = [CONTEXT_TYPE_HOME, CONTEXT_TYPE_ARTICLE].freeze
|
|
|
|
validates :category, inclusion: { in: VALID_CATEGORIES }
|
|
validates :context_type, inclusion: { in: VALID_CONTEXT_TYPES }
|
|
|
|
scope :impressions, -> { where(category: CATEGORY_IMPRESSION) }
|
|
scope :clicks, -> { where(category: CATEGORY_CLICK) }
|
|
end
|