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
|
||||
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).
|
||||
joins(:tags).where(:tags => {:name => tag_array})
|
||||
joins(:tags).where(:tags => {:id => tag_ids})
|
||||
end
|
||||
|
||||
def text(opts = {})
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Stream::FollowedTag < Stream::Base
|
|||
# @return [ActiveRecord::Association<Post>] AR association of posts
|
||||
def posts
|
||||
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
|
||||
|
||||
def contacts_title
|
||||
|
|
@ -28,8 +28,8 @@ class Stream::FollowedTag < Stream::Base
|
|||
@tag_string ||= tags.join(', '){|tag| tag.name}.to_s
|
||||
end
|
||||
|
||||
def tag_array
|
||||
tags.map{|x| x.name}
|
||||
def tag_ids
|
||||
tags.map{|x| x.id}
|
||||
end
|
||||
|
||||
def tags
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class Stream::Multi < Stream::Base
|
|||
end
|
||||
|
||||
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
|
||||
|
||||
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}
|
||||
end
|
||||
|
||||
def tag_array
|
||||
user.followed_tags.select('name').map{|x| x.name}
|
||||
def tag_ids
|
||||
user.followed_tags.map{|x| x.id}
|
||||
end
|
||||
|
||||
def ids(enumerable)
|
||||
|
|
|
|||
Loading…
Reference in a new issue