]> cat aescling's git repositories - mastodon.git/blob - app/presenters/instance_presenter.rb
f3a73209afe56658c78372d3f2b272e5fbcdd10b
[mastodon.git] / app / presenters / instance_presenter.rb
1 # frozen_string_literal: true
2
3 class InstancePresenter
4 delegate(
5 :site_contact_email,
6 :site_title,
7 :site_short_description,
8 :site_description,
9 :site_extended_description,
10 :site_terms,
11 :closed_registrations_message,
12 to: Setting
13 )
14
15 def contact_account
16 Account.find_local(Setting.site_contact_username.strip.gsub(/\A@/, ''))
17 end
18
19 def user_count
20 Rails.cache.fetch('user_count') { User.confirmed.joins(:account).merge(Account.without_suspended).count }
21 end
22
23 def active_user_count
24 Rails.cache.fetch('active_user_count') { Redis.current.pfcount(*(0..3).map { |i| "activity:logins:#{i.weeks.ago.utc.to_date.cweek}" }) }
25 end
26
27 def status_count
28 Rails.cache.fetch('local_status_count') { Account.local.joins(:account_stat).sum('account_stats.statuses_count') }.to_i
29 end
30
31 def domain_count
32 Rails.cache.fetch('distinct_domain_count') { Account.distinct.count(:domain) }
33 end
34
35 def sample_accounts
36 Rails.cache.fetch('sample_accounts', expires_in: 12.hours) { Account.discoverable.popular.limit(3) }
37 end
38
39 def version_number
40 Mastodon::Version
41 end
42
43 def source_url
44 Mastodon::Version.source_url
45 end
46
47 def thumbnail
48 @thumbnail ||= Rails.cache.fetch('site_uploads/thumbnail') { SiteUpload.find_by(var: 'thumbnail') }
49 end
50
51 def hero
52 @hero ||= Rails.cache.fetch('site_uploads/hero') { SiteUpload.find_by(var: 'hero') }
53 end
54
55 def mascot
56 @mascot ||= Rails.cache.fetch('site_uploads/mascot') { SiteUpload.find_by(var: 'mascot') }
57 end
58 end
This page took 0.086802 seconds and 3 git commands to generate.