dk iz querying by id in status message tag_stream
This commit is contained in:
parent
f9a9654c86
commit
ce199e770d
3 changed files with 8 additions and 8 deletions
|
|
@ -35,9 +35,9 @@ class StatusMessage < Post
|
||||||
#scopes
|
#scopes
|
||||||
scope :where_person_is_mentioned, lambda{|person| joins(:mentions).where(:mentions => {:person_id => person.id})}
|
scope :where_person_is_mentioned, lambda{|person| joins(:mentions).where(:mentions => {:person_id => person.id})}
|
||||||
|
|
||||||
def self.tag_stream(user, tag_array, max_time, order)
|
def self.tag_stream(user, tag_ids, max_time, order)
|
||||||
owned_or_visible_by_user(user).
|
owned_or_visible_by_user(user).
|
||||||
joins(:tags).where(:tags => {:name => tag_array})
|
joins(:tags).where(:tags => {:id => tag_ids})
|
||||||
end
|
end
|
||||||
|
|
||||||
def text(opts = {})
|
def text(opts = {})
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class Stream::FollowedTag < Stream::Base
|
||||||
# @return [ActiveRecord::Association<Post>] AR association of posts
|
# @return [ActiveRecord::Association<Post>] AR association of posts
|
||||||
def posts
|
def posts
|
||||||
return [] if tag_string.empty?
|
return [] if tag_string.empty?
|
||||||
@posts ||= StatusMessage.tag_stream(user, tag_array, max_time, order)
|
@posts ||= StatusMessage.tag_stream(user, tag_ids, max_time, order)
|
||||||
end
|
end
|
||||||
|
|
||||||
def contacts_title
|
def contacts_title
|
||||||
|
|
@ -28,8 +28,8 @@ class Stream::FollowedTag < Stream::Base
|
||||||
@tag_string ||= tags.join(', '){|tag| tag.name}.to_s
|
@tag_string ||= tags.join(', '){|tag| tag.name}.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_array
|
def tag_ids
|
||||||
tags.map{|x| x.name}
|
tags.map{|x| x.id}
|
||||||
end
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ class Stream::Multi < Stream::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def followed_tags_post_ids
|
def followed_tags_post_ids
|
||||||
@followed_tags_ids ||= ids(StatusMessage.tag_stream(user, tag_array, max_time, order))
|
@followed_tags_ids ||= ids(StatusMessage.tag_stream(user, tag_ids, max_time, order))
|
||||||
end
|
end
|
||||||
|
|
||||||
def mentioned_post_ids
|
def mentioned_post_ids
|
||||||
|
|
@ -110,8 +110,8 @@ class Stream::Multi < Stream::Base
|
||||||
@community_spotlight_person_ids ||= Person.community_spotlight.select('id').map{|x| x.id}
|
@community_spotlight_person_ids ||= Person.community_spotlight.select('id').map{|x| x.id}
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_array
|
def tag_ids
|
||||||
user.followed_tags.select('name').map{|x| x.name}
|
user.followed_tags.map{|x| x.id}
|
||||||
end
|
end
|
||||||
|
|
||||||
def ids(enumerable)
|
def ids(enumerable)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue