Results 1 to 7 of 7

Thread: Thread Views

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Thread Views

    I have been holding this off for quite some time.

    I am not sure how to do Thread Views for my forum. My thought is to have a table with either IP address (or usernames) and the forumID (along with timestamp, i guess) and then when i want to display the views, i just query all the records for that forum.

    It seems like that table could get really big, really fast. Is there any other way to do it, or am i right on the money?

    My usual boring signature: Something

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Thread Views

    Usually just a counter field which you increment.

  3. #3

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Thread Views

    Quote Originally Posted by penagate
    Usually just a counter field which you increment.
    but that would increase every time someone clicked the link, replied to a thread, edited a thread, delete a post.
    My usual boring signature: Something

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Thread Views

    Yeah, usually. They tend not to be reliable in the least.

    The method you suggest (a table with a unique index on thread ID + IP address) would be more reliable, but also fallible. What about dynamic IPs? What about proxies? The table might get fairly large, but that may or may not be a problem.

    Another method would be to store thread ID, user ID, and view count, which a unique index on thread ID and user ID and counting guests as user 0. This would allow you to track who viewed the thread and how many times they did so.

    MySQL SUM() may or may not be cached (I forget) so you could also store a total number of views against the thread record if performance is a concern; display that, then provide an option to drill down to views against users.


    (Sorry, I wrote this when I read your reply, then went to lunch and forgot about it.)

  5. #5

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Thread Views

    Quote Originally Posted by penagate
    Yeah, usually. They tend not to be reliable in the least.

    The method you suggest (a table with a unique index on thread ID + IP address) would be more reliable, but also fallible. What about dynamic IPs? What about proxies? The table might get fairly large, but that may or may not be a problem.

    Another method would be to store thread ID, user ID, and view count, which a unique index on thread ID and user ID and counting guests as user 0. This would allow you to track who viewed the thread and how many times they did so.

    MySQL SUM() may or may not be cached (I forget) so you could also store a total number of views against the thread record if performance is a concern; display that, then provide an option to drill down to views against users.


    (Sorry, I wrote this when I read your reply, then went to lunch and forgot about it.)
    i will try your method out.

    seems a little more reliable.

    I will also do some research on how phpBB and vB do it, maybe i can get some ideas.
    My usual boring signature: Something

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Thread Views

    I can tell you now that they just use simple incrementing counters.

  7. #7
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: Thread Views

    My quick thought is...

    If IP + Session ID are unique (query a db perhaps), then count++

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width