Skip to content

Commit 93f8d5a

Browse files
author
Jason Kao
committed
uses SQL GROUP_BY clause to remove repeated articles from media JOIN
1 parent c20a03f commit 93f8d5a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

app/graphql/resolvers/get_top_ranked_articles.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def call(_obj, args, _ctx)
2727

2828
if args["has_media"]
2929
unless articles.joins(:media).length == 0
30-
articles = articles.joins(:media)
30+
# uses SQL GROUP_BY clause to remove repeated articles from media JOIN
31+
articles = articles.joins(:media).group('articles.id, sections.rank')
3132
end
3233
end
3334

0 commit comments

Comments
 (0)