I am trying to write a query for my Rails API that will return the total number of hours of job applications that are accepted per month for a given set of dates.
Table: Job, JobApplication
Job has many JobApplication
JobApplication has a field status "SUCCESS" if matched
Start Date: Jul 16 2015
Is it possible to have it return {Jul 16: 100, Aug 16: 200, .... } ?
I am quite confused. Any help would be appreciated.
This query would give the number of successful Job Applications within a date range.
JobApplication.where(status: "SUCCESS").("created_at < ? ", Jul 16).("created_at < ? ", Aug 15)
JobApplication.job.duration would give the number of hours for that job.
I am not sure how to put them together and then loop through the dates.
My expect results is something like this:
{Jul 16: 100, Aug 16: 200, .... }