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.
educoder/app/models/salesman_channel.rb

28 lines
646 B

class SalesmanChannel < ApplicationRecord
belongs_to :salesman, :touch => true, counter_cache: true
belongs_to :school
def school_name
school.name
end
def teacher_count
UserExtension.where(school_id: school_id).where.not(identity: 1).count
end
def student_count
UserExtension.where(school_id: school_id, identity: 1).count
end
def course_count
Course.where(school_id: school_id).count
end
def shixuns_count
ShixunMember.joins("join user_extensions on user_extensions.user_id = shixun_members.user_id")
.where(user_extensions: {school_id: school_id}).pluck(:shixun_id).uniq.count
end
end