Class: ReportsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/reports_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#dashboard, #keyboard_tools, #upload

Instance Method Details

#postsObject



18
19
20
21
22
23
24
25
26
# File 'app/controllers/reports_controller.rb', line 18

def posts
  @questions = Question.where('created_at >= ?', 1.year.ago).undeleted
  @answers = Answer.where('created_at >= ?', 1.year.ago).undeleted
  @comments = Comment.where('created_at >= ?', 1.year.ago).undeleted
  @this_month = Post.where('created_at >= ?', 1.month.ago).undeleted
  @categories = Category.where('IFNULL(categories.min_view_trust_level, 0) <= ?', current_user&.trust_level || 0)
                        .order(:sequence)
  @posts_categories = Post.where(category: @categories).group(:category_id).count
end

#posts_globalObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/reports_controller.rb', line 47

def posts_global
  @questions = Post.unscoped.where(post_type_id: Question.post_type_id).where('created_at >= ?', 1.year.ago).undeleted
  @answers = Post.unscoped.where(post_type_id: Answer.post_type_id).where('created_at >= ?', 1.year.ago).undeleted
  @comments = Comment.unscoped.where('created_at >= ?', 1.year.ago).undeleted
  @this_month = Post.unscoped.where('created_at >= ?', 1.month.ago).undeleted
  @categories = Category.unscoped
                        .where('IFNULL(categories.min_view_trust_level, 0) <= ?', current_user&.trust_level || 0)
                        .includes(:community).order(:community_id, :sequence)
  @posts_categories = Post.unscoped.where(category: @categories).group(:category_id).count
  @global = true
  render :posts
end

#reactionsObject



28
29
30
31
32
# File 'app/controllers/reports_controller.rb', line 28

def reactions
  @reaction_types = ReactionType.active
  @reactions = Reaction.all
  @users = Reaction.select(:user_id).distinct
end

#subs_globalObject



41
42
43
44
45
# File 'app/controllers/reports_controller.rb', line 41

def subs_global
  @subs = Subscription.unscoped.where('created_at >= ?', 1.year.ago)
  @types = Subscription.unscoped.all.group(:type).count
  render :subscriptions
end

#subscriptionsObject



13
14
15
16
# File 'app/controllers/reports_controller.rb', line 13

def subscriptions
  @subs = Subscription.where('created_at >= ?', 1.year.ago)
  @types = Subscription.all.group(:type).count
end

#usersObject



6
7
8
9
10
11
# File 'app/controllers/reports_controller.rb', line 6

def users
  @users_all = User.joins(:community_users).where(community_users: { community_id: RequestContext.community_id })
                   .where('users.created_at >= ?', 1.year.ago)
  @users = @users_all.where("users.email NOT LIKE '%localhost'")
  @users_se = @users_all.where("users.email LIKE '%localhost'")
end

#users_globalObject



34
35
36
37
38
39
# File 'app/controllers/reports_controller.rb', line 34

def users_global
  @users_all = User.where('users.created_at >= ?', 1.year.ago)
  @users = @users_all.where("users.email NOT LIKE '%localhost'")
  @users_se = @users_all.where("users.email LIKE '%localhost'")
  render :users
end