Commit a0577377a330ffe65af86b73641014a2954cad7f
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'api' into stable
Showing
1 changed file
with
7 additions
and
0 deletions
Show diff stats
lib/noosfero/api/v1/articles.rb
| ... | ... | @@ -40,8 +40,15 @@ module Noosfero |
| 40 | 40 | |
| 41 | 41 | get ':id/children' do |
| 42 | 42 | article = find_article(environment.articles, params[:id]) |
| 43 | + | |
| 44 | + votes_order = params.delete(:order) if params[:order]=='votes_score' | |
| 43 | 45 | articles = select_filtered_collection_of(article, 'children', params) |
| 44 | 46 | articles = articles.display_filter(current_person, nil) |
| 47 | + | |
| 48 | + if votes_order | |
| 49 | + articles = articles.joins('left join votes on articles.id=votes.voteable_id').group('articles.id').order('sum(votes.id) DESC') | |
| 50 | + end | |
| 51 | + | |
| 45 | 52 | present articles, :with => Entities::Article, :fields => params[:fields] |
| 46 | 53 | end |
| 47 | 54 | ... | ... |