Richie
(Richie Rich)
March 29, 2025, 9:47am
1
Discourse 3.5.0.beta3-dev (afde7cc172 ).
The link counter displayed at the bottom of a topic seems to stop at 50, even when there are over 1,000 links in the thread:
For reference:
On another topic, this one also says 50:
When there are 250+ links:
Does anyone know what might be causing this?
2 Likes
pfaffman
(Jay Pfaffman)
March 29, 2025, 9:41pm
2
Without looking at the code, I think that number probably comes from topic_links
, so something like
select * from topic_links where topic_id=1234
It does seem like a bug, though.
3 Likes
Richie
(Richie Rich)
March 30, 2025, 10:09am
3
Interesting, hadn’t spotted that table.
If this helps, there are 4,155 links in this topic id yet it says 50x on the front end:
pfaffman
(Jay Pfaffman)
March 30, 2025, 2:45pm
4
Sounds like a bug. Maybe share the link. Maybe look in the code.
Looks like it’s limited to 50 on purpose; I guess that it’s a complicated join and having it do hundreds or thousands would be a performance issue.
def self.topic_map(guardian, topic_id)
# Sam: complicated reports are really hard in AR
builder = DB.build(<<~SQL)
SELECT ftl.url,
COALESCE(ft.title, ftl.title) AS title,
ftl.link_topic_id,
ftl.reflection,
ftl.internal,
ftl.domain,
MIN(ftl.user_id) AS user_id,
SUM(clicks) AS clicks
FROM topic_links AS ftl
LEFT JOIN topics AS ft ON ftl.link_topic_id = ft.id
LEFT JOIN categories AS c ON c.id = ft.category_id
/*where*/
GROUP BY ftl.url, ft.title, ftl.title, ftl.link_topic_id, ftl.reflection, ftl.internal, ftl.domain
ORDER BY clicks DESC, count(*) DESC
LIMIT 50
SQL
4 Likes
Richie
(Richie Rich)
March 30, 2025, 3:44pm
5
Hmmm
Thanks for the confirmation @pfaffman
I don’t know why we’d show a number to the end user which is completely inaccurate
No information is better than inaccurate information.
I have an idea for an easy solution which doesn’t involve removing this wrong number completely.
I’ll post a suggestion in UX
1 Like
sam
(Sam Saffron)
March 31, 2025, 5:41am
6
Yeah this lives between bug and ux.
On one hand it only impacts the UI of Discourse, on the other hand it is buggy to show a number that we know is not correct.
I think the simplest fix on our side is to select 51 and then show the text “50+” in the UI if we get 51.
It feels in the realm of pr-welcome , but I will leave @lindsey to triage and decide.
sam
(Sam Saffron)
March 31, 2025, 5:43am
7
Oh I see:
Further to what I thought was a bug but is seemingly by design, the topic link counter stops at 50:
Even if there are thousands of links in the topic
And:
With this in mind, rather than showing an inaccurate number to the end user could we simply display a + symbol if there are more than 50 links in a topic?
For example, this:
[Screenshot 2025-03-30 at 16.48.20]
Would simply become 50+ like so:
[Screenshot 2025-03-30 at 16.48.30]
This way the user is not being told in…
So I guess we take it up there.