Sha256: e5e468374dd9799074b2c80f156a0f992fe6550b4d32eb529c6a9290e5f8edaa

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

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("、") : ''
    json.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') || 0
    json.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']
  end
end

json.code 0
json.count @staffs.total_count

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
educode_sales-0.2.0 app/views/educode_sales/sales/operations.json.jbuilder