Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 988479b

Browse files
committed
format topic status
1 parent 7d5dc29 commit 988479b

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/utils/research/llm_formatter.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,27 @@ def format_topic_header(topic)
139139

140140
# Add creation date
141141
header << "Created: #{format_date(topic.created_at)}\n"
142-
header << "Topic url: /t/#{topic.id}\n\n"
142+
header << "Topic url: /t/#{topic.id}\n"
143+
header << "Status: #{format_topic_status(topic)}\n\n"
143144

144145
header
145146
end
146147

148+
def format_topic_status(topic)
149+
solved = topic.respond_to?(:solved) && topic.solved.present?
150+
solved_text = solved ? " (solved)" : ""
151+
if topic.archived?
152+
"Archived#{solved_text}"
153+
elsif topic.closed?
154+
"Closed#{solved_text}"
155+
else
156+
"Open#{solved_text}"
157+
end
158+
end
159+
147160
def format_post(post)
148161
text = +"---\n"
149-
text << "## Post by #{post.user.username} - #{format_date(post.created_at)}\n\n"
162+
text << "## Post by #{post.user&.username} - #{format_date(post.created_at)}\n\n"
150163
text << "#{post.raw}\n"
151164
text << "Likes: #{post.like_count}\n" if post.like_count.to_i > 0
152165
text << "Post url: /t/-/#{post.topic_id}/#{post.post_number}\n\n"

0 commit comments

Comments
 (0)