Commit b9ac15748b4c059f7dcfc93eb53d27cae1e5d536
1 parent
d465f6e8
Exists in
production-vendorized
and in
1 other branch
Revert "api: accept order param in search endpoint"
This reverts commit d465f6e8d75dcb41d500180dcd2d8ee6caddedcb.
Showing
2 changed files
with
2 additions
and
14 deletions
Show diff stats
lib/noosfero/api/v1/search.rb
| ... | ... | @@ -19,14 +19,10 @@ module Noosfero |
| 19 | 19 | scope = scope.where(make_conditions_with_parameter(params)) |
| 20 | 20 | scope = scope.joins(:categories).where(:categories => {:id => params[:category_ids]}) if params[:category_ids].present? |
| 21 | 21 | scope = scope.where('articles.children_count > 0') if params[:has_children].present? |
| 22 | - | |
| 23 | - order = make_order_with_parameters(profile || environment, :articles, params) | |
| 24 | - scope = scope.reorder(order) | |
| 25 | - | |
| 26 | 22 | query = params[:query] || "" |
| 27 | - search_order = "more_recent" | |
| 23 | + order = "more_recent" | |
| 28 | 24 | |
| 29 | - options = {:filter => search_order, :template_id => params[:template_id]} | |
| 25 | + options = {:filter => order, :template_id => params[:template_id]} | |
| 30 | 26 | |
| 31 | 27 | paginate_options = params.select{|k,v| [:page, :per_page].include?(k.to_sym)}.symbolize_keys |
| 32 | 28 | paginate_options.each_pair{|k,v| v=v.to_i} | ... | ... |
test/unit/api/search_test.rb
| ... | ... | @@ -156,12 +156,4 @@ class SearchTest < ActiveSupport::TestCase |
| 156 | 156 | assert_equal [article2.id], json['articles'].map {|a| a['id']} |
| 157 | 157 | end |
| 158 | 158 | |
| 159 | - should 'list articles with order' do | |
| 160 | - article1 = fast_create(Article, :profile_id => person.id, created_at: Time.now - 1.day) | |
| 161 | - article2 = fast_create(Article, :profile_id => person.id, created_at: Time.now) | |
| 162 | - params = {order: 'created_at DESC'} | |
| 163 | - get "/api/v1/search/article?#{params.to_query}" | |
| 164 | - json = JSON.parse(last_response.body) | |
| 165 | - assert_equal [article2.id, article1.id], json['articles'].map {|a| a['id']} | |
| 166 | - end | |
| 167 | 159 | end | ... | ... |