I’m pretty sure I’m ready to call this a bug.
I’ve been trying to find out where last_visited_at is updated so far I have found:
- The spec successfully tests a call to
TopicUser::track_visitupdates the value. TopicUser::change- change in notification level watching/tracking etc)TopicUser::update_last_read- keeps track of the last read post.
The problem seems to be:
- There are no calls to
TopicUser::track_visitoutside of the spec. TopicUser::update_last_readonly updates thelast_visited_atvalue when:
- “The user read at least one post in a topic that they haven’t viewed before”
I’m thinking that the following should be reviewed:
1. Should there be an explicit call when track_view is set when requesting the topic? I think there should be.
2. Change the UPDATE_TOPIC_USER_SQL to also update last_visited_at time as used in TopicUser::update_last_read so the value is kept up to date along with reading times.
3. There is a possibility that last_visited_at and first_visited_at are being set to NULL here when TopicUser::change tracking state changes:
But I don’t know enough / have a test environment to check for sure.
4. If point 3 above is not where the NULL is coming from there is either TopicUser rows being put in the table with initially last_visited_at and first_visited_at set to NULL or somewhere else they are being set to NULL.
Thoughts?