vanilla / addons

Official add-ons and tools for Vanilla Forums.
http://open.vanillaforums.com
108 stars 169 forks source link

Participated: Rework using 'Participated' flag in core #462

Closed linc closed 7 years ago

linc commented 7 years ago

Currently it's using a query that does not scale.

@kaecyra may have more info.

kaecyra commented 7 years ago

Currently the plugin executes a query that looks like this:

select d.*, d.InsertUserID as `FirstUserID`, d.DateInserted as `FirstDate`, d.DateLastComment as `LastDate`, d.LastCommentUserID as `LastUserID`, iu.Name as `FirstName`, iu.Photo as `FirstPhoto`, iu.Email as `FirstEmail`, lcu.Name as `LastName`, lcu.Photo as `LastPhoto`, lcu.Email as `LastEmail`, ca.Name as `Category`, ca.UrlCode as `CategoryUrlCode`, ca.PermissionCategoryID as `PermissionCategoryID`, d.*, w.UserID as `WatchUserID`, w.DateLastViewed as `DateLastViewed`, w.Dismissed as `Dismissed`, w.Bookmarked as `Bookmarked`, w.CountComments as `CountCommentWatch`
from GDN_Discussion d
left join GDN_User iu on d.InsertUserID = iu.UserID
left join GDN_User lcu on d.LastCommentUserID = lcu.UserID
left join GDN_Category ca on d.CategoryID = ca.CategoryID
left join GDN_UserDiscussion w on d.DiscussionID = w.DiscussionID and w.UserID = 14665
join GDN_Comment c on d.DiscussionID = c.DiscussionID
where d.CategoryID in ('-1', '242', '108', '8', '253', '115', '244', '58', '173', '54', '191', '127', '149', '176', '67', '59', '74', '202', '189', '148', '89', '105', '114', '232', '213', '109', '177', '159', '139', '106', '86', '97', '81', '56', '83', '61', '71', '66', '252', '183', '32', '245', '200', '45', '187', '79', '254', '96', '208', '100', '212', '250', '38', '101', '30', '248', '206', '44', '207', '153', '5', '52', '50', '51', '160', '258', '267', '255', '155', '271', '62', '27', '77', '260', '161', '276', '75', '278', '131', '7', '48', '246', '141', '14', '142', '199', '11', '180', '143', '156', '13', '90', '171', '119', '122', '144', '145', '126', '123', '125', '262', '263', '264', '64', '193', '25', '1', '164', '40', '236', '19', '134', '28', '22', '55', '150', '99', '188', '198')
 and c.InsertUserID = ?
group by c.DiscussionID
order by d.DateLastComment desc

It should be using the UserDiscussion.Participated flag.