Created
June 19, 2013 06:08
-
-
Save dangalipo/5812011 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 recordings | |
super do |recordings| | |
recordings = recordings.with_rejected_readings if self.with_rejected_readings.present? | |
recordings | |
end | |
end | |
def accepted_rejected_pie_chart_data | |
readings = FoodReadings.where(food_recording_id: recordings.collect(&:id)) | |
accepted = FoodReadings.where(food_recording_id: recordings.collect(&:id)).with_section(self.section_id).accepted.count } | |
rejected = recordings.sum{ |recording| recording.food_readings.with_section(self.section_id).rejected.count } | |
{ accepted: percentage_of_readings(accepted), rejected: percentage_of_readings(rejected) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment