# Setting timerange for the Lates Topic first screen for invited users

**URL:** https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941
**Category:** Support
**Created:** [2016年十月1日 05:12 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941 "2016-10-01T05:12:28Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [2016年十月1日 05:12 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/1 "2016-10-01T05:12:28Z")

</div>

Is there any setting for setting which timerange is selected by default on the Latest Topic page when a user accepts an email invitation?

It currently shows “All time”, but I’d like to set it to “Last month”.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月1日 12:13 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/2 "2016-10-01T12:13:00Z")

</div>

Do you mean the ‘Top’ page? There is `top page default timeframe` but it appies to everyone, not just invited.

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [2016年十月1日 12:15 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/3 "2016-10-01T12:15:20Z")

</div>

In our setup, the `top page default timeframe` setting is set to `monthly`, but for a newly-invited user it is shown for `all time`.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月1日 12:22 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/4 "2016-10-01T12:22:56Z")

</div>

Do you know which email they receive? I wonder if it is redirecting them to /top/all directly?

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [2016年十月1日 12:27 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/5 "2016-10-01T12:27:00Z")

</div>

The link is like this:

> [Козоводство в Украине, России, СНГ: форум, хозяйства, рынок](http://forum.kozovod.com/invites/123456)

I can reproduce it stably by inviting my other email to register and clicking the link from there.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月1日 12:28 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/6 "2016-10-01T12:28:24Z")

</div>

Yeah, I meant internally once they arrive and verify the invite process. That may be enough to let me dig into this later and see what it is doing.

---

<div class="post-metadata">

### Author: ![Overgrow](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/overgrow/32/478189_2.png) [@Overgrow](https://meta.discourse.org/u/Overgrow)
#### Post date: [2016年十月1日 12:57 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/7 "2016-10-01T12:57:00Z")

</div>

I’ve just clicked your link and after changing to “Top” I see only topics from past month.

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [2016年十月1日 12:59 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/8 "2016-10-01T12:59:16Z")

</div>

> [@Overgrow](#):
>
> after changing to “Top”

This is a fake (example) link which with an invalid invitation secret key. It will lead to the home page, which makes this link not suitable for further testing.

With a good link, you won’t have to click on “Top” - it will show you “Top” by default.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月1日 14:34 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/9 "2016-10-01T14:34:53Z")

</div>

Can you help me with repro steps?

Here is what I did, as a user go to my Profile page \> Invites \> Send an invite.  
Receive invite and I’m automatically signed in… but it dropped me off at the homepage, not to Top…

Can you give me clear steps that produce the result you are experiencing?

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [2016年十月3日 03:48 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/10 "2016-10-03T03:48:56Z")

</div>

@cpradio hm the repro steps you’re trying are correct - I’m doing exactly the same.

However, once I click on the link from the invitation email, it opens the “TOP” page:

 ![](https://global.discourse-cdn.com/meta/original/3X/1/1/11289d58338eafc6069167fd5d264adc32811be3.png)

Maybe there is a difference in our Settings that affect the scenario?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2016年十月3日 06:26 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/11 "2016-10-03T06:26:29Z")

</div>

Remember users who are new or have been absent a long time get the top page .

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月3日 10:30 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/12 "2016-10-03T10:30:09Z")

</div>

I had sent the email to a non-existant user and it properly created an account on link click…

I’ll see if I can attempt this again later today.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月10日 15:22 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/13 "2016-10-10T15:22:32Z")

</div>

Okay, so I couldn’t repo locally because it seems my sandbox and local sites do not have enough traffic to warrant redirecting to top/all. But when I did it on a live site that is active, it definitely redirects to top/all. It is that /all that is causing it to select the ALL timeframe.

Provided I can figure out where that gets set, what is the verdict here? Can we redirect to top/ and ignore the “all” so it uses the default in Site Settings?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月10日 15:46 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/14 "2016-10-10T15:46:23Z")

</div>

Found it.

discovery.js.es6 has the following

> <https://github.com/discourse/discourse/blob/5dbd6a304bed5400be481d71061d3e3ebb4d6785/app/assets/javascripts/discourse/routes/discovery.js.es6#L13-L21>

Which then utilizes the `redirect_to_top.period` found in user\_option.rb

> <https://github.com/discourse/discourse/blob/5dbd6a304bed5400be481d71061d3e3ebb4d6785/app/models/user_option.rb#L86-L110>

And that method pulls its value for the time period from `min_redirected_to_top_period`

> <https://github.com/discourse/discourse/blob/5dbd6a304bed5400be481d71061d3e3ebb4d6785/app/models/site_setting.rb#L100-L107>

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

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [2016年十月11日 01:05 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/15 "2016-10-11T01:05:47Z")

</div>

Thanks for the research.  
So is there a way to let the user be redirected as per configuration of the default top period?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月11日 01:08 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/16 "2016-10-11T01:08:09Z")

</div>

> [@meglio](#):
>
> So is there a way to let the user be redirected as per configuration of the default top period?

Not without changes.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月11日 03:35 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/17 "2016-10-11T03:35:30Z")

</div>

I’m actually wondering why we wouldn’t reuse the logic for handling the default top page period.

> <https://github.com/discourse/discourse/blob/600b23c0a40a4453532d20c1a53ce426ae8e3e68/app/controllers/list_controller.rb#L330-L350>

Calling that to get the period to show, seems logical to me. It would ensure the user sees the top most recent topics giving them a better insight to the activity of the community. But that is purely my own opinion.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2016年十月11日 07:33 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/18 "2016-10-11T07:33:04Z")

</div>

Nice detective work @cpradio 🕵️‍♂️

Feel free to submit a PR. Might have been done by someone who didn’t know that logic existed elsewhere.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月11日 15:16 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/19 "2016-10-11T15:16:20Z")

</div>

Okay, I think this will solve it  
[https://github.com/discourse/discourse/pull/4485](https://github.com/discourse/discourse/pull/4485)

I wrote additional tests (and verified the existing ones still pass) to verify it returns the Top redirect when it should since I’m still struggling to recreate the workflow consistently using the UI.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016年十月11日 18:04 UTC](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941/20 "2016-10-11T18:04:31Z")

</div>

Okay, so that first PR was a major oops. This second one is much better and isn’t causing a bunch of tests to fail.  
[https://github.com/discourse/discourse/pull/4487](https://github.com/discourse/discourse/pull/4487)

[下一頁](https://meta.discourse.org/t/setting-timerange-for-the-lates-topic-first-screen-for-invited-users/50941.md?page=2)
