Created
February 14, 2012 19:50
-
-
Save phudgins/1829662 to your computer and use it in GitHub Desktop.
Getting count of JobApplications by day for a specific JobPosting
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
def counts_by_day_for_job_posting(job_posting_id) | |
results = JobApplication.where(job_posting_id: job_posting_id). | |
where(created_at: 1.month.ago..Time.now). | |
group('date(created_at)').count | |
counts = [] | |
results.each do |result| | |
h = { date: Date.parse(result.first), | |
job_posting_id: job_posting_id, | |
application_count: result.last } | |
counts << h | |
end | |
counts | |
end | |
puts counts_by_day_for_job_posting(192).to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment