posts: fix rounding errors in ratio: metatag.
Fix the ratio: metatag sometimes including wrong results due to rounding errors. For example, searching for `ratio:>=4.0` would include post 3220414, which has an aspect ratio of 3.99879. This would get rounded up to 2 decimal places to 4.00.
This commit is contained in:
@@ -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, "ROUND(1.0 * posts.image_width / GREATEST(1, posts.image_height), 2)", :ratio)
|
||||
relation.attribute_matches(value, "posts.image_width::numeric / posts.image_height::numeric", :ratio)
|
||||
when "score"
|
||||
relation.attribute_matches(value, :score)
|
||||
when "upvotes"
|
||||
|
||||
Reference in New Issue
Block a user