about summary refs log tree commit diff
path: root/app/presenters
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-04-09 08:47:25 -0400
committerEugen <eugen@zeonfederated.com>2017-04-09 14:47:25 +0200
commite5282e4ec0e9dab62dde9481284b0cfd30690fb9 (patch)
tree9af1aadcf9dc34338c828edb3ed9a9aa265b05e6 /app/presenters
parent53eb31f124b8cb366f45ac0aec36e346115e334f (diff)
Clean up about page (#1282)
* Add InstancePresenter to expose site details

* Clean up about controller, use instance presenter
Diffstat (limited to 'app/presenters')
-rw-r--r--app/presenters/instance_presenter.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/presenters/instance_presenter.rb b/app/presenters/instance_presenter.rb
new file mode 100644
index 000000000..cd809566f
--- /dev/null
+++ b/app/presenters/instance_presenter.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class InstancePresenter
+  delegate(
+    :closed_registrations_message,
+    :contact_email,
+    :open_registrations,
+    :site_description,
+    :site_extended_description,
+    to: Setting
+  )
+
+  def contact_account
+    Account.find_local(Setting.site_contact_username)
+  end
+
+  def user_count
+    Rails.cache.fetch('user_count') { User.count }
+  end
+
+  def status_count
+    Rails.cache.fetch('local_status_count') { Status.local.count }
+  end
+
+  def domain_count
+    Rails.cache.fetch('distinct_domain_count') { Account.distinct.count(:domain) }
+  end
+end