Sha256: 7e08f2ce153000668c2f414fde6b84fd08227c19c29f581abd7c1d1449fa79f5

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 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.map { |d| d.staff.user.real_name}.uniq.join("、")
    json.expert d.experts.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.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

1 entries across 1 versions & 1 rubygems

Version Path
educode_sales-0.9.67 app/views/educode_sales/activities/index.json.jbuilder