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.
31 lines
1.3 KiB
31 lines
1.3 KiB
class SalesmanChannel < ApplicationRecord
|
|
belongs_to :salesman, :touch => true, counter_cache: true
|
|
belongs_to :school
|
|
|
|
def school_name
|
|
school.name
|
|
end
|
|
|
|
def teacher_count(start_time, end_time, keyword)
|
|
UserExtension.joins(:school).where("schools.name like '%#{keyword}%' and user_extensions.identity=0
|
|
and user_extensions.created_at between '#{start_time}' and '#{end_time}'").count
|
|
# UserExtension.where(school_id: school_id).where(query).count
|
|
end
|
|
|
|
def student_count(start_time, end_time, keyword)
|
|
UserExtension.joins(:school).where("schools.name like '%#{keyword}%' and user_extensions.identity=1
|
|
and user_extensions.created_at between '#{start_time}' and '#{end_time}'").count
|
|
end
|
|
|
|
def course_count(start_time, end_time, keyword)
|
|
Course.joins(:school).where("schools.name like '%#{keyword}%' and courses.created_at between '#{start_time}' and '#{end_time}'").count
|
|
end
|
|
|
|
def shixuns_count(start_time, end_time, keyword)
|
|
ShixunMember.joins("join user_extensions on user_extensions.user_id = shixun_members.user_id and shixun_members.created_at between '#{start_time}' and '#{end_time}'")
|
|
.where(user_extensions: {school_id: school_id}).pluck(:shixun_id).uniq.count
|
|
end
|
|
|
|
|
|
end
|