List of Solved stats per-user

To produce a list with stats per-user, with a variable for time interval (defaults to 1 year):

-- [params]
-- string :interval = 1 year

SELECT  
    ua.acting_user_id, 
    COUNT(CASE t.user_id WHEN ua.acting_user_id THEN 1 ELSE NULL END) as is_op, 
    COUNT(CASE t.user_id WHEN ua.acting_user_id THEN NULL ELSE 1 END) as not_op,
    COUNT(*) as total
FROM user_actions ua
LEFT JOIN topics t ON target_topic_id = t.id
WHERE action_type=15
AND ua.created_at >= CURRENT_DATE - INTERVAL :interval
GROUP BY ua.acting_user_id
ORDER BY total DESC