Non conosco affatto SQL… ma sarebbe possibile avere una query che mi mostri gli argomenti in cui sono stato menzionato ma a cui non ho risposto dopo la menzione (immagino che questa parte sia complicata, se non impossibile)?
argomenti in cui l’utente è stato menzionato ma non ha risposto dopo essere stato menzionato
-- [params]
-- user_id :user
WITH mentions AS (
SELECT target_topic_id, target_post_id, created_at
FROM user_actions
WHERE action_type = 7 -- menzioni
AND user_id = :user
), replies AS (
SELECT topic_id, MAX(created_at) created_at
FROM posts
WHERE user_id = :user
AND deleted_at IS NULL
AND post_type IN (1, 4) -- normale O sussurro
GROUP BY topic_id
)
SELECT DATE(m.created_at) menzionato_il, target_post_id post_id
FROM mentions m
LEFT JOIN replies r ON r.topic_id = m.target_topic_id
JOIN topics t ON t.id = m.target_topic_id
WHERE m.created_at > COALESCE(r.created_at, '1900-01-01')
AND t.deleted_at IS NULL
AND NOT t.archived
AND NOT t.closed
ORDER BY m.created_at DESC