Skip to content

Commit

Permalink
removed junk comments from related.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyodor committed Apr 24, 2013
1 parent 4fe2952 commit 853b308
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/acts_as_taggable_on/acts_as_taggable_on/related.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,24 @@ def acts_as_taggable_on(*args)

module InstanceMethods
def matching_contexts_for(search_context, result_context, klass, options = {})
# TODO consider options for scopes
tags_to_find = tags_on(search_context).collect { |t| t.name }

klass.select("#{klass.table_name}.*, COUNT(#{ActsAsTaggableOn::Tag.table_name}.#{ActsAsTaggableOn::Tag.primary_key}) AS count") \
.from("#{klass.table_name}, #{ActsAsTaggableOn::Tag.table_name}, #{ActsAsTaggableOn::Tagging.table_name}") \
.where(["#{exclude_self(klass, id)} #{klass.table_name}.#{klass.primary_key} = #{ActsAsTaggableOn::Tagging.table_name}.taggable_id AND #{ActsAsTaggableOn::Tagging.table_name}.taggable_type = '#{klass.base_class.to_s}' AND #{ActsAsTaggableOn::Tagging.table_name}.tag_id = #{ActsAsTaggableOn::Tag.table_name}.#{ActsAsTaggableOn::Tag.primary_key} AND #{ActsAsTaggableOn::Tag.table_name}.name IN (?) AND #{ActsAsTaggableOn::Tagging.table_name}.context = ?", tags_to_find, result_context]) \
.group(group_columns(klass)) \
.order("count DESC")
#.update(options)
end

def related_tags_for(context, klass, options = {})
# TODO consider options for scopes
tags_to_ignore = Array.wrap(options.delete(:ignore)).map(&:to_s) || []
tags_to_find = tags_on(context).collect { |t| t.name }.reject { |t| tags_to_ignore.include? t }

klass.select("#{klass.table_name}.*, COUNT(#{ActsAsTaggableOn::Tag.table_name}.#{ActsAsTaggableOn::Tag.primary_key}) AS count") \
.from("#{klass.table_name}, #{ActsAsTaggableOn::Tag.table_name}, #{ActsAsTaggableOn::Tagging.table_name}") \
.where(["#{exclude_self(klass, id)} #{klass.table_name}.#{klass.primary_key} = #{ActsAsTaggableOn::Tagging.table_name}.taggable_id AND #{ActsAsTaggableOn::Tagging.table_name}.taggable_type = '#{klass.base_class.to_s}' AND #{ActsAsTaggableOn::Tagging.table_name}.tag_id = #{ActsAsTaggableOn::Tag.table_name}.#{ActsAsTaggableOn::Tag.primary_key} AND #{ActsAsTaggableOn::Tag.table_name}.name IN (?)", tags_to_find]) \
.group(group_columns(klass)) \
.order("count DESC")#.update(options)
.order("count DESC")
end

private
Expand Down

0 comments on commit 853b308

Please sign in to comment.