work on related tag js

This commit is contained in:
albert
2011-09-30 18:20:29 -04:00
parent 3748934648
commit af8a0aaa76
8 changed files with 141 additions and 2 deletions

View File

@@ -20,8 +20,16 @@ class RelatedTagQuery
wiki_page.try(:tags) || []
end
def to_json
{:query => query, :category => category, :tags => map_with_category_data(tags), :wiki_page_tags => map_with_category_data(wiki_page_tags)}.to_json
end
protected
def map_with_category_data(list_of_tag_names)
Tag.categories_for(list_of_tag_names).to_a
end
def pattern_matching_tags
Tag.name_matches(query).order("post_count desc").limit(50).sort_by {|x| x.name}.map(&:name)
end