donnykurnia icon

Untitled

donnykurnia | PRO | 03/30/17 04:59:08 AM UTC | 0 ⭐ | 373 👁️ | Never ⏰ | []
Ruby |

790 B

|

None

|

0 👍

/

0 👎

  def outlet_coverages
    d = []
    Store.by_customer_and_city(params[:customer_id],params[:city_id],params[:data_date])
         .each do |x| 
           percent_num = (x.average_score.floor.to_s.size > 1) ? x.average_score.floor.to_s[0]+'0' : "10"
           d << {
             latLng:  [x.latitude.to_f, x.longitude.to_f],
             data:    "<b>#{x.name_store}</b><br>#{x.address}<br>percentage: #{x.average_score}%",
             city_id: x.city_id,
             tag:     ['marker',
                       x.city.code,
                       Customer.by_store(x.id).code,
                       Area.by_store(x.id).code
                      ],
             options: { icon: asset_path("percentages/21px-#{percent_num}p.png") }
           }
         end
    render json: d
  end

Comments