mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 02:13:39 +08:00
d1191b7f5f
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.
16 lines
478 B
Ruby
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
|