posts: choose better images for opengraph previews.
When choosing the Open Graph image (the preview image shown when a Danbooru link is posted on Discord or social media), choose the safest image with the highest score, rather than the image with the highest favcount.
This commit is contained in:
@@ -129,8 +129,7 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def best_post
|
def best_post
|
||||||
# be smarter about this in the future
|
posts.reject(&:is_deleted).select(&:visible?).max_by { |post| [-post.rating_id, post.score] }
|
||||||
posts.reject(&:is_deleted).select(&:visible?).max_by(&:fav_count)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_bulk_update_requests
|
def pending_bulk_update_requests
|
||||||
|
|||||||
@@ -305,6 +305,11 @@ class Post < ApplicationRecord
|
|||||||
flags.join(" ")
|
flags.join(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# g => 0, s => 1, q => 2, e => 3
|
||||||
|
def rating_id
|
||||||
|
RATINGS.keys.index(rating)
|
||||||
|
end
|
||||||
|
|
||||||
def pretty_rating
|
def pretty_rating
|
||||||
RATINGS.fetch(rating)
|
RATINGS.fetch(rating)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user