mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 10:42:45 +08:00
f562da3150
Why this change? Prior to this change, the `CategoryList#find_relevant_topics` method was loading and allocating all `CategoryFeaturedTopic` records in the database to eventually only just use its `category_id` and `topic_id` column. On a site with many `CategoryFeaturedTopic` records, the loading of the ActiveRecord objects is a source of bottleneck. The other problem with the `CategoryList#find_relevant_topics` method is that it is unconditionally loading all records from the database even if the user does not have access to the category. This again is wasteful. What does this change do? This commit makes it such that `CategoryList#find_relevant_topics` is called only after `CategoryList#find_categories` in the `CategoryList#initialize` method so that we can filter featured topics against categories that the user has access to. The second change is that Instead of loading `CategoryFeaturedTopic` records, we make an inner join agains the `topics` table instead and skip any allocation of `CatgoryFeaturedTopic` ActiveRecord objects. |
||
---|---|---|
.. | ||
fabricators | ||
fixtures | ||
generator | ||
helpers | ||
import_export | ||
initializers | ||
integration | ||
integrity | ||
jobs | ||
lib | ||
mailers | ||
migrations | ||
models | ||
multisite | ||
requests | ||
script/import_scripts | ||
serializers | ||
services | ||
support | ||
system | ||
tasks | ||
views | ||
rails_helper.rb | ||
regenerate_swagger_docs | ||
swagger_helper.rb |