Change AccountRelationshipSeveranceEvent
model to store lost followers and following counts separately (#29714)
This commit is contained in:
parent
34f293475e
commit
dfa43707eb
7 changed files with 30 additions and 8 deletions
|
@ -35,7 +35,7 @@ const RelationshipsSeveranceEvent = ({ event, hidden }) => {
|
|||
<FormattedMessage
|
||||
id='relationship_severance_notification.relationships'
|
||||
defaultMessage='{count, plural, one {# relationship} other {# relationships}}'
|
||||
values={{ count: event.get('relationships_count', 0) }}
|
||||
values={{ count: event.get('followers_count', 0) + event.get('following_count', 0) }}
|
||||
/>
|
||||
)}
|
||||
<br />
|
||||
|
|
|
@ -8,11 +8,16 @@
|
|||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8) not null
|
||||
# relationship_severance_event_id :bigint(8) not null
|
||||
# relationships_count :integer default(0), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# followers_count :integer default(0), not null
|
||||
# following_count :integer default(0), not null
|
||||
#
|
||||
class AccountRelationshipSeveranceEvent < ApplicationRecord
|
||||
self.ignored_columns += %w(
|
||||
relationships_count
|
||||
)
|
||||
|
||||
belongs_to :account
|
||||
belongs_to :relationship_severance_event
|
||||
|
||||
|
@ -30,6 +35,7 @@ class AccountRelationshipSeveranceEvent < ApplicationRecord
|
|||
private
|
||||
|
||||
def set_relationships_count!
|
||||
self.relationships_count = severed_relationships.about_local_account(account).count
|
||||
self.followers_count = severed_relationships.about_local_account(account).passive.count
|
||||
self.following_count = severed_relationships.about_local_account(account).active.count
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class REST::AccountRelationshipSeveranceEventSerializer < ActiveModel::Serializer
|
||||
attributes :id, :type, :purged, :target_name, :created_at
|
||||
attributes :id, :type, :purged, :target_name, :followers_count, :following_count, :created_at
|
||||
|
||||
def id
|
||||
object.id.to_s
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
%td{ rowspan: 2 }= t('severed_relationships.purged')
|
||||
- else
|
||||
%td
|
||||
- count = event.severed_relationships.active.about_local_account(current_account).count
|
||||
- count = event.following_count
|
||||
- if count.zero?
|
||||
= t('generic.none')
|
||||
- else
|
||||
= table_link_to 'download', t('severed_relationships.download', count: count), following_severed_relationship_path(event, format: :csv)
|
||||
%td
|
||||
- count = event.severed_relationships.passive.about_local_account(current_account).count
|
||||
- count = event.followers_count
|
||||
- if count.zero?
|
||||
= t('generic.none')
|
||||
- else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue