discourse/app
David Taylor e7bad9f05d
FIX: Ensure directory items appear in a consistent order (#11370)
User directory items are sorted by some activity metric. If those metrics have the same value, postgres does not guarantee the order in which they will be returned. This can cause issues in pagination - some users may appear twice, and some may be missed. To illustrate

```
pry(main)> query = DirectoryItem.where(period_type: DirectoryItem.period_types[:weekly]).order(:likes_received).limit(50);
pry(main)> page1 = query.offset(0).pluck(:id);
pry(main)> page2 = query.offset(50).pluck(:id);
pry(main)> (page1 & page2).count # users on both pages
=> 29
```

If we use the primary key to tie-break matching metrics, things are much more reliable

```
pry(main)> query = DirectoryItem.where(period_type: DirectoryItem.period_types[:weekly]).order(:likes_received, :id).limit(50);
pry(main)> page1 = query.offset(0).pluck(:id);
pry(main)> page2 = query.offset(50).pluck(:id);
pry(main)> (page1 & page2).count # users on both pages
=> 0
```

This most commonly effects new sites where all the directory metrics are zero.

The fact that the ordering is indeterminate makes it difficult to write a reliable test case for this.
2020-11-27 18:12:49 +00:00
..
assets DEV: Tidy up imports. (#11364) 2020-11-27 11:30:16 -03:00
controllers FIX: Ensure directory items appear in a consistent order (#11370) 2020-11-27 18:12:49 +00:00
helpers UX: Use appropriate logo on static pages (#11211) 2020-11-12 10:50:55 -08:00
jobs FIX: Cached badge_count isn't updated after backfilling badges (#11281) 2020-11-18 22:01:56 +01:00
mailers FIX: Ensure group SMTP and message builder always uses from address for Reply-To when IMAP is enabled (#11037) 2020-10-28 07:01:58 +10:00
models FEATURE: Add users:log_out API key scope (#11359) 2020-11-26 10:39:38 +00:00
serializers PERF: Simplify topic serialization for user summary page (#11236) 2020-11-17 12:07:16 +00:00
services PERF: avoid using destroy_all when removing stats (#11358) 2020-11-26 15:29:39 +10:00
views Move CSS link tags above JS in the head 2020-11-17 09:57:30 -05:00