Class: UsersStatistics

Inherits:
ApplicationRecord show all
Defined in:
app/models/users_statistics.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Class Method Details

.create_current_stats!Object


29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/users_statistics.rb', line 29

def create_current_stats!
  stats_by_role = highest_role_stats

  create!(
    without_groups_and_projects: without_groups_and_projects_stats,
    with_highest_role_guest: stats_by_role[:guest],
    with_highest_role_reporter: stats_by_role[:reporter],
    with_highest_role_developer: stats_by_role[:developer],
    with_highest_role_maintainer: stats_by_role[:maintainer],
    with_highest_role_owner: stats_by_role[:owner],
    bots: bot_stats,
    blocked: blocked_stats
  )
end

.latestObject


7
8
9
# File 'app/models/users_statistics.rb', line 7

def latest
  order_created_at_desc.first
end

Instance Method Details

#activeObject


12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/users_statistics.rb', line 12

def active
  [
    without_groups_and_projects,
    with_highest_role_guest,
    with_highest_role_reporter,
    with_highest_role_developer,
    with_highest_role_maintainer,
    with_highest_role_owner,
    bots
  ].sum
end

#totalObject


24
25
26
# File 'app/models/users_statistics.rb', line 24

def total
  active + blocked
end