Class: Decidim::Admin::ModerationStats

Inherits:
Object
  • Object
show all
Defined in:
app/queries/decidim/admin/moderation_stats.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ ModerationStats

Returns a new instance of ModerationStats.



6
7
8
# File 'app/queries/decidim/admin/moderation_stats.rb', line 6

def initialize(user)
  @user = user
end

Instance Method Details

#content_moderationsObject



10
11
12
# File 'app/queries/decidim/admin/moderation_stats.rb', line 10

def content_moderations
  @content_moderations ||= Decidim::Moderation.where(participatory_space: spaces_user_is_admin_to)
end

#count_content_moderationsObject



18
19
20
# File 'app/queries/decidim/admin/moderation_stats.rb', line 18

def count_content_moderations
  content_moderations.not_hidden.count
end

#count_pending_moderationsObject



26
27
28
# File 'app/queries/decidim/admin/moderation_stats.rb', line 26

def count_pending_moderations
  count_content_moderations + count_user_pending_reports
end

#count_user_pending_reportsObject



22
23
24
# File 'app/queries/decidim/admin/moderation_stats.rb', line 22

def count_user_pending_reports
  user_reports.unblocked.count
end

#user_reportsObject



14
15
16
# File 'app/queries/decidim/admin/moderation_stats.rb', line 14

def user_reports
  @user_reports ||= UserModeration.joins(:user).where(decidim_users: { decidim_organization_id: user.decidim_organization_id })
end