'Top' sorting always defaults to Year time period

AI-generated summary

Users reported that the /Top sorting page always defaults to the ‘past year’ time period, regardless of the user’s last visit, which contradicts expected behavior. P16 raised the issue, and codinghorror speculated it might be intentional for long-absent users. zogstrip confirmed it was a bug: the system was incorrectly overriding the user’s last-visit timestamp with a hardcoded default, even for returning users. Two fixes were implemented — one to restore correct time period selection based on last visit, and another to fix a client-side variable naming error that prevented proper redirection. P16 confirmed the fix and asked if manual navigation to /Top should still respect the most relevant time period — zogstrip affirmed that it should. P16 also inquired about reopening discussion on Top sorting criteria, and zogstrip reopened the original topic for community suggestions. The issue was resolved thanks to the report, uncovering and fixing two related bugs.

I’m not sure if this is a bug, but whenever I visit /Top, the time period selected by default is always the past year. From what I have read on Meta, it should select the time period based on your last visit - i.e. if you haven’t visited Meta in a few days, it shows the past week; likewise, if you visited it yesterday, you should be shown the Top posts for the past 24 hours.

Possibly but I am not sure we did this on manual navigation to top, it is more of a redirect for long absent users. Perhaps @zogstrip can advise.

Turns out, this was broken since we added support for a default top timeframe. That value was overriding the date of the user’s previous visit instead of just being a default value when there was no previous visit (new user or anon).

https://github.com/discourse/discourse/commit/33bc8c276d8db36513adf72a863db3d648613489

While at it, I noticed another bug where a returning user would not be redirected to the proper timeframe due to a variable not being named properly on the client-side… :man_facepalming:

https://github.com/discourse/discourse/commit/b792db9d92dedd5bcd9386f4169fb6c4ee1b55aa

Thanks @P16 for the report as we got to fix 2 bugs :raised_hands:

Thanks @zogstrip for fixing this! Just to confirm, is the correct behavior to default to the most relevant time period, even if /top is selected manually?

While on this topic, are you still open to suggestions for the Top sorting criteria, as the original topic has closed:

Yes, that is correct.

Sure, I’ve re-opened the topic.