discourse/db/migrate/20240527015009_add_topic_view_stats.rb
Sam d1191b7f5f
FEATURE: topic_view_stats table with daily fidelity (#27197)
This gives us daily fidelity of topic view stats

New table stores a row per topic viewed per day tracking
anonymous and logged on views

We also have a new endpoint `/t/ID/views-stats.json` to get the statistics for the topic.
2024-05-27 15:25:32 +10:00

16 lines
478 B
Ruby

# frozen_string_literal: true
class AddTopicViewStats < ActiveRecord::Migration[7.0]
def change
create_table :topic_view_stats do |t|
t.integer :topic_id, null: false
t.date :viewed_at, null: false
t.integer :anonymous_views, default: 0, null: false
t.integer :logged_in_views, default: 0, null: false
end
add_index :topic_view_stats, %i[topic_id viewed_at], unique: true
add_index :topic_view_stats, %i[viewed_at topic_id]
end
end