mirror of
https://github.com/discourse/discourse-rewind.git
synced 2025-07-31 16:13:32 +00:00
24 lines
701 B
Ruby
24 lines
701 B
Ruby
# frozen_string_literal: true
|
|
|
|
module DiscourseRewind
|
|
module Action
|
|
class BestTopics < BaseReport
|
|
def call
|
|
best_topics =
|
|
TopTopic
|
|
.includes(:topic)
|
|
.references(:topic)
|
|
.where(topic: { deleted_at: nil, created_at: date, user_id: user.id })
|
|
.order("yearly_score DESC NULLS LAST")
|
|
.limit(3)
|
|
.pluck(:topic_id, :title, :excerpt, :yearly_score)
|
|
.map do |topic_id, title, excerpt, yearly_score|
|
|
{ topic_id: topic_id, title: title, excerpt: excerpt, yearly_score: yearly_score }
|
|
end
|
|
|
|
{ data: best_topics, identifier: "best-topics" }
|
|
end
|
|
end
|
|
end
|
|
end
|