Merge remote-tracking branch 'parent/main' into upstream-20241107
This commit is contained in:
commit
a003c2db89
98 changed files with 2002 additions and 590 deletions
15
app/models/annual_report/statuses_per_account_count.rb
Normal file
15
app/models/annual_report/statuses_per_account_count.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: annual_report_statuses_per_account_counts
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# year :integer not null
|
||||
# account_id :bigint(8) not null
|
||||
# statuses_count :bigint(8) not null
|
||||
#
|
||||
|
||||
class AnnualReport::StatusesPerAccountCount < ApplicationRecord
|
||||
# This table facilitates percentile calculations
|
||||
end
|
|
@ -44,8 +44,16 @@ class FeaturedTag < ApplicationRecord
|
|||
update(statuses_count: statuses_count + 1, last_status_at: timestamp)
|
||||
end
|
||||
|
||||
def decrement(deleted_status_id)
|
||||
update(statuses_count: [0, statuses_count - 1].max, last_status_at: visible_tagged_account_statuses.where.not(id: deleted_status_id).pick(:created_at))
|
||||
def decrement(deleted_status)
|
||||
if statuses_count <= 1
|
||||
update(statuses_count: 0, last_status_at: nil)
|
||||
elsif last_status_at > deleted_status.created_at
|
||||
update(statuses_count: statuses_count - 1)
|
||||
else
|
||||
# Fetching the latest status creation time can be expensive, so only perform it
|
||||
# if we know we are deleting the latest status using this tag
|
||||
update(statuses_count: statuses_count - 1, last_status_at: visible_tagged_account_statuses.where(id: ...deleted_status.id).pick(:created_at))
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -83,6 +83,9 @@ class Notification < ApplicationRecord
|
|||
moderation_warning: {
|
||||
filterable: false,
|
||||
}.freeze,
|
||||
annual_report: {
|
||||
filterable: false,
|
||||
}.freeze,
|
||||
'admin.sign_up': {
|
||||
filterable: false,
|
||||
}.freeze,
|
||||
|
@ -124,6 +127,7 @@ class Notification < ApplicationRecord
|
|||
belongs_to :report, inverse_of: false
|
||||
belongs_to :account_warning, inverse_of: false
|
||||
belongs_to :account_relationship_severance_event, inverse_of: false
|
||||
belongs_to :generated_annual_report, inverse_of: false
|
||||
end
|
||||
|
||||
validates :type, inclusion: { in: TYPES }
|
||||
|
@ -344,7 +348,7 @@ class Notification < ApplicationRecord
|
|||
self.from_account_id = activity&.status&.account_id
|
||||
when 'Account'
|
||||
self.from_account_id = activity&.id
|
||||
when 'AccountRelationshipSeveranceEvent', 'AccountWarning'
|
||||
when 'AccountRelationshipSeveranceEvent', 'AccountWarning', 'GeneratedAnnualReport'
|
||||
# These do not really have an originating account, but this is mandatory
|
||||
# in the data model, and the recipient's account will by definition
|
||||
# always exist
|
||||
|
|
|
@ -67,6 +67,7 @@ class NotificationGroup < ActiveModelSerializers::Model
|
|||
:report,
|
||||
:account_relationship_severance_event,
|
||||
:account_warning,
|
||||
:generated_annual_report,
|
||||
to: :notification, prefix: false
|
||||
|
||||
def self.convert_emoji_reaction_pair(activity_ids)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue