Created
February 17, 2016 20:01
-
-
Save vetalt/1457b59840a22cc8af49 to your computer and use it in GitHub Desktop.
getLatestForCategories
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 | |
ft1.parent_category_id, | |
substring_index(group_concat(ft1.forum_topic_id order by ft1.last_forum_topic_create_date desc), ',', 3) as ids | |
from | |
forum_topic ft1 | |
join user u1 on ft1.user_id = u1.user_id | |
and u1.is_content_hidden = 0 | |
join forum_topic ft2 on ft1.last_forum_topic_id = ft2.forum_topic_id | |
join user u2 on ft2.user_id = u2.user_id | |
and u2.is_content_hidden = 0 | |
and ( | |
u2.main_image_hash is not null | |
or u2.create_date < date_sub(curdate(), interval 30 day) | |
) | |
where | |
ft1.parent_category_id is not null | |
and ft1.is_parent_topic = 1 | |
and ft1.post_count > 3 | |
and ft1.is_live = 1 | |
group by | |
ft1.parent_category_id | |
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = | |
select | |
ft.parent_category_id, | |
ft.forum_topic_id, | |
ft.subject, | |
ft.url, | |
ft.post_count, | |
ft.last_forum_topic_create_date, | |
case when ft.is_locked then 'locked' when tft.track_forum_topic_id is not null then 'tracked' else 'none' end as status, | |
if ( | |
ft.create_date >= ifnull('2016-02-17 11:23:32', date_sub(curdate(), interval 7 day)) | |
and ft.forum_topic_id not in (0), 1, 0) as new | |
from | |
forum_topic ft | |
left join track_forum_topic tft on ft.forum_topic_id = tft.forum_topic_id | |
and tft.user_id = ifnull(41, 0) | |
where | |
ft.forum_topic_id in ('23', '415', '2835', '2815', '20', '279', '202', '481', '1543', '764', '292') | |
order by | |
ft.last_forum_topic_create_date desc |
jseverson
commented
Feb 18, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment