0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 02:19:55 +08:00
discourse/spec/tasks
Mark VanLandingham c85593eda8
PERF: Add fast nested reply stats preparation (#41870)
## Problem

Nested reply statistics currently start backfilling only after nested
replies are enabled. At the default 100 topics every five minutes, that
is 28,800 topics per day—about 174 days for a site with five million
topics. Large sites therefore have to expose the feature before its
historical stats are ready.

## Solution

Add a backend-only `nested_replies:prepare_stats` rake task. For each
site, it:

- enables the existing realtime stats callbacks while the nested-replies
UI remains disabled;
- captures the current regular-topic high-water mark;
- enqueues low-priority, keyset-paginated batches which immediately
enqueue the next batch instead of waiting five minutes;
- reuses the existing per-topic backfill SQL; and
- isolates an individual failed topic into its own job, where normal
Sidekiq retries apply, so later topics can continue.

The task leaves the hidden maintenance flag enabled, so replies created,
deleted, or reparented after preparation begins keep the same stats
current before nested replies are enabled. On multisite it prepares
every database by default; `RAILS_DB` scopes it to one database.

The existing scheduled backfill keeps its original feature gate, topic
selection, batch schedule, and calculations. This adds no UI,
migrations, stats version, readiness marker, durable cursor setting,
lock, or watchdog.

Run it with:

```sh
RAILS_ENV=production bin/rake nested_replies:prepare_stats
```

Completion is logged with the captured high-water topic ID. Re-running
the task is safe because it uses the existing idempotent upsert
behavior.

Tests cover disabled-mode preparation, bounded continuation and
high-water behavior, isolated retries, rake-task enqueueing,
preservation of the old scheduler gate, and realtime maintenance while
the UI is disabled.
2026-07-21 10:45:53 -05:00
..
assets_precompile_spec.rb DEV: Cache AssetProcessor code in development (#38036) 2026-02-25 11:24:41 +00:00
compatibility_spec.rb
destroy_spec.rb
hashtags_spec.rb
incoming_emails_spec.rb
migrate_advanced_search_banner_to_welcome_banner_spec.rb DEV: Silence expected error/debug output in core specs (#39247) 2026-04-14 11:04:10 +02:00
migrate_discourse_gifs_to_core_multisite_spec.rb DEV: better multisite suppport for migrate gifs (#40792) 2026-06-11 17:51:27 +04:00
migrate_discourse_gifs_to_core_spec.rb DEV: set enable_gifs to true in migrate gifs rake task (#41502) 2026-07-07 17:04:28 +04:00
nested_replies_spec.rb PERF: Add fast nested reply stats preparation (#41870) 2026-07-21 10:45:53 -05:00
plugin_spec.rb DEV: Prune branches on plugin:update (#38128) 2026-02-28 00:14:50 +01:00
posts_spec.rb FIX: PG::UniqueViolation for PostTimings in posts:reorder_posts rake task when PostTiming records have no corresponding Post (#35212) 2025-10-08 18:48:21 +02:00
qunit_cli_spec.rb DEV: Fix the build due to 64252b131f (#40512) 2026-06-03 13:31:07 +08:00
redis_spec.rb
release_spec.rb DEV: Enable Rails/FilePath rubocop rule (#40097) 2026-05-19 19:07:54 +02:00
site_settings_spec.rb FIX: type: objects uploads should be stored as IDs (#40178) 2026-05-21 13:45:27 -03:00
themes_spec.rb FEATURE: rake tasks to export/import theme bundles 2026-04-30 21:03:48 +00:00
topic_localizations_spec.rb DEV: Add rake task to backfill localization excerpts which were empty (#36901) 2025-12-30 17:04:36 +08:00
topics_spec.rb
uploads_spec.rb DEV: Move test cleanup to correct scope in tasks/uploads_spec.rb (#36386) 2025-12-02 17:45:28 +01:00
users_spec.rb