From 1253844369cb8438b1b2a0af7ff314bad5a0f2ed Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 21 Jun 2019 13:54:07 +0800 Subject: [PATCH] modify --- app/controllers/courses_controller.rb | 2 +- app/models/course.rb | 2 +- app/services/users/course_service.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 252664139..cb3b5c929 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -937,7 +937,7 @@ class CoursesController < ApplicationController @page = params[:page] || 1 @page_size = params[:page_size] || 15 - @courses = Course.by_user(current_user).hidden(false).ended(false).deleted(0).by_keywords(params[:search]).distinct + @courses = Course.by_user(current_user).hidden(false).processing.not_deleted.by_keywords(params[:search]).distinct # @total_count = @courses.count # offset = 0 diff --git a/app/models/course.rb b/app/models/course.rb index 61e48d350..e4ade6e9f 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -62,7 +62,7 @@ class Course < ApplicationRecord scope :hidden, ->(is_hidden = true) { where(is_hidden: is_hidden) } scope :ended, ->(is_end = true) { where(is_end: is_end) } scope :processing, -> { where(is_end: false) } - scope :not_deleted, -> { where(is_delete: false) } + scope :not_deleted, -> { where(is_delete: 0) } scope :deleted, ->(is_delete = 1) { where(is_delete: is_delete) } scope :by_user, ->(user) { joins(:course_members).where('course_members.user_id = ?', user.id).order(updated_at: :desc) } scope :by_keywords, lambda { |keywords| diff --git a/app/services/users/course_service.rb b/app/services/users/course_service.rb index 6271db17b..9eb34917e 100644 --- a/app/services/users/course_service.rb +++ b/app/services/users/course_service.rb @@ -11,7 +11,7 @@ class Users::CourseService end def call - courses = category_scope_courses.deleted(false) + courses = category_scope_courses.not_deleted courses = status_filter(courses) @@ -38,9 +38,9 @@ class Users::CourseService case params[:status] when 'processing' then - relations.ended(false) + relations.processing when 'end' then - relations.ended(true) + relations.ended else relations end