diff --git a/app/models/salesman_channel.rb b/app/models/salesman_channel.rb index b5ae17e0e..0aee5f635 100644 --- a/app/models/salesman_channel.rb +++ b/app/models/salesman_channel.rb @@ -6,20 +6,23 @@ class SalesmanChannel < ApplicationRecord school.name end - def teacher_count - UserExtension.where(school_id: school_id).where.not(identity: 1).count + 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 - UserExtension.where(school_id: school_id, identity: 1).count + 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 - Course.where(school_id: school_id).count + 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 - ShixunMember.joins("join user_extensions on user_extensions.user_id = shixun_members.user_id") + 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 diff --git a/app/views/admins/salesman_channels/index.html.erb b/app/views/admins/salesman_channels/index.html.erb index 5e15d63eb..237ef61d5 100644 --- a/app/views/admins/salesman_channels/index.html.erb +++ b/app/views/admins/salesman_channels/index.html.erb @@ -2,12 +2,32 @@ <% add_admin_breadcrumb("#{@salesman.name}的渠道", admins_salesmans_path) %> <% end %> -