Add export of account subscribe

This commit is contained in:
noellabo 2023-01-20 14:08:02 +09:00
parent 2ac7e727f7
commit 7a53fefe8c
7 changed files with 41 additions and 3 deletions

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
module Settings
module Exports
class AccountSubscribingsController < BaseController
include ExportControllerConcern
def index
send_export_file
end
private
def export_data
@export.to_subscribing_accounts_csv
end
end
end
end

View file

@ -30,9 +30,17 @@ class Export
end
def to_following_accounts_csv
CSV.generate(headers: ['Account address', 'Show boosts'], write_headers: true) do |csv|
CSV.generate(headers: ['Account address', 'Show boosts', 'Notify on new posts', 'Languages', 'Delivery to home'], write_headers: true) do |csv|
account.active_relationships.includes(:target_account).reorder(id: :desc).each do |follow|
csv << [acct(follow.target_account), follow.show_reblogs]
csv << [acct(follow.target_account), follow.show_reblogs, follow.notify, follow.languages&.join(', '), follow.delivery]
end
end
end
def to_subscribing_accounts_csv
CSV.generate(headers: ['Account address', 'List', 'Show boosts', 'Media only'], write_headers: true) do |csv|
account.active_subscribes.includes(:target_account, :list).references(:list).reorder(id: :desc).each do |subscribe|
csv << [acct(subscribe.target_account), subscribe.list&.title, subscribe.show_reblogs, subscribe.media_only]
end
end
end
@ -71,7 +79,7 @@ class Export
account.following_count
end
def total_subscribes
def total_subscribings
account.subscribing_count
end

View file

@ -40,6 +40,10 @@ class Follow < ApplicationRecord
destroy!
end
def languages
nil
end
before_validation :set_uri, only: :create
after_create :increment_cache_counters
after_create :invalidate_hash_cache

View file

@ -16,6 +16,10 @@
%th= t('admin.accounts.follows')
%td= number_with_delimiter @export.total_follows
%td= table_link_to 'download', t('exports.csv'), settings_exports_follows_path(format: :csv)
%tr
%th= t('admin.accounts.subscribes')
%td= number_with_delimiter @export.total_subscribings
%td= table_link_to 'download', t('exports.csv'), settings_exports_account_subscribings_path(format: :csv)
%tr
%th= t('exports.lists')
%td= number_with_delimiter @export.total_lists

View file

@ -218,6 +218,7 @@ en:
silenced: Limited
statuses: Posts
subscribe: Subscribe
subscribes: Subscribes
suspended: Suspended
suspension_irreversible: The data of this account has been irreversibly deleted. You can unsuspend the account to make it usable but it will not recover any data it previously had.
suspension_reversible_hint_html: The account has been suspended, and the data will be fully removed on %{date}. Until then, the account can be restored without any ill effects. If you wish to remove all of the account's data immediately, you can do so below.

View file

@ -207,6 +207,7 @@ ja:
silenced: サイレンス済み
statuses: 投稿数
subscribe: 購読する
subscribes: 購読
suspended: 停止済み
suspension_irreversible: このアカウントのデータは削除され元に戻せなくなります。後日アカウントの凍結を解除することはできますがデータは元に戻せません。
suspension_reversible_hint_html: アカウントは停止されており、データは %{date} に完全に削除されます。それまではアカウントを元に戻すことができます。今すぐ完全に削除したい場合は以下から行うことができます。

View file

@ -128,6 +128,7 @@ Rails.application.routes.draw do
resources :lists, only: :index, controller: :lists
resources :domain_blocks, only: :index, controller: :blocked_domains
resources :bookmarks, only: :index, controller: :bookmarks
resources :account_subscribings, only: :index, controller: :account_subscribings
end
resources :two_factor_authentication_methods, only: [:index] do