0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 03:25:17 +08:00
discourse/db/migrate/20260723013754_create_user_visit_daily_rollups.rb
Alan Guo Xiang Tan 395077a745
PERF: Use daily rollups for DAU/MAU reports (#41958)
DAU/MAU reports previously calculated every requested date from the full
user visit history, so dashboard requests became slower as that history
grew.

Persist the daily DAU and trailing-30-day MAU values and have the shared
report read only those rollups. The scheduled job builds all existing
history on its first successful run, then refreshes yesterday and today
every three hours. Replacements are atomic, so a failed calculation
leaves the previous report data intact.
2026-07-24 09:52:40 +08:00

13 lines
337 B
Ruby
Vendored

# frozen_string_literal: true
class CreateUserVisitDailyRollups < ActiveRecord::Migration[8.0]
def change
create_table :user_visit_daily_rollups do |t|
t.date :date, null: false
t.bigint :dau, null: false
t.bigint :mau, null: false
end
add_index :user_visit_daily_rollups, :date, unique: true
end
end