You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/controllers/tidings_controller.rb

32 lines
1.0 KiB

6 years ago
class TidingsController < ApplicationController
include PaginateHelper
after_action :update_onclick_time!, only: [:index]
6 years ago
def index
tidings = current_user.tidings
6 years ago
tiding_types =
case params[:type]
when 'notice' then 'System'
when 'apply' then 'Apply'
when 'course' then %w(HomeworkCommon Exercise Poll GraduationTask GraduationTopic)
6 years ago
when 'project' then 'Project'
when 'interaction' then %w(Comment Mentioned Praise Fan)
when 'project_package' then %w(Created Destroyed Bidding BiddingEnd BiddingWon BiddingLost)
6 years ago
end
tidings = tidings.where(tiding_type: tiding_types) if tiding_types.present?
tidings = tidings.where(container_type: 'ProjectPackage') if params[:type] == 'project_package'
6 years ago
@count = tidings.count
@tidings = paginate(tidings.order(created_at: :desc), per_page: 10)
@onclick_time = current_user.click_time
end
private
def update_onclick_time!
current_user.onclick_time.touch(:onclick_time)
6 years ago
end
end