Created
January 25, 2025 04:28
-
-
Save rahul1990gupta/00ed9e0d26ef8fb6ddfe8de21f707d25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT `read_ribbons`.`user_id` AS `user_id`, | |
`comments`.`id` AS `comment_id`, | |
`read_ribbons`.`story_id` AS `story_id`, | |
`comments`.`parent_comment_id` AS | |
`parent_comment_id`, | |
`comments`.`created_at` AS | |
`comment_created_at`, | |
`parent_comments`.`user_id` AS | |
`parent_comment_author_id`, | |
`comments`.`user_id` AS | |
`comment_author_id`, | |
`stories`.`user_id` AS | |
`story_author_id`, | |
`read_ribbons`.`updated_at` < `comments`.`created_at` AS `is_unread`, | |
(SELECT `votes`.`vote` | |
FROM `votes` | |
WHERE `votes`.`user_id` = `read_ribbons`.`user_id` | |
AND `votes`.`comment_id` = `comments`.`id`) AS | |
`current_vote_vote`, | |
(SELECT `votes`.`reason` | |
FROM `votes` | |
WHERE `votes`.`user_id` = `read_ribbons`.`user_id` | |
AND `votes`.`comment_id` = `comments`.`id`) AS | |
`current_vote_reason` | |
FROM (((`read_ribbons` | |
JOIN `comments` | |
ON( `comments`.`story_id` = `read_ribbons`.`story_id` )) | |
JOIN `stories` | |
ON( `stories`.`id` = `comments`.`story_id` )) | |
LEFT JOIN `comments` `parent_comments` | |
ON( `parent_comments`.`id` = `comments`.`parent_comment_id` )) | |
WHERE `read_ribbons`.`is_following` = 1 | |
AND `comments`.`user_id` <> `read_ribbons`.`user_id` | |
AND `comments`.`is_deleted` = 0 | |
AND `comments`.`is_moderated` = 0 | |
AND ( `parent_comments`.`user_id` = `read_ribbons`.`user_id` | |
OR `parent_comments`.`user_id` IS NULL | |
AND `stories`.`user_id` = `read_ribbons`.`user_id` ) | |
AND `stories`.`score` > `stories`.`flags` | |
AND `comments`.`score` > `comments`.`flags` | |
AND ( `parent_comments`.`id` IS NULL | |
OR `parent_comments`.`score` > `parent_comments`.`flags` | |
AND `parent_comments`.`is_moderated` = 0 | |
AND `parent_comments`.`is_deleted` = 0 ) | |
AND ! EXISTS(SELECT 1 | |
FROM (`votes` `f` | |
JOIN `comments` `c` | |
ON( `f`.`comment_id` = `c`.`id` )) | |
WHERE `f`.`vote` < 0 | |
AND `f`.`user_id` = `parent_comments`.`user_id` | |
AND `c`.`user_id` = `comments`.`user_id` | |
AND `f`.`story_id` = `comments`.`story_id` | |
LIMIT 1) | |
AND ! EXISTS(SELECT 1 | |
FROM `hidden_stories` `h` | |
WHERE `h`.`story_id` = `stories`.`id` | |
AND `h`.`user_id` = `parent_comments`.`user_id` | |
LIMIT 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment