Recent activity query WordPress

This needs to be 2 queries, one to get the posts most recently commented like:

$q = "SELECT wp_comments.comment_post_id, wp_posts.* FROM wp_comments LEFT JOIN wp_posts ON wp_comments.comment_post_id = wp_posts.ID ORDER by wp_comments.comment_date DESC";

And one to get the most 10 recent posts by add or edit:

$q = "SELECT * FROM wp_posts WHERE post_type="post" OR post_type="revision" ORDER BY post_date DESC";

But when you retrieve the posts from the latter you will need to check if it is a revision and if so get the parent post, and also depending on the reason for this check the status of the post or the parent post to make sure it is published (status of revisions will be inherit)