This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues/pull-requests.
2017-04-11 22:00:43 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'csv'
|
|
|
|
|
|
|
|
class Export
|
2017-04-13 13:02:02 +02:00
|
|
|
attr_reader :account
|
2017-04-11 22:00:43 +02:00
|
|
|
|
2017-04-13 13:02:02 +02:00
|
|
|
def initialize(account)
|
|
|
|
@account = account
|
2017-04-11 22:00:43 +02:00
|
|
|
end
|
|
|
|
|
2017-04-13 13:02:02 +02:00
|
|
|
def to_blocked_accounts_csv
|
|
|
|
to_csv account.blocking
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_muted_accounts_csv
|
|
|
|
to_csv account.muting
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_following_accounts_csv
|
|
|
|
to_csv account.following
|
|
|
|
end
|
|
|
|
|
|
|
|
def total_storage
|
|
|
|
account.media_attachments.sum(:file_file_size)
|
|
|
|
end
|
|
|
|
|
2018-08-14 21:56:17 +02:00
|
|
|
def total_statuses
|
|
|
|
account.statuses_count
|
|
|
|
end
|
|
|
|
|
2017-04-13 13:02:02 +02:00
|
|
|
def total_follows
|
2018-08-14 21:56:17 +02:00
|
|
|
account.following_count
|
|
|
|
end
|
|
|
|
|
|
|
|
def total_followers
|
|
|
|
account.followers_count
|
2017-04-13 13:02:02 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def total_blocks
|
|
|
|
account.blocking.count
|
|
|
|
end
|
|
|
|
|
|
|
|
def total_mutes
|
|
|
|
account.muting.count
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def to_csv(accounts)
|
2017-04-11 22:00:43 +02:00
|
|
|
CSV.generate do |csv|
|
|
|
|
accounts.each do |account|
|
|
|
|
csv << [(account.local? ? account.local_username_and_domain : account.acct)]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|