# 主题列表预览（旧版）

**URL:** https://meta.discourse.org/t/topic-list-previews-legacy/101646
**Category:** Plugin
**Tags:** deprecated
**Created:** [2018年十一月9日 03:56 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646 "2018-11-09T03:56:38Z")
**Posts on this page:** 20
**Page:** 12

<div class="post-metadata">

### Author: ![petepan23](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/petepan23/32/161836_2.png) [@petepan23](https://meta.discourse.org/u/petepan23)
#### Post date: [2020年七月3日 13:33 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1165 "2020-07-03T13:33:04Z")

</div>

你好，感谢你们开发了这么棒的插件！

遗憾的是，在最近的更新后，那些未直接托管在 Discourse 上的图片在网格或瓷砖视图中不再显示。能否请您检查一下这个问题？

例如，如果帖子中的图片来自其他服务器（如 Blogger、Picasa 等），它们就不再显示了。之前，这些图片一直能正常显示，没有任何问题。

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2020年七月3日 13:37 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1166 "2020-07-03T13:37:17Z")

</div>

缩略图现在由 Discourse 核心生成，我对此几乎无法施加影响。

大部分缩略图生成逻辑已被移除，交由 Discourse 处理。

你可以在这里提出相关建议：[Theme modifiers: A brief introduction](https://meta.discourse.org/t/theme-modifiers-a-brief-introduction/150605)

---

<div class="post-metadata">

### Author: ![petepan23](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/petepan23/32/161836_2.png) [@petepan23](https://meta.discourse.org/u/petepan23)
#### Post date: [2020年七月3日 13:46 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1167 "2020-07-03T13:46:18Z")

</div>

谢谢！我刚刚在那里回复了。由于我的所有图片都不是托管在本地服务器上，我对这些更新持怀疑态度。

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2020年七月3日 13:48 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1168 "2020-07-03T13:48:39Z")

</div>

我相信，如果您通过设置将“上传”托管在远程服务器上，它仍然可以正常工作，但它将不再直接链接到远程站点和非关联的第三方。

鉴于这部分代码现在由核心处理，在插件中管理它已不再合理。您跟进此事是完全正确的 👍

---

<div class="post-metadata">

### Author: ![petepan23](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/petepan23/32/161836_2.png) [@petepan23](https://meta.discourse.org/u/petepan23)
#### Post date: [2020年七月3日 13:54 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1169 "2020-07-03T13:54:01Z")

</div>

谢谢。我理解目前的情况。由于我的网站使用其他服务器托管图片，因此修复起来并不容易。现在，要将大量帖子迁移到关联服务器非常困难，而本地服务器又无法承载如此大的数据量。

---

<div class="post-metadata">

### Author: ![davidkingham](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidkingham/32/119528_2.png) [@davidkingham](https://meta.discourse.org/u/davidkingham)
#### Post date: [2020年七月3日 23:17 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1170 "2020-07-03T23:17:31Z")

</div>

> [@merefield](#):
>
> 所以现在我在移动端的主题列表上通过 TC 可以正常看到事件了。

我遇到的问题在于，启用事件插件后，缩略图在移动端不再显示，正如之前讨论的那样。我以为你指的就是这个问题。

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2020年七月4日 11:25 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1171 "2020-07-04T11:25:46Z")

</div>

缩略图在我这里显示正常。你确定已按照 @fzngagan 的要求更新了事件吗？

---

<div class="post-metadata">

### Author: ![davidkingham](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/davidkingham/32/119528_2.png) [@davidkingham](https://meta.discourse.org/u/davidkingham)
#### Post date: [2020年七月4日 12:59 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1172 "2020-07-04T12:59:30Z")

</div>

他肯定是在我测试完之后就合并了，谢谢大家，现在一切正常了！

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [2020年七月6日 06:24 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1173 "2020-07-06T06:24:50Z")

</div>

我昨天更新了系统，之后性能表现一直较差。查看分析器后，我发现是 TLP 执行的这条查询导致了问题——也许这里缺少某个索引？

有趣的是，即使我在安全模式下运行网站，这条查询仍然会出现：thinking:

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

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2020年七月6日 06:46 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1174 "2020-07-06T06:46:36Z")

</div>

功能图片。此查询多年来（甚至数年！）未曾改变。您确定这是一个新问题吗？

您是否按标签创建日期排序？这几乎肯定会是一个复杂的查询。按“最新”排序会更友好。

您可以暂时关闭此功能。

主题组件使用的是核心 API。如果它给您带来困扰，您随时可以切换并暂时使用核心 API。

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [2020年七月6日 07:03 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1175 "2020-07-06T07:03:33Z")

</div>

我想这是我升级到 PG12 之后才出现的新情况。我们确实需要按标签创建日期进行排序，这算是我们社区的一个核心“功能”。如果切换到 TC，我会错过什么呢？

附：我模糊地记得几年前曾和你讨论过关于特色行的同一问题，我会再仔细查一下。

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2020年七月6日 07:21 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1176 "2020-07-06T07:21:01Z")

</div>

您确定 PG 12 升级已完成重新索引吗？许多用户报告称，在该过程中曾出现性能下降的情况（这些报告与 TLP 无关）

顺便提一下，仔细想想，可能还有其他变化：现在需要关联 topic\_thumbnails 表，但这也是一段时间前的事了，且未收到其他相关报告。我怀疑之前可能直接使用 Topic 对象中的 image\_url 热链接，那样会更快（少一次关联），但由于核心代码的变更，这种方式已不再可行。这可能也是导致问题的原因之一。

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [2020年七月6日 08:22 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1177 "2020-07-06T08:22:53Z")

</div>

是的，重新索引已完成。按主题创建日期排序也存在同样的问题。以下是两个查询的 EXPLAIN 输出：

按标记日期排序：

```plaintext
discourse=# explain SELECT "topics"."id", "topics"."title", "topics"."last_posted_at", "topics"."created_at", "topics"."updated_at", "topics"."views", "topics"."posts_count", "topics"."user_id", "topics"."last_post_user_id", "topics"."reply_count", "topics"."featured_user1_id", "topics"."featured_user2_id", "topics"."featured_user3_id", "topics"."deleted_at", "topics"."highest_post_number", "topics"."like_count", "topics"."incoming_link_count", "topics"."category_id", "topics"."visible", "topics"."moderator_posts_count", "topics"."closed", "topics"."archived", "topics"."bumped_at", "topics"."has_summary", "topics"."archetype", "topics"."featured_user4_id", "topics"."notify_moderators_count", "topics"."spam_count", "topics"."pinned_at", "topics"."score", "topics"."percent_rank", "topics"."subtype", "topics"."slug", "topics"."deleted_by_id", "topics"."participant_count", "topics"."word_count", "topics"."excerpt", "topics"."pinned_globally", "topics"."pinned_until", "topics"."fancy_title", "topics"."highest_staff_post_number", "topics"."featured_link", "topics"."reviewable_score", "topics"."image_upload_id" 
discourse-# FROM "topics" 
discourse-# INNER JOIN "topic_tags" 
discourse-# ON "topic_tags"."topic_id" = "topics"."id" 
discourse-# INNER JOIN "tags" ON "tags"."id" = "topic_tags"."tag_id" 
discourse-# WHERE ("topics"."deleted_at" IS NULL) 
discourse-# AND "topics"."visible" = TRUE 
discourse-# AND (NOT topics.closed AND NOT topics.archived AND topics.deleted_at IS NULL) 
discourse-# AND (topics.image_upload_id in (
discourse(# SELECT image_upload_id FROM topic_thumbnails
discourse(# ))
discourse-# AND (tags.id IN (1)) 
discourse-# 
discourse-# ORDER BY (
discourse(# SELECT created_at FROM topic_tags
discourse(# WHERE topic_id = topics.id
discourse(# AND tag_id IN (1)
discourse(# LIMIT 1
discourse(# )
discourse-# 
discourse-# DESC LIMIT 6; 
                                                                    QUERY PLAN                                                         
            
---------------------------------------------------------------------------------------------------------------------------------------
------------
 Limit (cost=2631719.94..2631719.95 rows=6 width=569)
   -> Sort (cost=2631719.94..2631721.73 rows=717 width=569)
         Sort Key: ((SubPlan 1)) DESC
         -> Nested Loop (cost=0.43..2631707.09 rows=717 width=569)
               -> Seq Scan on tags (cost=0.00..4.51 rows=1 width=4)
                     Filter: (id = 1)
               -> Nested Loop (cost=0.43..2625737.13 rows=717 width=565)
                     -> Seq Scan on topic_tags (cost=0.00..860.33 rows=1539 width=8)
                           Filter: (tag_id = 1)
                     -> Index Scan using topics_pkey on topics (cost=0.43..1705.57 rows=1 width=561)
                           Index Cond: (id = topic_tags.topic_id)
                           Filter: ((deleted_at IS NULL) AND visible AND (NOT closed) AND (NOT archived) AND (deleted_at IS NULL) AND (
SubPlan 2))
                           SubPlan 2
                             -> Seq Scan on topic_thumbnails (cost=0.00..2966.64 rows=171664 width=8)
               SubPlan 1
                 -> Limit (cost=0.29..8.31 rows=1 width=8)
                       -> Index Scan using index_topic_tags_on_topic_id_and_tag_id on topic_tags topic_tags_1 (cost=0.29..8.31 rows=1
 width=8)
                             Index Cond: ((topic_id = topics.id) AND (tag_id = 1))
 JIT:
   Functions: 25
   Options: Inlining true, Optimization true, Expressions true, Deforming true
(21 rows)

```

按主题日期排序：

```plaintext
discourse=# explain SELECT "topics"."id", "topics"."title", "topics"."last_posted_at", "topics"."created_at", "topics"."updated_at", "topics"."views", "topics"."posts_count", "topics"."user_id", "topics"."last_post_user_id", "topics"."reply_count", "topics"."featured_user1_id", "topics"."featured_user2_id", "topics"."featured_user3_id", "topics"."deleted_at", "topics"."highest_post_number", "topics"."like_count", "topics"."incoming_link_count", "topics"."category_id", "topics"."visible", "topics"."moderator_posts_count", "topics"."closed", "topics"."archived", "topics"."bumped_at", "topics"."has_summary", "topics"."archetype", "topics"."featured_user4_id", "topics"."notify_moderators_count", "topics"."spam_count", "topics"."pinned_at", "topics"."score", "topics"."percent_rank", "topics"."subtype", "topics"."slug", "topics"."deleted_by_id", "topics"."participant_count", "topics"."word_count", "topics"."excerpt", "topics"."pinned_globally", "topics"."pinned_until", "topics"."fancy_title", "topics"."highest_staff_post_number", "topics"."featured_link", "topics"."reviewable_score", "topics"."image_upload_id" FROM "topics" INNER JOIN "topic_tags" ON "topic_tags"."topic_id" = "topics"."id" INNER JOIN "tags" ON "tags"."id" = "topic_tags"."tag_id" WHERE ("topics"."deleted_at" IS NULL) AND "topics"."visible" = TRUE AND (NOT topics.closed AND NOT topics.archived AND topics.deleted_at IS NULL) AND (topics.image_upload_id in (
        SELECT image_upload_id FROM topic_thumbnails
      )) AND (tags.id IN (1)) ORDER BY (SELECT created_at FROM topic_tags
        WHERE topic_id = topics.id
        AND tag_id IN (1)
        LIMIT 1)
        DESC LIMIT 6; 
                                                                    QUERY PLAN                                                         
            
---------------------------------------------------------------------------------------------------------------------------------------
------------
 Limit (cost=2631719.94..2631719.95 rows=6 width=569)
   -> Sort (cost=2631719.94..2631721.73 rows=717 width=569)
         Sort Key: ((SubPlan 1)) DESC
         -> Nested Loop (cost=0.43..2631707.09 rows=717 width=569)
               -> Seq Scan on tags (cost=0.00..4.51 rows=1 width=4)
                     Filter: (id = 1)
               -> Nested Loop (cost=0.43..2625737.13 rows=717 width=565)
                     -> Seq Scan on topic_tags (cost=0.00..860.33 rows=1539 width=8)
                           Filter: (tag_id = 1)
                     -> Index Scan using topics_pkey on topics (cost=0.43..1705.57 rows=1 width=561)
                           Index Cond: (id = topic_tags.topic_id)
                           Filter: ((deleted_at IS NULL) AND visible AND (NOT closed) AND (NOT archived) AND (deleted_at IS NULL) AND (
SubPlan 2))
                           SubPlan 2
                             -> Seq Scan on topic_thumbnails (cost=0.00..2966.64 rows=171664 width=8)
               SubPlan 1
                 -> Limit (cost=0.29..8.31 rows=1 width=8)
                       -> Index Scan using index_topic_tags_on_topic_id_and_tag_id on topic_tags topic_tags_1 (cost=0.29..8.31 rows=1
 width=8)
                             Index Cond: ((topic_id = topics.id) AND (tag_id = 1))
 JIT:
   Functions: 25
   Options: Inlining true, Optimization true, Expressions true, Deforming true
(21 rows)

```

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2020年七月6日 08:23 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1178 "2020-07-06T08:23:48Z")

</div>

有用。谢谢。

抱歉，我不确定什么时候能处理这个。

另外请注意，新的 join 可能会有所改进 ~~但我无法将其移除。~~ （哦，我确实可以！）。

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2020年七月6日 11:43 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1179 "2020-07-06T11:43:57Z")

</div>

好的，我已经与 @bartv 线下合作改进了这一点。

这仅影响插件，不影响 TC：

> <https://github.com/merefield/discourse-topic-previews-sidecar/pull/158>

建议升级以利用此改进，这对于使用特色图片的网站来说是一个巨大的提升。

---

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [2020年七月6日 11:46 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1180 "2020-07-06T11:46:48Z")

</div>

你真是个摇滚明星！🎸

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2020年七月6日 11:49 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1181 "2020-07-06T11:49:28Z")

</div>

Bart，你详尽的侦探工作也至关重要，谢谢。

---

<div class="post-metadata">

### Author: ![nory](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nory/32/173397_2.png) [@nory](https://meta.discourse.org/u/nory)
#### Post date: [2020年七月7日 14:02 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1182 "2020-07-07T14:02:15Z")

</div>

你好，我已在容器的 app.yml 中添加了 git clone 地址，但当我尝试重建应用时出现错误：

`(<unknown>): 在扫描纯标量时，第 91 行第 13 列发现制表符，违反了缩进规则 -e LANG=en_US.UTF-8`

网站也无法正常工作。

我删除了该插件的 git clone 地址后，一切又恢复正常了。

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2020年七月7日 14:04 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1183 "2020-07-07T14:04:35Z")

</div>

我认为您的问题并非此插件所特有。您不能在 app.yml 中使用制表符，请使用空格。

---

<div class="post-metadata">

### Author: ![nory](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nory/32/173397_2.png) [@nory](https://meta.discourse.org/u/nory)
#### Post date: [2020年七月7日 14:07 UTC](https://meta.discourse.org/t/topic-list-previews-legacy/101646/1184 "2020-07-07T14:07:59Z")

</div>

好的，抱歉，我复制粘贴了插件的最新一行并更改了 git clone 的 URL。现在它起作用了，谢谢：slight\_smile:

[上一頁](https://meta.discourse.org/t/topic-list-previews-legacy/101646.md?page=11)

[下一頁](https://meta.discourse.org/t/topic-list-previews-legacy/101646.md?page=13)
