diff options
author | Matt Jankowski <mjankowski@thoughtbot.com> | 2017-04-13 07:02:02 -0400 |
---|---|---|
committer | Eugen <eugen@zeonfederated.com> | 2017-04-13 13:02:02 +0200 |
commit | 0e39cc6a35661416a1f1ccb8841863f7bf307020 (patch) | |
tree | 7905b859d61ff98ca63a66eb86c50da4834e9c89 /app/models | |
parent | faefd8ec8f164e174fd887f06d01c7fe8ed05531 (diff) |
Settings export refactor (#1646)
* Refactor Export to take an account and know about the export types * Use Export instance in settings/exports#show
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/export.rb | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/app/models/export.rb b/app/models/export.rb index cd1a58eb6..f0d5dd255 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -2,13 +2,43 @@ require 'csv' class Export - attr_reader :accounts + attr_reader :account - def initialize(accounts) - @accounts = accounts + def initialize(account) + @account = account end - def to_csv + 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 + + def total_follows + account.following.count + end + + def total_blocks + account.blocking.count + end + + def total_mutes + account.muting.count + end + + private + + def to_csv(accounts) CSV.generate do |csv| accounts.each do |account| csv << [(account.local? ? account.local_username_and_domain : account.acct)] |