Jump to content

Forums - Topics Viewed


Garethp

Recommended Posts

So, you know how on forums (including this one) the icon of a topic/forum will be greyed out if your account viewed that topic's latest post, regardless of which computer you viewed it on? How exactly does it store that?

 

I know that logically it would store it on the Database, but I'm curious as to the actual implementation. It seems to me that storing every single topic you viewed it and when would take up huge numbers of rows, even for a small number of people, like say 100. If you have a forum with 1000's of people, each viewing even 3 topics a day, you're record numbers would be huge, slowing down the database. And calling your last viewed time for each and ever topic? Wouldn't that slow down the code excecution heaps?

 

If you have any input, I'd love to hear it. It's a question I've been wrestling with in the back of my mind for a few years now

Link to comment
Share on other sites

Here's one way:

 

Create a table that will basically store the last activity timestamp of a user for a thread and forum like:

 

threads_viewed

------------------------

user_id

thread_id

timestamp

 

For the logic: each time a thread is viewed, insert a record into that table. Now you know the last time the user viewed the thread.

 

So all you have to do to show a 'new' icon on the thread list is just check if there any posts to the threads where the post time is after the users last thread view time, that way you know that the user has not viewed those replies.

 

Hope this helps.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.