mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-15 03:39:43 +08:00
`.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.
41 lines
1.2 KiB
Ruby
41 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class IgnoredUser < ActiveRecord::Base
|
|
validates :expiring_at, presence: true
|
|
|
|
belongs_to :user
|
|
belongs_to :ignored_user, class_name: "User"
|
|
|
|
# Excludes self and staff to match topic post filtering.
|
|
def self.ignored_ids_for(user)
|
|
return [] unless user
|
|
|
|
DB.query_single(<<~SQL, current_user_id: user.id)
|
|
SELECT ignored_user_id
|
|
FROM ignored_users as ig
|
|
INNER JOIN users as u ON u.id = ig.ignored_user_id
|
|
WHERE ig.user_id = :current_user_id
|
|
AND ig.ignored_user_id <> :current_user_id
|
|
AND NOT u.admin
|
|
AND NOT u.moderator
|
|
SQL
|
|
end
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: ignored_users
|
|
#
|
|
# id :bigint not null, primary key
|
|
# expiring_at :datetime not null
|
|
# summarized_at :datetime
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# ignored_user_id :integer not null
|
|
# user_id :integer not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_ignored_users_on_ignored_user_id_and_user_id (ignored_user_id,user_id) UNIQUE
|
|
# index_ignored_users_on_user_id_and_ignored_user_id (user_id,ignored_user_id) UNIQUE
|
|
#
|