Last active
June 22, 2017 14:30
-
-
Save debborafernandess/8f4f06364d281076241960a563e3c511 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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