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.
 
 
 
 

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