class ContactsSearch < Searchlight::Search
  search_on Contact.includes(:contact_memberships, :contact_groups)

  searches :title, :description, :name, :department_id, :contact_group_id

  def name
    (super || "").strip
  end

  def search_name
    search.where "title LIKE :name OR description LIKE :name", name: "%#{name}%"
  end

  def search_department_id
    search.where department_id: department_id
  end

  def search_contact_group_id
    search.where "`contact_memberships`.`contact_group_id` = ?", contact_group_id
  end
end

class ContactsSearch < Searchlight::Search
  search_on Contact.includes(:contact_memberships)

  searches :title, :description, :name, :department_id, :contact_group_id

  def name
    (super || "").strip
  end

  def search_name
    search.where "title LIKE :name OR description LIKE :name", name: "%#{name}%"
  end

  def search_department_id
    search.where department_id: department_id
  end

  def search_contact_group_id
    search.where "`contact_memberships`.`contact_group_id` = ?", contact_group_id
  end
end

Fix for 500 when using the Topic filter
Fix for 500 when using the Topic filter

If you were to use the Topic filter with a search term, it was 500ing from
an ambiguous column name in contact_search.rb, specifically in the include
of contact_groups, which wasn't needed for the search to function.
