Commit 3a07ccbb0b0237d0efef7cafea5706b17bba1fe3
1 parent
8d9a57db
Exists in
theme-brasil-digital-from-staging
and in
3 other branches
Remove file added by mistake
Showing
1 changed file
with
0 additions
and
50 deletions
Show diff stats
lib/noosfero/api/v1/search.rb.orig
| ... | ... | @@ -1,50 +0,0 @@ |
| 1 | -module Noosfero | |
| 2 | - module API | |
| 3 | - module V1 | |
| 4 | - class Search < Grape::API | |
| 5 | - | |
| 6 | - resource :search do | |
| 7 | - resource :article do | |
| 8 | - paginate per_page: 20, max_per_page: 200 | |
| 9 | - get do | |
| 10 | - # Security checks | |
| 11 | - sanitize_params_hash(params) | |
| 12 | - # APIHelpers | |
| 13 | - asset = :articles | |
| 14 | - context = environment | |
| 15 | - | |
| 16 | - profile = environment.profiles.find(params[:profile_id]) if params[:profile_id] | |
| 17 | - scope = profile.nil? ? environment.articles.is_public : profile.articles.is_public | |
| 18 | - scope = scope.where(:type => params[:type]) if params[:type] && !(params[:type] == 'Article') | |
| 19 | - scope = scope.where(:parent_id => params[:parent_id]) if params[:parent_id].present? | |
| 20 | - scope = scope.joins(:categories).where(:categories => {:id => params[:category_ids]}) if params[:category_ids].present? | |
| 21 | -<<<<<<< HEAD | |
| 22 | - | |
| 23 | - scope = scope.where('children_count > 0') if params[:has_children].present? | |
| 24 | - | |
| 25 | -======= | |
| 26 | ->>>>>>> staging | |
| 27 | - query = params[:query] || "" | |
| 28 | - order = "more_recent" | |
| 29 | - | |
| 30 | - options = {:filter => order, :template_id => params[:template_id]} | |
| 31 | - | |
| 32 | - paginate_options = params.select{|k,v| [:page, :per_page].include?(k.to_sym)}.symbolize_keys | |
| 33 | - paginate_options.each_pair{|k,v| v=v.to_i} | |
| 34 | - paginate_options[:page]=1 if !paginate_options.keys.include?(:page) | |
| 35 | - | |
| 36 | - search_result = find_by_contents(asset, context, scope, query, paginate_options, options) | |
| 37 | - | |
| 38 | - articles = search_result[:results] | |
| 39 | - | |
| 40 | - result = present_articles_paginated(articles) | |
| 41 | - | |
| 42 | - result | |
| 43 | - end | |
| 44 | - end | |
| 45 | - end | |
| 46 | - | |
| 47 | - end | |
| 48 | - end | |
| 49 | - end | |
| 50 | -end |