Module: SettingsHelper

Defined in:
app/helpers/settings_helper.rb

Instance Method Summary collapse

Instance Method Details

#collection_count ⇒ Object



28
29
30
# File 'app/helpers/settings_helper.rb', line 28

def collection_count
  policy_scope(Collection).local.count
end

#creator_count ⇒ Object



24
25
26
# File 'app/helpers/settings_helper.rb', line 24

def creator_count
  policy_scope(Creator).local.count
end

#masked_email(email) ⇒ Object



2
3
4
# File 'app/helpers/settings_helper.rb', line 2

def masked_email(email)
  email.gsub(/(?<=^.)[^@]*|(?<=@.).*(?=\.[^.]+$)/, "****")
end

#model_count(library: nil) ⇒ Object



6
7
8
9
10
# File 'app/helpers/settings_helper.rb', line 6

def model_count(library: nil)
  scope = policy_scope(Model)
  scope = scope.where(library: library) if library
  scope.count
end

#model_file_count(library: nil) ⇒ Object



12
13
14
15
16
# File 'app/helpers/settings_helper.rb', line 12

def model_file_count(library: nil)
  scope = policy_scope(ModelFile)
  scope = scope.includes(:model).where("models.library": library) if library
  scope.count
end

#tag_count ⇒ Object



32
33
34
# File 'app/helpers/settings_helper.rb', line 32

def tag_count
  policy_scope(ActsAsTaggableOn::Tag).count
end

#total_file_size(library: nil) ⇒ Object



18
19
20
21
22
# File 'app/helpers/settings_helper.rb', line 18

def total_file_size(library: nil)
  scope = policy_scope(ModelFile)
  scope = scope.includes(:model).where("models.library": library) if library
  scope.sum(:size)
end

#user_count ⇒ Object



36
37
38
# File 'app/helpers/settings_helper.rb', line 36

def user_count
  policy_scope(User).count
end