PERF: limit maximum number of topic links to 50
When a giant topic has huge numbers of links only show top 50 if expanded from the show more links... button.
This commit is contained in:
parent
a5d0e0f277
commit
c1a01b2a28
|
@ -37,20 +37,23 @@ class TopicLink < ActiveRecord::Base
|
||||||
def self.topic_map(guardian, topic_id)
|
def self.topic_map(guardian, topic_id)
|
||||||
|
|
||||||
# Sam: complicated reports are really hard in AR
|
# Sam: complicated reports are really hard in AR
|
||||||
builder = SqlBuilder.new("SELECT ftl.url,
|
builder = SqlBuilder.new <<SQL
|
||||||
COALESCE(ft.title, ftl.title) AS title,
|
SELECT ftl.url,
|
||||||
ftl.link_topic_id,
|
COALESCE(ft.title, ftl.title) AS title,
|
||||||
ftl.reflection,
|
ftl.link_topic_id,
|
||||||
ftl.internal,
|
ftl.reflection,
|
||||||
ftl.domain,
|
ftl.internal,
|
||||||
MIN(ftl.user_id) AS user_id,
|
ftl.domain,
|
||||||
SUM(clicks) AS clicks
|
MIN(ftl.user_id) AS user_id,
|
||||||
FROM topic_links AS ftl
|
SUM(clicks) AS clicks
|
||||||
LEFT JOIN topics AS ft ON ftl.link_topic_id = ft.id
|
FROM topic_links AS ftl
|
||||||
LEFT JOIN categories AS c ON c.id = ft.category_id
|
LEFT JOIN topics AS ft ON ftl.link_topic_id = ft.id
|
||||||
/*where*/
|
LEFT JOIN categories AS c ON c.id = ft.category_id
|
||||||
GROUP BY ftl.url, ft.title, ftl.title, ftl.link_topic_id, ftl.reflection, ftl.internal, ftl.domain
|
/*where*/
|
||||||
ORDER BY clicks DESC")
|
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
|
||||||
|
|
||||||
builder.where('ftl.topic_id = :topic_id', topic_id: topic_id)
|
builder.where('ftl.topic_id = :topic_id', topic_id: topic_id)
|
||||||
builder.where('ft.deleted_at IS NULL')
|
builder.where('ft.deleted_at IS NULL')
|
||||||
|
|
|
@ -1868,7 +1868,7 @@ en:
|
||||||
title: "Topic Summary"
|
title: "Topic Summary"
|
||||||
participants_title: "Frequent Posters"
|
participants_title: "Frequent Posters"
|
||||||
links_title: "Popular Links"
|
links_title: "Popular Links"
|
||||||
links_shown: "show all {{totalLinks}} links..."
|
links_shown: "show more links..."
|
||||||
clicks:
|
clicks:
|
||||||
one: "1 click"
|
one: "1 click"
|
||||||
other: "%{count} clicks"
|
other: "%{count} clicks"
|
||||||
|
|
Loading…
Reference in New Issue