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-0.9.95 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.94 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.93 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.92 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.91 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.90 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.89 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.86 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.84 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.83 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.82 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.81 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.80 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.79 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.78 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.77 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.76 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.75 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.74 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-0.9.73 app/views/educode_sales/activities/index.json.jbuilder