mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 03:25:17 +08:00
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.
13 lines
337 B
Ruby
Vendored
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
|