كيف يمكنني استخدام إضافة مستكشف البيانات لمعرفة ما إذا كان المستخدمون قد قرأوا أو تفاعلوا مع مواضيع وفئات معينة؟
لقد حاولت البحث في المنتدى لكن لم أجد أي نتائج حتى الآن.
أحتاج أيضًا إلى تضمين بريد المستخدم الإلكتروني واسمه الأول والأخير في المخرجات.
For Topic Participants you could use something like this
-- [params]
-- null string_list :topic_id
WITH user_data AS (
SELECT u.username, ue.email, tu.topic_id FROM users u
LEFT JOIN topic_users tu ON u.id = tu.user_id AND tu.posted = true
LEFT JOIN user_emails ue on u.id = ue.user_id
)
SELECT * FROM user_data WHERE topic_id = :topic_id
You would then just need to enter the relevant topic id in the box that is required.
I specifically linked to one there. It looks pretty close to what you are asking for. Can you run it and tell us what more info you need and we can likely edit it.
I dont understand why user is a number, where I should specify the topic id,
and also when I run the query nothing shows up? (probably because I dont know how to use it)
Thank you, this one is going to be pretty useful for me in the future when my forum is bigger.
Does this also include people who have liked the posts in the topic, or only those who replied?
If it does not include likers, how can we add them?
You can get more data from that query by selecting for more fields from the topic_users table. To find whether the user liked a post, or posted in the topic, try this:
-- [params]
-- null string_list :topic_id
WITH user_data AS (
SELECT u.username, ue.email, tu.topic_id, tu.posted, tu.liked FROM users u
LEFT JOIN topic_users tu ON u.id = tu.user_id AND tu.posted = true
LEFT JOIN user_emails ue on u.id = ue.user_id
)
SELECT * FROM user_data WHERE topic_id = :topic_id
That’s right. You can alter the query so that it doesn’t only select users who have posted by removing this part:
AND tu.posted = true
Try this:
-- [params]
-- int :topic_id
WITH user_data AS (
SELECT u.username,
ue.email,
tu.topic_id,
tu.posted,
tu.liked
FROM users u
JOIN topic_users tu ON u.id = tu.user_id
JOIN user_emails ue on u.id = ue.user_id
ORDER BY tu.last_visited_at DESC
)
SELECT * FROM user_data WHERE topic_id = :topic_id
Thank you so much brother you just sent me exactly what I needed. Not only does it scrape users who liked and commented, but it also shows me who viewed it!!