I want to show data for the past 14 days where requests have occurred which is showing on map
@maintenance_count = Maintenance.where(property_id: property_ids)
.where("created_at >= ?", start_date)
.group_by_period(params[:day_month], :created_at, series: true, format: date_format,
last: params[:duration].to_i)
.count.map{|x| x[1]}
this is taking params from URL i assigned like this
a.dropdown-item href="?day_month=day&duration=14" 14 Days
a.dropdown-item href="?day_month=week&duration=8" 8 weeks
a.dropdown-item href="?day_month=month&duration=12" 12 months
a.dropdown-item href="?day_month=year&duration=2" 2 years
i want to show for past 14 days when params are empty but i don't know how this array working with map
labels: @maintaince_ending_labels,
datasets: [
{
data: @maintenance_count
},
]
if params[:day_month] == "day"
start_date = (Date.today - params[:duration].to_i.day).beginning_of_day
date_format = '%a %d'
Aucun commentaire:
Enregistrer un commentaire