add ability to export followers

staging
multiple creatures 2019-07-15 13:10:50 -05:00
parent 29643fd6c4
commit 0a5eba734e
4 changed files with 29 additions and 1 deletions

View File

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

View File

@ -29,6 +29,14 @@ class Export
end
end
def to_followers_accounts_csv
CSV.generate(headers: ['Account address'], write_headers: true) do |csv|
account.followers.find_each do |follow|
csv << [acct(follow)]
end
end
end
def to_lists_csv
CSV.generate do |csv|
account.owned_lists.select(:title, :id).each do |list|

View File

@ -23,7 +23,7 @@
%tr
%th= t('accounts.followers', count: @export.total_followers)
%td= number_with_delimiter @export.total_followers
%td
%td= table_link_to 'download', t('exports.csv'), settings_exports_followers_path(format: :csv)
%tr
%th= t('exports.blocks')
%td= number_with_delimiter @export.total_blocks

View File

@ -98,6 +98,7 @@ Rails.application.routes.draw do
resource :export, only: [:show, :create]
namespace :exports, constraints: { format: :csv } do
resources :follows, only: :index, controller: :following_accounts
resources :followers, only: :index, controller: :followers_accounts
resources :blocks, only: :index, controller: :blocked_accounts
resources :mutes, only: :index, controller: :muted_accounts
resources :lists, only: :index, controller: :lists