Skip to content

Instantly share code, notes, and snippets.

@dangalipo
Created June 19, 2013 06:08
Show Gist options
  • Save dangalipo/5812011 to your computer and use it in GitHub Desktop.
Save dangalipo/5812011 to your computer and use it in GitHub Desktop.
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