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.26 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.25 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.24 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.23 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.22 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.21 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.20 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.19 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.18 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.17 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.16 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.15 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.14 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.13 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.12 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.11 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.10 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.9 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.8 app/views/educode_sales/activities/index.json.jbuilder
educode_sales-1.10.7 app/views/educode_sales/activities/index.json.jbuilder