Sha256: 49f5485ab33a332320291ff83a02a9b64029966188f566339b79d46314425916

Contents?: true

Size: 1.36 KB

Versions: 85

Compression:

Stored size: 1.36 KB

Contents

teachers_count = 0
schools_count = 0
json.data do
  json.array! @activities do |d|
    json.id d.id
    json.name d.name
    json.days d.days
    json.teachers_count d.activity_teachers_count
    teachers_count += d.activity_teachers_count
    json.return_rate d.return_rate
    json.students_count d.students_count || 0
    json.course_rate d.course_rate
    json.start_at d.start_at ? d.start_at.to_s(:date) : ''
    json.clazz_id d.clazz_id
    json.staff d.sales&.user&.real_name || d.staff&.user&.real_name
    json.staff_manage d.manages.map { |d| d.staff.user.real_name}.uniq.join("、")
    json.staff_assist d.assists.pluck(:name).join("、")
    json.invitations d.invitations.pluck(:name).join("、")
    json.sponsor d.sponsor
    json.linkman d.linkman
    json.phone d.phone
    json.scale d.scale
    json.address d.address
    json.meeting_form d.meeting_form
    json.state_id d.state_id
    json.advise d.last_follow_up&.advise || ''
 
    json.schools_count EducodeSales::ActivityTeacher.joins(teacher: :department).where(activity_id: d.id).select("distinct(school_id)").count
    schools_count +=  EducodeSales::ActivityTeacher.joins(teacher: :department).where(activity_id: d.id).select("distinct(school_id)").count
  end
end

json.totalRow do
  json.teachers_count teachers_count.to_s
  json.schools_count schools_count.to_s
end
json.code 0
json.count @activities.total_count

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
educode_sales-1.10.74 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.73 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.72 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.71 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.70 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.59 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.58 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.49 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.48 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.46 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.41 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.37 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.36 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.35 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.34 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.33 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.31 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.30 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.29 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.28 app/views/educode_sales/activities/index.json.jbuilder