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

Conversation

@markvanlan
Copy link
Contributor

In the last commit, I introduced a topic_custom_field to determine if a PM is indeed a bot PM.

This commit adds a migration to backfill any PM that is between 1 real user, and 1 bot. The correct topic_custom_field is added for these, so they will appear on the bot conversation sidebar properly.

We can also drop the joining to topic_users in the controller for sidebar conversations, and the isPostFromAiBot logic from the sidebar.

.joins(:topic_users)
.where(topic_users: { user_id: bot_user_ids })
.joins("INNER JOIN topic_custom_fields tcf ON tcf.topic_id = topics.id")
.where("tcf.name = ? AND tcf.value = 't'", DiscourseAi::AiBot::TOPIC_AI_BOT_PM_FIELD)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move the where conditions to the join?

@markvanlan markvanlan merged commit 298ebee into main Apr 24, 2025
6 checks passed
@markvanlan markvanlan deleted the migration-4-bpm branch April 24, 2025 18:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants