Created
July 30, 2015 01:41
-
-
Save mixmix/53d8ced48d3ef8835e30 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
cr_last_week = CustomerReview.where('created_at > ?', Time.now - 7.days) | |
cr_naughty_location_ids = CustomerReview.where('last_response_date > ?', Date.today).where('created_at > ?', Time.now - 7.days).group(:location_id).count.keys | |
results = cr_naughty_location_ids.map do |loc_id| | |
crs = cr_last_week.where(location_id: loc_id) | |
naughty_crs = crs.where('last_response_date > ?', Date.today) | |
[Location.find(loc_id).full_name, naughty_crs.count, crs.count] | |
end | |
results.each {|r| puts r} | |
#---------------------------------- | |
cr_naughty = CustomerReview.where('last_response_date > ?', Date.today).where('created_at > ?', Time.now - 7.days) ; puts 'got 1st' | |
cr_from_last_month_plus_five_years = cr_naughty.where('last_response_date BETWEEN ? AND ?', Date.today + 5.years - 1.month, Date.today + 5.years) ; puts 'got 2nd'*/ | |
puts cr_naughty.count | |
puts cr_from_last_month_plus_five_years.count | |
results = (1..12).map do |month| | |
["#{month-1} to #{month} months out", | |
cr_naughty.where('last_response_date BETWEEN ? AND ?', Date.today + 4.years + (month-1).months, Date.today + 4.years + month.months).count | |
] | |
end | |
p results | |
#------------------------------------ | |
cr_naughty_location_ids = CustomerReview.where('last_response_date > ?', Date.today).where('created_at > ?', Time.now - 7.days).group(:location_id).count.keys ; puts 'got this' | |
naughty_locations = Location.where(id: cr_naughty_location_ids) ; puts 'got this' | |
naughty_owners = naughty_locations.map(&:owner) ; puts 'got this' | |
naughty_companies = naughty_owners.map(&:company) ; puts 'got this' | |
p naughty_owners.map(&:name).uniq | |
p '----------------' | |
p naughty_companies.map(&:name).uniq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment