15 lines
No EOL
545 B
Ruby
15 lines
No EOL
545 B
Ruby
class LocalTopPostsService < BaseService
|
|
# Rank local posts by engagement (boosts > favs > replies) in last 24h
|
|
def call
|
|
Status
|
|
.local
|
|
.joins(:status_stat)
|
|
.where('statuses.created_at > ?', 24.hours.ago)
|
|
.select('statuses.*,
|
|
(status_stats.reblogs_count * 0.6 +
|
|
status_stats.favourites_count * 0.3 +
|
|
status_stats.replies_count * 0.1) AS engagement_score')
|
|
.order('engagement_score DESC')
|
|
.limit(50) # Adjust as needed
|
|
end
|
|
end |