Sha256: f6650ca6349d9c77bc3befe3b559d8a6bc890f6bbd0f1a0149e53b1f0e772fc0

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

module Aeternitas
  module WebUi
    class ApplicationController < ActionController::Base
      protect_from_forgery with: :exception

      def render_error(status, message)
        @status = status
        @message = message
        render template: 'aeternitas/web_ui/dashboard/error', status: status
      end

      def set_timerange
        @from = DateTime.parse(params.require(:from))
        @to = DateTime.parse(params.require(:to))
        @resolution = get_resolution(@from, @to)
      end

      def get_resolution(from, to)
        case (to.to_time - from.to_time)
          when 0.hours..2.hours
            :minute
          when 2.hours..12.hours
            :ten_minutes
          when 12.hours..3.days
            :hour
          else
            :day
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aeternitas_web_ui-0.2.1 app/controllers/aeternitas/web_ui/application_controller.rb
aeternitas_web_ui-0.2.0 app/controllers/aeternitas/web_ui/application_controller.rb