Select max from a subquery of two things (#16177)
* Select max from a subquery of two things max(int, int) not a function, says postgres, once it stopped yelling about parenthesis balancing. * prefer greatest to select max from subquery
This commit is contained in:
parent
06f6573436
commit
394d33e134
1 changed files with 1 additions and 1 deletions
|
|
@ -462,7 +462,7 @@ module Articles
|
|||
when "final_order_by_random_weighted_to_last_comment_at"
|
||||
# rubocop:disable Layout/LineLength
|
||||
articles
|
||||
.order(Arel.sql("RANDOM() ^ (1.0 / (max(1, (extract(epoch from now() - articles.last_comment_at)::integer)) ASC"))
|
||||
.order(Arel.sql("RANDOM() ^ (1.0 / greatest( 1, (extract(epoch from now() - articles.last_comment_at)::integer))) ASC"))
|
||||
# rubocop:enable Layout/LineLength
|
||||
else # original
|
||||
articles
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue