From 861cf7d7b2218e98baac8601d8603de0f62a0a31 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 26 Nov 2019 14:02:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=9A=84=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/tidings_controller.rb | 5 ++++- app/views/tidings/index.json.jbuilder | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/tidings_controller.rb b/app/controllers/tidings_controller.rb index 9324b2755..5acffcb16 100644 --- a/app/controllers/tidings_controller.rb +++ b/app/controllers/tidings_controller.rb @@ -6,6 +6,7 @@ class TidingsController < ApplicationController def index tidings = current_user.tidings + @onclick_time = current_user.click_time tiding_types = case params[:type] @@ -18,11 +19,13 @@ class TidingsController < ApplicationController end tidings = tidings.where(tiding_type: tiding_types) if tiding_types.present? + tidings = tidings.where(container_type: 'JoinCourse') if params[:type] == 'course_apply' + @course_apply_count = tidings.where("created_at > '#{@onclick_time}'").where(container_type: 'JoinCourse').count + tidings = tidings.where(container_type: 'ProjectPackage') if params[:type] == 'project_package' @count = tidings.count @tidings = paginate(tidings.order(created_at: :desc), per_page: 10) - @onclick_time = current_user.click_time end private diff --git a/app/views/tidings/index.json.jbuilder b/app/views/tidings/index.json.jbuilder index 69f932f8f..26c31d98b 100644 --- a/app/views/tidings/index.json.jbuilder +++ b/app/views/tidings/index.json.jbuilder @@ -1,2 +1,3 @@ json.count @count json.tidings @tidings, partial: 'tidings/tiding', as: :tiding +json.course_apply_count @course_apply_count