1
0
Fork 0
forked from gitea/nas
nas/app/services/local_top_posts_service.rb
2025-06-12 20:00:16 -04:00

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