dev_course
p31729568 6 years ago
parent 4fd4b579af
commit 1253844369

@ -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

@ -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|

@ -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

Loading…
Cancel
Save