discourse/app/models/post_stat.rb
David Taylor 3332e9f4c3
DEV: Always pass --force to annotaterb and reorder annotations (#39977)
`.annotaterb.yml` has carried `classified_sort: true` since the project
switched from `annotate` to `annotaterb` (commit 0eab7daea4, July 2025),
but annotaterb's default behaviour is to compare the existing schema
block against what it would generate and skip the rewrite when the
column list matches — even when the *ordering* of those columns differs.
The result is that models which haven't had a schema change since the
config landed never get reordered, and `classified_sort` drift
accumulates indefinitely.

`--force` makes annotaterb always rewrite, so a single `bin/rake
annotate:clean` run brings every model into the canonical format and
keeps them there. Every schema block is now grouped primary-key →
regular columns → timestamps → foreign keys (alphabetical within each
group). Pure annotation comment change — no code modifications.

Also cleans up the rake task to avoid string interpolation for `system`
calls.
2026-05-13 14:12:48 +01:00

36 lines
1.1 KiB
Ruby

# frozen_string_literal: true
class PostStat < ActiveRecord::Base
# Version 1 is the original textarea composer for Discourse,
# which has been around since its inception and uses a split
# pane between markdown and preview.
#
# Version 2 is the new rich text composer, which is a single
# contendedibale using ProseMirror which is more of a WYSIWYG
# experience.
COMPOSER_VERSIONS = { 1 => "classic", 2 => "rich_text" }
belongs_to :post
end
# == Schema Information
#
# Table name: post_stats
#
# id :integer not null, primary key
# composer_open_duration_msecs :integer
# composer_version :integer
# drafts_saved :integer
# typing_duration_msecs :integer
# writing_device :string
# writing_device_user_agent :string
# created_at :datetime not null
# updated_at :datetime not null
# post_id :integer
#
# Indexes
#
# index_post_stats_on_composer_version (composer_version)
# index_post_stats_on_post_id (post_id)
# index_post_stats_on_writing_device (writing_device)
#