How many views are counted per IP?

javascript

#1

Except in our popular threads where the views are substantially lower than the posts, due to your “view” only counting 1 time per day per IP.

Sorry about that - for the pedants out there:


Should views column be removed?
(Dave McClure) #2

oh… is that how its done?


(Jeff Atwood) #3

No, that is not how it is done.


(Sam Saffron) #4

See:


(Dave McClure) #5

So better phrased as per this comment:


(Sam Saffron) #6

No see the SQL

1 view per ip
1 view per user

1 attempt to upsert per day per ip per user


(Dave McClure) #7

sorry it was this line I was linking to


(Sam Saffron) #8

That comment is incorrect, I need to fix the commenting in that file.

There are 2 unique indexes on the table (ip,topic_id) and (user_id,topic_id) the redis trick is just to avoid a db hit for a super hot path.

So if you really really want to explore the edge cases

  1. be logged off
  2. go to topic page, get one view
  3. reload … no new views
  4. wait a week with same ip reload, no new view
  5. log in, you get a new view
  6. go to a new computer which is already logged in, revisit the topic, no new views

Yes this is edge casey and can be improved but works ok for now.

The per user_id allows multiple users to share an ip (eg corporate lan NAT) and still get multiple views.


(AstonJ) #9

Is there any reason why views are being restricted like this?

A thread with lots of views often indicates it is popular. You often get ‘hot’ threads that many people are glued to but don’t actually want to get involved themselves.

If it’s to prevent abuse, why not track views per thread per ip, and if it looks like a bot (say 50 within 2 minutes) disallow views from the IP.

If it’s to give more of a ‘unique viewers’ idea, maybe show this just to admins or some other way - like who’s viewed this thread.


(Gerhard Schlager) #10

Oh, I should have looked at that table earlier. Just to make sure: When I have a private forum (so no anonymous users) with 30 users the max view count for each topic would also be 30, right?

I was already thinking about how I’d import the original view count from phpBB3. Now it looks like this would be a stupid idea anyway. Importing a view count of 7K doesn’t make sense when the counting algorithm is completely different.

Not that I’m complaining… the behaviour is just unexpected. Well, at least I’ll know now how many users have seen a topic.


(Jeff Atwood) #11

Yes @sam can you clarify handling of anons, as obviously anons do not have a user id. So is it just 1 per ip per day in that case?


(Dave McClure) #12

I understood it just to be 1 per IP:

I think the per day thing is just about


Jump to latest reply, repetition
(Sam Saffron) #13

its complicated is one view per page view expected? it is so easy to abuse.


(Sam Saffron) #14

nope its just one view per ip, personally I think what we had going for so was a bit better


(Gerhard Schlager) #15

Yes, I expected one view per page view per day. That’s what the comment says and it somehow made more sense than the current behaviour. Currently only anonymous users have the ability to create a really high view count. Otherwise it’s always restricted by the number of registered users. That feels kind of wrong to me.

Popular forum software like phpBB3 count every page view. I personally don’t like that behaviour. As a user of such forums I often hit reload in order to see if another user has responded yet. I don’t think that should count as view.

Thinking about it I would change it so that it increases the view count when

  • a registered user views a new topic
  • a registered user views a topic with unread posts
  • an anonymous user views a topic (just 1 view per IP and day)

(Sam Saffron) #16

ha, how?

anons get one page view per ip forever and ever per ip forever and ever.
logged in users get one page view per user_id forever and ever per user id.

so anon are going to have to hire a botnet to do what you are describing.


(Gerhard Schlager) #17

Maybe I’m still misunderstanding how the views are calculated, but what I’m trying to say is:

When the forum has 100 registered users than they can create max 100 views.
Let’s say you have 10 anonymous users whose provider assigns them a new IP address every day. When those 10 anonymous users read the same topic on 10 different days than they increase the view count by 100 views.

Just to clarify: I’m not talking about someone who’s trying to manipulate the view count by using a botnet or some other means. That’s 10 regular, anonymous users who happen to like this topic and therefore look at it every day.

There seems to be a imbalance. The same anonymous user has the ability to increase the view count of a topic by looking at it multiple times (if he get’s a new IP address every now and then). A registered user can’t do that. It’s just one view and that’s it.

And if you have only registered users (on a private forum) the meaning of the view count changes from “this topic is viewed often and is popular” to “this topic has been seen by n% of the users”.


(Sam Saffron) #18

only way to protect against anons cycling ips is a cookie but then multiple browsers will “work around it”

yes there is an imbalance, I am not against changing this, but its terrible timing now.

propose an algorithm we can consider it.


(Jeff Atwood) #19

I personally think it should be one view per ip per 8 hour period for anons. With the period being a site setting that defaults to 8 hours.

Probably should be similar for logged in users, just adding the user id in as well, so one view per ip per user every 8 hours.


(AstonJ) #20

Would it be possible to make this an admin setting? @codinghorror @sam

I would prefer a view simply being a view.

I think there are other more interesting ways we could expand views, such as showing referrers (and for admins, how many per referrer)