From beebbd51046690cd30f5a7cc281352de8f358202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vit=C3=B3ria=20Rosa?= Date: Thu, 18 Jan 2018 12:12:22 -0200 Subject: [PATCH] new condition to show total and average of meetings and recordings --- app/views/manage/_statistics_list.html.haml | 29 ++++++++++++++++++--- lib/mconf/statistics_module.rb | 16 +++++++----- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/app/views/manage/_statistics_list.html.haml b/app/views/manage/_statistics_list.html.haml index 38b918792..82f7a8a47 100644 --- a/app/views/manage/_statistics_list.html.haml +++ b/app/views/manage/_statistics_list.html.haml @@ -20,12 +20,33 @@ -#.list-container.list-tablefied .title= t('.meetings.title') .text= t('.meetings.all', value: @data[:meetings][:all]) - .text= t('.meetings.total', value: distance_of_time_in_words_to_now(Time.now + @data[:meetings][:total], include_seconds: false)) - .text= t('.meetings.average', value: distance_of_time_in_words_to_now(Time.now + @data[:meetings][:average], include_seconds: false)) + + - total = @data[:meetings][:total] + - if total == 0 + .text= t('.meetings.total', value: total) + - else + .text= t('.meetings.total', value: distance_of_time_in_words_to_now(Time.now + total, include_seconds: false)) + + - average = @data[:meetings][:average] + - if average == 0 + .text= t('.meetings.average', value: average) + - else + .text= t('.meetings.average', value: distance_of_time_in_words_to_now(Time.now + average, include_seconds: false)) -#.list-container.list-tablefied .title= t('.recordings.title') .text= t('.recordings.all', value: @data[:recordings][:all]) - .text= t('.recordings.total', value: distance_of_time_in_words_to_now(Time.now + @data[:recordings][:total], include_seconds: false)) - .text= t('.recordings.average', value: distance_of_time_in_words_to_now(Time.now + @data[:recordings][:average], include_seconds: false)) + + - total = @data[:recordings][:total] + - if total == 0 + .text= t('.recordings.total', value: total) + - else + .text= t('.recordings.total', value: distance_of_time_in_words_to_now(Time.now + total, include_seconds: false)) + + - average = @data[:recordings][:average] + - if average == 0 + .text= t('.recordings.average', value: average) + - else + .text= t('.recordings.average', value: distance_of_time_in_words_to_now(Time.now + average, include_seconds: false)) + .text= t('.recordings.size', value: human_file_size(@data[:recordings][:size])) diff --git a/lib/mconf/statistics_module.rb b/lib/mconf/statistics_module.rb index 9b34d6a44..6d55026aa 100644 --- a/lib/mconf/statistics_module.rb +++ b/lib/mconf/statistics_module.rb @@ -51,13 +51,15 @@ def self.total_meetings(from, to) average = 0 count = 0 - meetings.find_each do |m| - # total duration - unless m.finish_time == nil - duration = m.finish_time - m.create_time - end - total = total + duration - count = count + 1 + unless meetings == 0 + meetings.find_each do |m| + # total duration + unless m.finish_time == nil + duration = m.finish_time - m.create_time + end + total = total + duration + count = count + 1 + end end # duration average