discourse-ai/app/serializers/ai_sentiment_post_serializer.rb
Keegan George bab6f0be43
FIX: Ensure category badging present in sentiment reports (#1222)
This PR ensures that the category badges are present in the sentiment analysis report. Since the core change in https://github.com/discourse/discourse/pull/31795, there was a regression in the post list drill-down where category badges were not being shown. This PR fixes that and also ensures icons/emojis are shown when categories make use of them. This PR also adds the category badge in the table list.
2025-03-26 12:37:41 -07:00

29 lines
638 B
Ruby

# frozen_string_literal: true
class AiSentimentPostSerializer < ApplicationSerializer
attributes :post_id,
:topic_id,
:topic_title,
:post_number,
:username,
:name,
:avatar_template,
:excerpt,
:sentiment,
:truncated,
:category_id,
:created_at
def avatar_template
User.avatar_template(object.username, object.uploaded_avatar_id)
end
def excerpt
Post.excerpt(object.post_cooked)
end
def truncated
object.post_cooked.length > SiteSetting.post_excerpt_maxlength
end
end