Class: ReportsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#dashboard, #keyboard_tools, #upload

Instance Method Details

#postsObject



19
20
21
22
23
24
25
26
27
# File '/var/apps/qpixel/app/controllers/reports_controller.rb', line 19

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

#posts_globalObject



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

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

#reactionsObject



29
30
31
32
33
# File '/var/apps/qpixel/app/controllers/reports_controller.rb', line 29

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

#subs_globalObject



42
43
44
45
46
# File '/var/apps/qpixel/app/controllers/reports_controller.rb', line 42

def subs_global
  @subs = Subscription.unscoped.recent(1.year.ago)
  @types = Subscription.unscoped.all.group(:type).count
  render :subscriptions
end

#subscriptionsObject



14
15
16
17
# File '/var/apps/qpixel/app/controllers/reports_controller.rb', line 14

def subscriptions
  @subs = Subscription.recent(1.year.ago)
  @types = Subscription.all.group(:type).count
end

#usersObject



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

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

#users_globalObject



35
36
37
38
39
40
# File '/var/apps/qpixel/app/controllers/reports_controller.rb', line 35

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