How do you group by week for a month of records, but only find dates for the month.
arget_date = Date.today.beginning_of_month
target_range = target_date..target_date.end_of_month
Post.where(created_at: target_range).group_by_week(:created_at, range: target_range).sum(:view_count)
I'm using group_by_week() that is included with groupdate gem. The issue is, its returning records from the end of the last month for certain months. Given that certain months begin on Wednesday. I would like to get all record for example: The month of July 1st-31st and then get the sums for each week within the month. Week 1, should start on July 1st.