From 0ed62231e7363e8f9cfa21a47244fac6b752dad4 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Sun, 19 Apr 2015 18:27:40 -0300 Subject: [PATCH] api: fix votes order --- lib/noosfero/api/v1/articles.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/noosfero/api/v1/articles.rb b/lib/noosfero/api/v1/articles.rb index 80f754d..80bc591 100644 --- a/lib/noosfero/api/v1/articles.rb +++ b/lib/noosfero/api/v1/articles.rb @@ -37,7 +37,7 @@ module Noosfero articles = articles.display_filter(current_person, nil) if votes_order - articles = articles.joins(:votes).group('articles.id').reorder('sum(votes.id) DESC') + articles = articles.joins('left join votes on articles.id=votes.voteable_id').group('articles.id').reorder('sum(coalesce(votes.vote, 0)) DESC') end present articles, :with => Entities::Article, :fields => params[:fields] -- libgit2 0.21.2