about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-07-15 13:10:50 -0500
committermultiple creatures <dev@multiple-creature.party>2019-07-15 14:12:21 -0500
commit0a5eba734e6aa6a6e7e8f64b022af8ea129c9f5d (patch)
treee6c0c0e6d54e03eecb22af00ba3ec5af1ac71fc2 /app
parent29643fd6c42bcee5a1d6a4a137256b33996c60f2 (diff)
add ability to export followers
Diffstat (limited to 'app')
-rw-r--r--app/controllers/settings/exports/followers_accounts_controller.rb19
-rw-r--r--app/models/export.rb8
-rw-r--r--app/views/settings/exports/show.html.haml2
3 files changed, 28 insertions, 1 deletions
diff --git a/app/controllers/settings/exports/followers_accounts_controller.rb b/app/controllers/settings/exports/followers_accounts_controller.rb
new file mode 100644
index 000000000..5ed5d6160
--- /dev/null
+++ b/app/controllers/settings/exports/followers_accounts_controller.rb
@@ -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
diff --git a/app/models/export.rb b/app/models/export.rb
index cab01f11a..fed41310d 100644
--- a/app/models/export.rb
+++ b/app/models/export.rb
@@ -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|
diff --git a/app/views/settings/exports/show.html.haml b/app/views/settings/exports/show.html.haml
index b13cea976..455df1c2d 100644
--- a/app/views/settings/exports/show.html.haml
+++ b/app/views/settings/exports/show.html.haml
@@ -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