mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 06:15:48 +08:00
a7628c1d74
The `posts` relation on `Topic` is not ordered. Using `Topic.posts.first` is basically the same as asking for a random post, it will depend on DB order. This breaks on Topic merge and split for example. Additionally, a huge problem with that is that it forces active record down a slow path. `Topic.posts.first` is extremely slow on giant topics, since it has no default ordering it appears AR materializes the entire set prior to doing `first`. This commit also illustrates the importance of testing, initially I only fixed the second instance of the problem in `post_validator.rb` but testing revealed that the problem was repeated at the top of the file. Longer term we should consider a larger change of default ordering the posts relations so people do not fall down this trap anymore. |
||
---|---|---|
.. | ||
allowed_ip_address_validator_spec.rb | ||
email_setting_validator_spec.rb | ||
email_validator_spec.rb | ||
enable_local_logins_via_email_validator_spec.rb | ||
enable_sso_validator_spec.rb | ||
integer_setting_validator_spec.rb | ||
ip_address_format_validator_spec.rb | ||
max_emojis_validator_spec.rb | ||
max_username_length_validator_spec.rb | ||
min_username_length_validator_spec.rb | ||
password_validator_spec.rb | ||
post_validator_spec.rb | ||
quality_title_validator_spec.rb | ||
regex_presence_validator_spec.rb | ||
regex_setting_validator_spec.rb | ||
reply_by_email_address_validator_spec.rb | ||
reply_by_email_enabled_validator_spec.rb | ||
sso_overrides_email_validator_spec.rb | ||
string_setting_validator_spec.rb | ||
topic_title_length_validator_spec.rb | ||
upload_validator_spec.rb | ||
url_validator_spec.rb | ||
user_full_name_validator_spec.rb | ||
username_setting_validator_spec.rb |