포럼에 Data Explorer 플러그인이 설치되어 있다면, SQL 쿼리를 작성하여 Discourse 데이터베이스에서 이 정보를 가져올 수 있습니다. 이 쿼리는 토픽의 ID와 제목, 그리고 해당 토픽의 마지막 게시물 작성자의 사용자 ID를 가져오도록 시도합니다. 마지막 게시물이 ‘clients’ 그룹에 속한 사용자가 작성한 토픽만 선택합니다.
이것은 예시일 뿐입니다.
SELECT
t.id AS topic_id,
t.title AS topic_title,
(SELECT user_id FROM posts WHERE topic_id = t.id ORDER BY created_at DESC LIMIT 1) AS last_post_user_id
FROM
topics t
JOIN
posts p ON p.topic_id = t.id
JOIN
group_users gu ON gu.user_id = p.user_id
JOIN
groups g ON g.id = gu.group_id
WHERE
g.name = 'clients'
GROUP BY
t.id
HAVING
MAX(p.user_id) = last_post_user_id
ORDER BY
MAX(p.created_at) DESC