The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

58 lines
1.5 KiB

  1. # frozen_string_literal: true
  2. class InstancePresenter
  3. delegate(
  4. :site_contact_email,
  5. :site_title,
  6. :site_short_description,
  7. :site_description,
  8. :site_extended_description,
  9. :site_terms,
  10. to: Setting
  11. )
  12. def contact_account
  13. Account.find_local(Setting.site_contact_username.gsub(/\A@/, ''))
  14. end
  15. def user_count
  16. Rails.cache.fetch('user_count') { User.confirmed.joins(:account).merge(Account.without_suspended).count }
  17. end
  18. def active_user_count
  19. Rails.cache.fetch('active_user_count') { Redis.current.pfcount(*(0..3).map { |i| "activity:logins:#{i.weeks.ago.utc.to_date.cweek}" }) }
  20. end
  21. def status_count
  22. Rails.cache.fetch('local_status_count') { Account.local.joins(:account_stat).sum('account_stats.statuses_count') }.to_i
  23. end
  24. def domain_count
  25. Rails.cache.fetch('distinct_domain_count') { Account.distinct.count(:domain) }
  26. end
  27. def sample_accounts
  28. Rails.cache.fetch('sample_accounts', expires_in: 12.hours) { Account.discoverable.popular.limit(3) }
  29. end
  30. def version_number
  31. Mastodon::Version
  32. end
  33. def source_url
  34. Mastodon::Version.source_url
  35. end
  36. def thumbnail
  37. @thumbnail ||= Rails.cache.fetch('site_uploads/thumbnail') { SiteUpload.find_by(var: 'thumbnail') }
  38. end
  39. def hero
  40. @hero ||= Rails.cache.fetch('site_uploads/hero') { SiteUpload.find_by(var: 'hero') }
  41. end
  42. def mascot
  43. @mascot ||= Rails.cache.fetch('site_uploads/mascot') { SiteUpload.find_by(var: 'mascot') }
  44. end
  45. end