cpradio
(cpradio)
October 10, 2016, 3:46pm
14
Found it.
discovery.js.es6 has the following
beforeModel(transition) {
if (transition.intent.url === "/" &&
transition.targetName.indexOf("discovery.top") === -1 &&
Discourse.User.currentProp("should_be_redirected_to_top")) {
Discourse.User.currentProp("should_be_redirected_to_top", false);
const period = Discourse.User.currentProp("redirect_to_top.period") || "all";
this.replaceWith(`discovery.top${period.capitalize()}`);
}
},
Which then utilizes the redirect_to_top.period found in user_option.rb
def redirected_to_top
# redirect is enabled
return unless SiteSetting.redirect_users_to_top_page
# top must be in the top_menu
return unless SiteSetting.top_menu =~ /(^|\|)top(\||$)/i
# not enough topics
return unless period = SiteSetting.min_redirected_to_top_period
if !user.seen_before? || (user.trust_level == 0 && !redirected_to_top_yet?)
update_last_redirected_to_top!
return {
reason: I18n.t('redirected_to_top_reasons.new_user'),
period: period
}
elsif user.last_seen_at < 1.month.ago
update_last_redirected_to_top!
return {
reason: I18n.t('redirected_to_top_reasons.not_seen_in_a_month'),
period: period
}
This file has been truncated. show original
And that method pulls its value for the time period from min_redirected_to_top_period
The site_setting.rb doesn’t take into account the default time period. It simply returns the first time period that has enough topics to meet topics per period in top page site setting