diff options
| author | anicet | 2015-06-11 17:56:04 +0200 |
|---|---|---|
| committer | anicet | 2015-06-16 10:45:53 +0200 |
| commit | 2e8f1c8060d018ac1e89450afca7f79ba119d3ba (patch) | |
| tree | 98c9868e5ba728c73f9fab91427cae5353dac5bc | |
| parent | 095d03b2b2f36eab0e5b4713adeb051020b45401 (diff) | |
| download | chouette-core-2e8f1c8060d018ac1e89450afca7f79ba119d3ba.tar.bz2 | |
ReportConcern : add saved and unsaved lines methods
| -rw-r--r-- | app/models/concerns/report_concern.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/concerns/report_concern.rb b/app/models/concerns/report_concern.rb index a71ae1855..e8e2078bd 100644 --- a/app/models/concerns/report_concern.rb +++ b/app/models/concerns/report_concern.rb @@ -67,13 +67,21 @@ module ReportConcern end def line_items - [].tap do |line_items| + @line_items ||= [].tap do |line_items| datas.lines.each do |line| line_items << LineItem.new(line) end if datas.lines? end end + def saved_lines + line_items.map(&:status).count(true) + end + + def unsaved_lines + line_items.map(&:status).count(false) + end + def lines stats.present? ? stats.line_count : 0 end |
