From d346adabc9567327055a6db0954ecb803c0f6132 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 22 May 2022 12:33:37 -0500 Subject: [PATCH] Revert "posts: fix rounding errors in ratio: metatag." This reverts commit 80ced3e41857c6339d119543ee0b6f1cd66e742c. This turned out to be intentional. Rounding the aspect ratio to 2 decimal places is so that searches for exact ratios like `ratio:16:9` or `ratio:1.78` work even when the ratio doesn't exactly match. Rounding to 2 decimal places means that the ratio: metatag has a 1% error tolerance. --- app/logical/post_query_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index ccfd0530a..de602fd96 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -98,7 +98,7 @@ class PostQueryBuilder when "mpixels" relation.attribute_matches(value, "posts.image_width * posts.image_height / 1000000.0", :float) when "ratio" - relation.attribute_matches(value, "posts.image_width::numeric / posts.image_height::numeric", :ratio) + relation.attribute_matches(value, "ROUND(1.0 * posts.image_width / GREATEST(1, posts.image_height), 2)", :ratio) when "score" relation.attribute_matches(value, :score) when "upvotes"