Sha256: 3ae8966824cacb7c370662d691f18c4ccdb7fe66599a4960b35a129b0463af46
Contents?: true
Size: 1.61 KB
Versions: 12
Compression:
Stored size: 1.61 KB
Contents
# frozen_string_literal: true module ThinkFeelDoEngine # Used to the average in difference between the actual # and predicted values of a collection of activities module ActivitiesHelper def average_intensity_difference(activities, attribute) count = 0 total_diff = 0 activities.each do |activity| actual_intensity = activity.send("actual_#{attribute}_intensity") predicted_intensity = activity.send("predicted_#{attribute}_intensity") if actual_intensity && predicted_intensity count += 1 total_diff += (actual_intensity - predicted_intensity).abs end end count == 0 ? "No activities exist." : total_diff.to_f / count end def percent_complete_message(activities) "Completion Score: #{percent_complete(activities)} "\ "(#{help_text(activities.were_planned)})" end private def help_text(activities) if activities.were_planned.count > 0 "You completed #{activities.reviewed_and_complete.count} out of "\ "#{scheduled_message(activities.were_planned)} that you scheduled." else "No activities were scheduled." end end def percent_complete(activities) if activities.were_planned.count > 0 (activities.reviewed_and_complete.count.to_f / activities.were_planned.count.to_f * 100 ).round(0).to_s + "%" else "Not Available" end end def scheduled_count(activities) activities.were_planned.count end def scheduled_message(activities) pluralize(scheduled_count(activities), "activity") end end end
Version data entries
12 entries across 12 versions & 1 rubygems