Sha256: 5af7701a4cb89a685b87d1431f83b6ff6c8243511be89d5b4e6136f16615ff68
Contents?: true
Size: 1.12 KB
Versions: 17
Compression:
Stored size: 1.12 KB
Contents
- passengers = Questionnaire.joins(:school).group('schools.name').where(acc_status: 'rsvp_confirmed', bus_list_id: @bus_list.id).order("schools.name ASC").count = pie_chart passengers %br :ruby school_ids = Questionnaire.where(acc_status: 'rsvp_confirmed', bus_list_id: @bus_list.id).distinct.pluck(:school_id) schools = Questionnaire.joins(:school).group('schools.name').where(school_id: school_ids, acc_status: 'rsvp_confirmed').order("schools.name ASC").count schools_riding = Questionnaire.joins(:school).group('schools.name').where(school_id: school_ids, acc_status: 'rsvp_confirmed', bus_list_id: @bus_list.id).count schools = schools.map do |name, count| bus_count_row = schools_riding.select { |school_bus_name, _| school_bus_name == name } bus_count = bus_count_row ? bus_count_row[name] || 0 : 0 count_without_bus = count - bus_count [name, count_without_bus, bus_count] end data = [ { name: "Attending but not riding this bus", data: schools.sort_by { |_, no_bus, bus| [bus, no_bus] }.reverse }, { name: "Riding this bus", data: schools_riding } ] = bar_chart data, stacked: true, height: '400px'
Version data entries
17 entries across 17 versions & 1 rubygems