mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
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.
This commit is contained in:
15
db/migrate/20240527015009_add_topic_view_stats.rb
Normal file
15
db/migrate/20240527015009_add_topic_view_stats.rb
Normal file
@ -0,0 +1,15 @@
|
||||
# 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
|
Reference in New Issue
Block a user