2025-02-20 09:14:10 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AiSentimentPostSerializer < ApplicationSerializer
|
|
|
|
attributes :post_id,
|
|
|
|
:topic_id,
|
|
|
|
:topic_title,
|
|
|
|
:post_number,
|
|
|
|
:username,
|
|
|
|
:name,
|
|
|
|
:avatar_template,
|
|
|
|
:excerpt,
|
|
|
|
:sentiment,
|
2025-02-23 21:21:10 -08:00
|
|
|
:truncated,
|
2025-02-25 07:47:30 -08:00
|
|
|
:category,
|
|
|
|
:created_at
|
2025-02-20 09:14:10 -08:00
|
|
|
|
|
|
|
def avatar_template
|
|
|
|
User.avatar_template(object.username, object.uploaded_avatar_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def excerpt
|
|
|
|
Post.excerpt(object.post_cooked)
|
|
|
|
end
|
|
|
|
|
|
|
|
def truncated
|
2025-02-25 07:47:30 -08:00
|
|
|
object.post_cooked.length > SiteSetting.post_excerpt_maxlength
|
2025-02-20 09:14:10 -08:00
|
|
|
end
|
2025-02-23 21:21:10 -08:00
|
|
|
|
|
|
|
def category
|
|
|
|
{
|
|
|
|
id: object.category_id,
|
|
|
|
name: object.category_name,
|
|
|
|
color: object.category_color,
|
|
|
|
slug: object.category_slug,
|
|
|
|
description: object.category_description,
|
|
|
|
}
|
|
|
|
end
|
2025-02-20 09:14:10 -08:00
|
|
|
end
|