Skip to content

Instantly share code, notes, and snippets.

@debborafernandess
Last active June 22, 2017 14:30
Show Gist options
  • Save debborafernandess/8f4f06364d281076241960a563e3c511 to your computer and use it in GitHub Desktop.
Save debborafernandess/8f4f06364d281076241960a563e3c511 to your computer and use it in GitHub Desktop.
date = Date.parse('2017-06-18')
report = File.new("nps_#{date}.csv", 'w')
report << "Location, Count\n"
LocationGroup.find(25).all_locations.enabled.map do |location|
count = Survey.ordered.
in_range(
date.to_date.beginning_of_day,
date.to_date.end_of_day
).where(location_id: location.id).count
if count < location.configuration.survey_daily_limit
count
report << "#{location.acronym}, #{count}\n"
end
end.compact
report.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment