Class: Subscription
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Subscription
- Includes:
- CommunityRelated
- Defined in:
- app/models/subscription.rb
Instance Method Summary collapse
Methods inherited from ApplicationRecord
#attributes_print, fuzzy_search, match_search, #match_search, sanitize_for_search, sanitize_name, sanitize_sql_in, useful_err_msg, with_lax_group_rules
Instance Method Details
#questions ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/subscription.rb', line 13 def questions case type when 'all' Question.unscoped.where(community: community, post_type_id: Question.post_type_id) .where(Question.arel_table[:created_at].gteq(last_sent_at || created_at)) when 'tag' Question.unscoped.where(community: community, post_type_id: Question.post_type_id) .where(Question.arel_table[:created_at].gteq(last_sent_at || created_at)) .joins(:tags).where(tags: { name: qualifier }) when 'user' Question.unscoped.where(community: community, post_type_id: Question.post_type_id) .where(Question.arel_table[:created_at].gteq(last_sent_at || created_at)) .where(user_id: qualifier) when 'interesting' RequestContext.community = community # otherwise SiteSetting#[] doesn't work Question.unscoped.where(community: community, post_type_id: Question.post_type_id) .where('score >= ?', SiteSetting['InterestingSubscriptionScoreThreshold']) .order(Arel.sql('RAND()')) when 'category' Question.unscoped.where(community: community, post_type_id: Question.post_type_id) .where(Question.arel_table[:created_at].gteq(last_sent_at || created_at)) .where(category_id: qualifier) end&.order(created_at: :desc)&.limit(25) end |