Graph with multiple conditions in Rails

I am trying to count all records between two dates that have been completed. This means that the created_at field is between start_date and end_date, and the final_at field is not null.

I can use the following expression to get records that have not ended:

Record.count(:all, :conditions => {:created_at => start_date..end_date, :finished_at => nil })

Is there a similar way to count entries in which nonzero ended?

+5
source share
1 answer

This should work just fine if I don't miss something.

Record.where(:created_at => start_date..end_date).where('finished_at IS NOT NULL').count
+7
source

All Articles