app/controllers/admin/store/reports_controller.rb
# Report showing number of shipments for each fulfiller, and the states of the shipments
Report showing number of shipments for each fulfiller, and the states of the shipments
Report showing number of shipments for each fulfiller and the states of the shipments
def shipments
    sql = <<-EOF
		select aff.id as affiliate_id, aff.name as affiliate_name, shp.status, count(shp.status) as total
		from store_shipments shp
		join core_affiliates aff on aff.id = shp.fulfilled_by_id
		where shp.created_at > '#{@start_date}' and shp.created_at < '#{@end_date}'
		group by shp.fulfilled_by_id, shp.status;
    EOF
    @data = []
    ActiveRecord::Base.connection.execute(sql).each(as: :hash) { |row| @data << row }
  end
def shipments sql = <<-EOF 
		select aff.id as affiliate_id, aff.name as affiliate_name, shp.status, count(shp.status) as total
		from store_shipments shp
		join core_affiliates aff on aff.id = shp.fulfilled_by_id
		where shp.created_at > ' #{ @start_date } ' and shp.created_at < ' #{ @end_date } '
		group by shp.fulfilled_by_id, shp.status;
     EOF @data = [ ] ActiveRecord :: Base . connection . execute ( sql ) . each ( as : :hash ) { | row | @data << row } end
Report showing number of shipments for each fulfiller, and the states of the shipments
Report showing number of shipments for each fulfiller and the states of the shipments