mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
Previously, claiming a topic recorded a history entry on every reviewable it contained, including ones resolved long ago, and the transient lock taken whenever a moderator opens a confirmation dialog or an action modal was recorded the same way — even on the sites where claiming is disabled, which is the default. A flag that stayed open therefore accumulated an endless list of claim/unclaim pairs, most of them recording activity on other flags entirely. This change records only deliberate claims, and only against reviewables that are still pending, so a resolved item's timeline stops changing and the entries that remain correspond to real moderation decisions.
44 lines
1.1 KiB
Ruby
Vendored
44 lines
1.1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class ReviewableClaimedTopic < ActiveRecord::Base
|
|
belongs_to :topic
|
|
belongs_to :user
|
|
validates :topic, uniqueness: true
|
|
|
|
def log_topic_history(type, performed_by)
|
|
return if automatic?
|
|
|
|
Reviewable
|
|
.pending
|
|
.where(topic_id:)
|
|
.find_each { |reviewable| reviewable.log_history(type, performed_by) }
|
|
end
|
|
|
|
def self.claimed_hash(topic_ids)
|
|
result = {}
|
|
if SiteSetting.reviewable_claiming == "disabled"
|
|
ReviewableClaimedTopic
|
|
.where(topic_id: topic_ids, automatic: true)
|
|
.each { |rct| result[rct.topic_id] = rct }
|
|
else
|
|
ReviewableClaimedTopic.where(topic_id: topic_ids).each { |rct| result[rct.topic_id] = rct }
|
|
end
|
|
result
|
|
end
|
|
end
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: reviewable_claimed_topics
|
|
#
|
|
# id :bigint not null, primary key
|
|
# automatic :boolean default(FALSE), not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# topic_id :integer not null
|
|
# user_id :integer not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_reviewable_claimed_topics_on_topic_id (topic_id) UNIQUE
|
|
#
|