Sha256: 7c421d47a8568110c77e88eb6f6c02c43ac7d48ffd94eb51c03c27dc57a023a0

Contents?: true

Size: 1.12 KB

Versions: 62

Compression:

Stored size: 1.12 KB

Contents

module Workarea
  module Admin
    module InsightsHelper
      def insights_path_for(model)
        url_for(
          action: 'insights',
          controller: model.model_name.route_key,
          id: model,
          only_path: true
        )
      end

      def insights_number_to_percentage(number, options = {})
        number_to_percentage(
          number,
          options.reverse_merge(precision: number.zero? || number.abs > 5 ? 0 : 2)
        )
      end

      def insights_trend_icon(number)
        return nil if number.blank? || number.zero?

        if number > 0
          content_tag(:span, '⬆', style: 'color: green;') # TODO FIXME
        else
          content_tag(:span, '⬇', style: 'color: red;') # TODO FIXME
        end
      end

      def current_popular_searches
        @current_popular_searches ||= Workarea::Insights::PopularSearches.current.results.take(5)
      end

      def sparkline_analytics_data_for(data)
        return [0] if data.blank?
        return Array.new(data.size, 0) if data.max.zero?

        data.map { |p| [(p / data.max.to_f * 10).round - 1, 0].max }
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-admin-3.4.27 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.5.4 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.26 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.5.3 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.25 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.5.2 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.24 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.5.1 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.23 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.22 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.5.0 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.21 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.5.0.beta.1 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.20 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.19 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.18 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.17 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.16 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.15 app/helpers/workarea/admin/insights_helper.rb
workarea-admin-3.4.14 app/helpers/workarea/admin/insights_helper.rb