* Declare winner in update points worker * Remove tests * Test variants for which posts are fetched on home feed * Add field test * Rewrite field tests * Change user to @user * Fix tests * Fix user thing * Check for existence of user before setting experiment * Fix experiment -> @experiment * Change spec * Fix tests * Fix tests * Fix tests * Fix rubocop issues * Remove unneeded offset value * Fix up specs * Final adjustments * Add comments * Update app/services/articles/feeds/large_forem_experimental.rb Co-authored-by: Molly Struve <mollylbs@gmail.com> * Update app/services/articles/feeds/large_forem_experimental.rb Co-authored-by: Molly Struve <mollylbs@gmail.com> * Update app/services/articles/feeds/large_forem_experimental.rb Co-authored-by: Fernando Valverde <fdov88@gmail.com> * Update app/services/articles/feeds/large_forem_experimental.rb Co-authored-by: Fernando Valverde <fdov88@gmail.com> * Better initial user query Co-authored-by: Molly Struve <mollylbs@gmail.com> Co-authored-by: Fernando Valverde <fdov88@gmail.com>
36 lines
737 B
Ruby
36 lines
737 B
Ruby
class PageView < ApplicationRecord
|
|
belongs_to :user, optional: true
|
|
belongs_to :article
|
|
|
|
before_create :extract_domain_and_path
|
|
after_create_commit :record_field_test_event
|
|
|
|
private
|
|
|
|
def extract_domain_and_path
|
|
return unless referrer
|
|
|
|
parsed_url = Addressable::URI.parse(referrer)
|
|
self.domain = parsed_url.domain
|
|
self.path = parsed_url.path
|
|
end
|
|
|
|
def article_searchable_tags
|
|
article.cached_tag_list
|
|
end
|
|
|
|
def article_searchable_text
|
|
article.body_text[0..350]
|
|
end
|
|
|
|
def article_tags
|
|
article.decorate.cached_tag_list_array
|
|
end
|
|
|
|
def record_field_test_event
|
|
return unless user_id
|
|
|
|
Users::RecordFieldTestEventWorker
|
|
.perform_async(user_id, "user_creates_pageview")
|
|
end
|
|
end
|