Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Question regarding UserDiscussion.DateLastViewed

vizionaviziona New
edited March 2011 in Vanilla 2.0 - 2.8
I am creating plugin which will show list of all discussions with unread comments.
My code looks like this:

return $Sender->SQL->Select('d.*') ->Join('UserDiscussion ud','d.DiscussionID = ud.DiscussionID and ud.DateLastViewed < d.DateLastComment') ->Where(array ( 'ud.UserID' => $UserID, )) ->Limit($Limit, $Offset) ->Get();

the problem that I am facing is that even if I open Discussion, the DateLastViewed field is not always updated
(possibly related to problem my installation has: http://vanillaforums.org/discussion/12903/datelastcomment-not-updateds)

Can someone reproduce this misbehavior?
Is there more preferred way to get unread discussions?

thanks

Comments

  • Options
    lucluc ✭✭
    edited March 2011
    To mark as unread, I need to change the comment count to 0 (as stated by @Mark 2 years ago http://vanillaforums.org/discussion/comment/96439#Comment_96439) and now I do need to set datelastviewed as NULL also.

    I think that you should select the ones with dates less than or null, and/or maybe check the comment count as well compared to the full number of comments for that discussion.

    Maybe a core dev might have some more insight about this.
  • Options
    thanks, i did not look into the comment count
    will report once I check this live
  • Options
    following did the trick, thanks

    ->Join('UserDiscussion ud', 'd.DiscussionID = ud.DiscussionID and (d.CountComments - ud.CountComments) >0 ')
    I'll cleanup some code and upload the plugin to Addons
Sign In or Register to comment.