From 4db0c3c0e50e08b85e5385562c16d12fd12e36f7 Mon Sep 17 00:00:00 2001 From: Toks Date: Wed, 24 Sep 2014 13:11:54 -0400 Subject: [PATCH] fixes #2249 --- app/logical/post_query_builder.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index b0ebb1ff1..422ed41c9 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -370,11 +370,13 @@ class PostQueryBuilder relation = relation.order("artist_commentaries.updated_at ASC, posts.id DESC") when "mpixels", "mpixels_desc" + relation = relation.where("posts.image_width is not null and posts.image_height is not null") # Use "w*h/1000000", even though "w*h" would give the same result, so this can use # the posts_mpixels index. relation = relation.order("posts.image_width * posts.image_height / 1000000.0 DESC, posts.id DESC") when "mpixels_asc" + relation = relation.where("posts.image_width is not null and posts.image_height is not null") relation = relation.order("posts.image_width * posts.image_height / 1000000.0 ASC, posts.id DESC") when "portrait"