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:
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:
oh… is that how its done?
No, that is not how it is done.
So better phrased as per this comment:
https://github.com/discourse/discourse/blob/master/app/models/topic_view_item.rb#L10
No see the SQL
1 view per ip
1 view per user
1 attempt to upsert per day per ip per user
sorry it was this line I was linking to
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
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.
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.
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.
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?
I understood it just to be 1 per IP:
I think the per day thing is just about
its complicated is one view per page view expected? it is so easy to abuse.
nope its just one view per ip, personally I think what we had going for so was a bit better
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
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.
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”.
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.
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.
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)