I'm trying to create an array of counts per day. I want the counts to be only of distinct uid's (what uid's are "distinct" shouldn't be reset each day).
Before, I had:
@unique_count_array_by_day = []
15.times { |i|
bar = Model.select("DISTINCT(uid)").where(:created_at => (Time.now.beginning_of_day - i.days)..(Time.now.beginning_of_day - (i-1).days)).count()
@unique_count_array_by_day << bar
}
This wasn't giving me distinct uid's overall, it was giving me the count of unique uid's within a day. So I pulled the code selecting the distinct uid's out of the loop:
@unique_count_array_by_day = []
foo = Model.select("DISTINCT(uid)")
15.times { |i|
bar = foo.where(:created_at => (Time.now.beginning_of_day - i.days)..(Time.now.beginning_of_day - (i-1).days)).count()
@unique_count_array_by_day << bar
}
However, this still produces a count of distinct uid's per day instead of distinct uid's on their first occurrence in the data table.
Any thoughts on how to finagle this?