sacarmonar15
9/22/2017 - 5:31 PM

weekly metrics

#Metricas semanales de Mauricio
#Saca las metricas dadas por semana para las cuentas, eventos, registros, meetings y stands.
current_day = DateTime.new(2017, 1 , 2)
end_date = DateTime.now
report = []
while current_day <= end_date
  end_of_week = current_day.end_of_week
  metrics = Metric.weekly_report(current_day, end_of_week)
  metrics[:start_date] = current_day.strftime("%d/%m/%Y")
  metrics[:end_date] = end_of_week.strftime("%d/%m/%Y")
  report << metrics
  current_day = current_day.next_week
end
 
CSV.open("/Users/monica/documents/weekly_report.csv", "wb") do |csv|
  csv << ["", "", "cuentas", "eventos", "regitros", "meetings", "stands"]
  report.each do |metrics|
    csv <<  [
              metrics[:start_date], metrics[:end_date], metrics[:number_accounts],
              metrics[:number_of_events], metrics[:number_registrations],
              metrics[:number_meeting_requested], metrics[:number_stands_booked]
            ]
  end
end