Add a confirmation screen when suspending a domain (#25144)
This commit is contained in:
		@@ -16,7 +16,9 @@ class Admin::Metrics::Measure::InstanceAccountsMeasure < Admin::Metrics::Measure
 | 
			
		||||
  protected
 | 
			
		||||
 | 
			
		||||
  def perform_total_query
 | 
			
		||||
    Account.where(domain: params[:domain]).count
 | 
			
		||||
    domain = params[:domain]
 | 
			
		||||
    domain = Instance.by_domain_and_subdomains(params[:domain]).select(:domain) if params[:include_subdomains]
 | 
			
		||||
    Account.where(domain: domain).count
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_previous_total_query
 | 
			
		||||
@@ -24,13 +26,21 @@ class Admin::Metrics::Measure::InstanceAccountsMeasure < Admin::Metrics::Measure
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_data_query
 | 
			
		||||
    account_matching_sql = begin
 | 
			
		||||
      if params[:include_subdomains]
 | 
			
		||||
        "accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $3::text))"
 | 
			
		||||
      else
 | 
			
		||||
        'accounts.domain = $3::text'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sql = <<-SQL.squish
 | 
			
		||||
      SELECT axis.*, (
 | 
			
		||||
        WITH new_accounts AS (
 | 
			
		||||
          SELECT accounts.id
 | 
			
		||||
          FROM accounts
 | 
			
		||||
          WHERE date_trunc('day', accounts.created_at)::date = axis.period
 | 
			
		||||
            AND accounts.domain = $3::text
 | 
			
		||||
            AND #{account_matching_sql}
 | 
			
		||||
        )
 | 
			
		||||
        SELECT count(*) FROM new_accounts
 | 
			
		||||
      ) AS value
 | 
			
		||||
@@ -53,6 +63,6 @@ class Admin::Metrics::Measure::InstanceAccountsMeasure < Admin::Metrics::Measure
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def params
 | 
			
		||||
    @params.permit(:domain)
 | 
			
		||||
    @params.permit(:domain, :include_subdomains)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,9 @@ class Admin::Metrics::Measure::InstanceFollowersMeasure < Admin::Metrics::Measur
 | 
			
		||||
  protected
 | 
			
		||||
 | 
			
		||||
  def perform_total_query
 | 
			
		||||
    Follow.joins(:account).merge(Account.where(domain: params[:domain])).count
 | 
			
		||||
    domain = params[:domain]
 | 
			
		||||
    domain = Instance.by_domain_and_subdomains(params[:domain]).select(:domain) if params[:include_subdomains]
 | 
			
		||||
    Follow.joins(:account).merge(Account.where(domain: domain)).count
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_previous_total_query
 | 
			
		||||
@@ -24,6 +26,14 @@ class Admin::Metrics::Measure::InstanceFollowersMeasure < Admin::Metrics::Measur
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_data_query
 | 
			
		||||
    account_matching_sql = begin
 | 
			
		||||
      if params[:include_subdomains]
 | 
			
		||||
        "accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $3::text))"
 | 
			
		||||
      else
 | 
			
		||||
        'accounts.domain = $3::text'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sql = <<-SQL.squish
 | 
			
		||||
      SELECT axis.*, (
 | 
			
		||||
        WITH new_followers AS (
 | 
			
		||||
@@ -31,7 +41,7 @@ class Admin::Metrics::Measure::InstanceFollowersMeasure < Admin::Metrics::Measur
 | 
			
		||||
          FROM follows
 | 
			
		||||
          INNER JOIN accounts ON follows.account_id = accounts.id
 | 
			
		||||
          WHERE date_trunc('day', follows.created_at)::date = axis.period
 | 
			
		||||
            AND accounts.domain = $3::text
 | 
			
		||||
            AND #{account_matching_sql}
 | 
			
		||||
        )
 | 
			
		||||
        SELECT count(*) FROM new_followers
 | 
			
		||||
      ) AS value
 | 
			
		||||
@@ -54,6 +64,6 @@ class Admin::Metrics::Measure::InstanceFollowersMeasure < Admin::Metrics::Measur
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def params
 | 
			
		||||
    @params.permit(:domain)
 | 
			
		||||
    @params.permit(:domain, :include_subdomains)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,9 @@ class Admin::Metrics::Measure::InstanceFollowsMeasure < Admin::Metrics::Measure:
 | 
			
		||||
  protected
 | 
			
		||||
 | 
			
		||||
  def perform_total_query
 | 
			
		||||
    Follow.joins(:target_account).merge(Account.where(domain: params[:domain])).count
 | 
			
		||||
    domain = params[:domain]
 | 
			
		||||
    domain = Instance.by_domain_and_subdomains(params[:domain]).select(:domain) if params[:include_subdomains]
 | 
			
		||||
    Follow.joins(:target_account).merge(Account.where(domain: domain)).count
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_previous_total_query
 | 
			
		||||
@@ -24,6 +26,14 @@ class Admin::Metrics::Measure::InstanceFollowsMeasure < Admin::Metrics::Measure:
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_data_query
 | 
			
		||||
    account_matching_sql = begin
 | 
			
		||||
      if params[:include_subdomains]
 | 
			
		||||
        "accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $3::text))"
 | 
			
		||||
      else
 | 
			
		||||
        'accounts.domain = $3::text'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sql = <<-SQL.squish
 | 
			
		||||
      SELECT axis.*, (
 | 
			
		||||
        WITH new_follows AS (
 | 
			
		||||
@@ -31,7 +41,7 @@ class Admin::Metrics::Measure::InstanceFollowsMeasure < Admin::Metrics::Measure:
 | 
			
		||||
          FROM follows
 | 
			
		||||
          INNER JOIN accounts ON follows.target_account_id = accounts.id
 | 
			
		||||
          WHERE date_trunc('day', follows.created_at)::date = axis.period
 | 
			
		||||
            AND accounts.domain = $3::text
 | 
			
		||||
            AND #{account_matching_sql}
 | 
			
		||||
        )
 | 
			
		||||
        SELECT count(*) FROM new_follows
 | 
			
		||||
      ) AS value
 | 
			
		||||
@@ -54,6 +64,6 @@ class Admin::Metrics::Measure::InstanceFollowsMeasure < Admin::Metrics::Measure:
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def params
 | 
			
		||||
    @params.permit(:domain)
 | 
			
		||||
    @params.permit(:domain, :include_subdomains)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,9 @@ class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics:
 | 
			
		||||
  protected
 | 
			
		||||
 | 
			
		||||
  def perform_total_query
 | 
			
		||||
    MediaAttachment.joins(:account).merge(Account.where(domain: params[:domain])).sum('COALESCE(file_file_size, 0) + COALESCE(thumbnail_file_size, 0)')
 | 
			
		||||
    domain = params[:domain]
 | 
			
		||||
    domain = Instance.by_domain_and_subdomains(params[:domain]).select(:domain) if params[:include_subdomains]
 | 
			
		||||
    MediaAttachment.joins(:account).merge(Account.where(domain: domain)).sum('COALESCE(file_file_size, 0) + COALESCE(thumbnail_file_size, 0)')
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_previous_total_query
 | 
			
		||||
@@ -34,6 +36,14 @@ class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics:
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_data_query
 | 
			
		||||
    account_matching_sql = begin
 | 
			
		||||
      if params[:include_subdomains]
 | 
			
		||||
        "accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $3::text))"
 | 
			
		||||
      else
 | 
			
		||||
        'accounts.domain = $3::text'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sql = <<-SQL.squish
 | 
			
		||||
      SELECT axis.*, (
 | 
			
		||||
        WITH new_media_attachments AS (
 | 
			
		||||
@@ -41,7 +51,7 @@ class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics:
 | 
			
		||||
          FROM media_attachments
 | 
			
		||||
          INNER JOIN accounts ON accounts.id = media_attachments.account_id
 | 
			
		||||
          WHERE date_trunc('day', media_attachments.created_at)::date = axis.period
 | 
			
		||||
            AND accounts.domain = $3::text
 | 
			
		||||
            AND #{account_matching_sql}
 | 
			
		||||
        )
 | 
			
		||||
        SELECT SUM(size) FROM new_media_attachments
 | 
			
		||||
      ) AS value
 | 
			
		||||
@@ -64,6 +74,6 @@ class Admin::Metrics::Measure::InstanceMediaAttachmentsMeasure < Admin::Metrics:
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def params
 | 
			
		||||
    @params.permit(:domain)
 | 
			
		||||
    @params.permit(:domain, :include_subdomains)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,9 @@ class Admin::Metrics::Measure::InstanceReportsMeasure < Admin::Metrics::Measure:
 | 
			
		||||
  protected
 | 
			
		||||
 | 
			
		||||
  def perform_total_query
 | 
			
		||||
    Report.where(target_account: Account.where(domain: params[:domain])).count
 | 
			
		||||
    domain = params[:domain]
 | 
			
		||||
    domain = Instance.by_domain_and_subdomains(params[:domain]).select(:domain) if params[:include_subdomains]
 | 
			
		||||
    Report.where(target_account: Account.where(domain: domain)).count
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_previous_total_query
 | 
			
		||||
@@ -24,6 +26,14 @@ class Admin::Metrics::Measure::InstanceReportsMeasure < Admin::Metrics::Measure:
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_data_query
 | 
			
		||||
    account_matching_sql = begin
 | 
			
		||||
      if params[:include_subdomains]
 | 
			
		||||
        "accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $3::text))"
 | 
			
		||||
      else
 | 
			
		||||
        'accounts.domain = $3::text'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sql = <<-SQL.squish
 | 
			
		||||
      SELECT axis.*, (
 | 
			
		||||
        WITH new_reports AS (
 | 
			
		||||
@@ -31,7 +41,7 @@ class Admin::Metrics::Measure::InstanceReportsMeasure < Admin::Metrics::Measure:
 | 
			
		||||
          FROM reports
 | 
			
		||||
          INNER JOIN accounts ON accounts.id = reports.target_account_id
 | 
			
		||||
          WHERE date_trunc('day', reports.created_at)::date = axis.period
 | 
			
		||||
            AND accounts.domain = $3::text
 | 
			
		||||
            AND #{account_matching_sql}
 | 
			
		||||
        )
 | 
			
		||||
        SELECT count(*) FROM new_reports
 | 
			
		||||
      ) AS value
 | 
			
		||||
@@ -54,6 +64,6 @@ class Admin::Metrics::Measure::InstanceReportsMeasure < Admin::Metrics::Measure:
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def params
 | 
			
		||||
    @params.permit(:domain)
 | 
			
		||||
    @params.permit(:domain, :include_subdomains)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,9 @@ class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure
 | 
			
		||||
  protected
 | 
			
		||||
 | 
			
		||||
  def perform_total_query
 | 
			
		||||
    Status.joins(:account).merge(Account.where(domain: params[:domain])).count
 | 
			
		||||
    domain = params[:domain]
 | 
			
		||||
    domain = Instance.by_domain_and_subdomains(params[:domain]).select(:domain) if params[:include_subdomains]
 | 
			
		||||
    Status.joins(:account).merge(Account.where(domain: domain)).count
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_previous_total_query
 | 
			
		||||
@@ -24,6 +26,14 @@ class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def perform_data_query
 | 
			
		||||
    account_matching_sql = begin
 | 
			
		||||
      if params[:include_subdomains]
 | 
			
		||||
        "accounts.domain IN (SELECT domain FROM instances WHERE reverse('.' || domain) LIKE reverse('.' || $5::text))"
 | 
			
		||||
      else
 | 
			
		||||
        'accounts.domain = $5::text'
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sql = <<-SQL.squish
 | 
			
		||||
      SELECT axis.*, (
 | 
			
		||||
        WITH new_statuses AS (
 | 
			
		||||
@@ -31,7 +41,7 @@ class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure
 | 
			
		||||
          FROM statuses
 | 
			
		||||
          INNER JOIN accounts ON accounts.id = statuses.account_id
 | 
			
		||||
          WHERE statuses.id BETWEEN $3 AND $4
 | 
			
		||||
            AND accounts.domain = $5::text
 | 
			
		||||
            AND #{account_matching_sql}
 | 
			
		||||
            AND date_trunc('day', statuses.created_at)::date = axis.period
 | 
			
		||||
        )
 | 
			
		||||
        SELECT count(*) FROM new_statuses
 | 
			
		||||
@@ -55,6 +65,6 @@ class Admin::Metrics::Measure::InstanceStatusesMeasure < Admin::Metrics::Measure
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def params
 | 
			
		||||
    @params.permit(:domain)
 | 
			
		||||
    @params.permit(:domain, :include_subdomains)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user