Removed unread_count from group_accounts
This commit is contained in:
@@ -13,19 +13,12 @@ module GroupInteractions
|
||||
follow_mapping(GroupAccount.where(group_id: target_group_ids, account_id: account_id, role: :admin), :group_id)
|
||||
end
|
||||
|
||||
def unread_count_map(target_group_ids, account_id)
|
||||
unread_count_mapping(GroupAccount.where(group_id: target_group_ids, account_id: account_id), :unread_count)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def follow_mapping(query, field)
|
||||
query.pluck(field).each_with_object({}) { |id, mapping| mapping[id] = true }
|
||||
end
|
||||
|
||||
def unread_count_mapping(query, field)
|
||||
query.pluck(:group_id, :unread_count).each_with_object({}) { |e, mapping| mapping[e[0]] = e[1] }
|
||||
end
|
||||
end
|
||||
|
||||
def accounts_for_local_distribution
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
# role :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# unread_count :integer default(0)
|
||||
#
|
||||
|
||||
class GroupAccount < ApplicationRecord
|
||||
self.ignored_columns = ["unread_count"]
|
||||
enum role: { admin: "admin" }
|
||||
|
||||
belongs_to :group
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# id :bigint(8) not null, primary key
|
||||
# list_id :bigint(8) not null
|
||||
# account_id :bigint(8) not null
|
||||
# follow_id :bigint(8) not null
|
||||
# follow_id :bigint(8) default(1)
|
||||
#
|
||||
|
||||
class ListAccount < ApplicationRecord
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
# group_id :integer
|
||||
# quote_of_id :bigint(8)
|
||||
# revised_at :datetime
|
||||
# markdown :text
|
||||
#
|
||||
|
||||
class Status < ApplicationRecord
|
||||
@@ -266,7 +267,6 @@ class Status < ApplicationRecord
|
||||
|
||||
after_create_commit :store_uri, if: :local?
|
||||
after_create_commit :update_statistics, if: :local?
|
||||
after_create_commit :increase_group_unread_counts, if: Proc.new { |status| !status.group_id.nil? }
|
||||
|
||||
around_create GabSocial::Snowflake::Callbacks
|
||||
|
||||
@@ -553,7 +553,4 @@ class Status < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def increase_group_unread_counts
|
||||
GroupAccount.where(group_id: group_id).where.not(account_id: account_id).update_all("unread_count = unread_count + 1")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user