Sha256: 13b9a2d3d2e296db63c1fdd1829d7a4ad2a1b5171b54c33ca3898d47cdadf76d
Contents?: true
Size: 1.3 KB
Versions: 7
Compression:
Stored size: 1.3 KB
Contents
departments_count = 0 schools_count = 0 json.data do json.array! @staffs do |d| json.id d.id json.name d.user.real_name json.role d.role&.name json.job_type EducodeSales::Common.job_type_name[d.job_type] json.area d.areas.present? ? d.areas.pluck(:name).join("、") : '' departments = EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.staff_id = #{d.id}").select("COUNT(educode_sales_follow_ups.staff_id) AS count")[0]&.send('count') + EducodeSales::Teacher.joins(:follow_up).where("educode_sales_teacher_follows.staff_id = #{d.id}").select("COUNT(educode_sales_teacher_follows.staff_id) AS count")[0]&.send('count') || 0 json.departments departments schools = EducodeSales::Business.joins(:last_follow_up, :department).where("educode_sales_follow_ups.staff_id = #{d.id}").select("COUNT(distinct(departments.school_id)) AS count")[0]['count'] + EducodeSales::Teacher.joins(:follow_up, :department).where("educode_sales_teacher_follows.staff_id = #{d.id}").select("COUNT(distinct(departments.school_id)) AS count")[0]['count'] json.schools schools departments_count += departments schools_count += schools end end json.totalRow do json.departments departments_count.to_s json.schools schools_count.to_s end json.code 0 json.count @staffs.total_count
Version data entries
7 entries across 7 versions & 1 rubygems