Sha256: 3630a67fa9edae44653a74293b335850603e7a5269ee726c67c9d430733dd270

Contents?: true

Size: 608 Bytes

Versions: 1

Compression:

Stored size: 608 Bytes

Contents

module ClockworkWeb
  module HomeHelper

    def friendly_period(period)
      if period % 1.day == 0
        "#{period / 1.day} day"
      elsif period % 1.hour == 0
        "#{period / 1.hour} hour"
      elsif period % 1.minute == 0
        "#{period / 1.minute} min"
      else
        "#{period} sec"
      end
    end

    def last_run(event)
      if ClockworkWeb.redis
        # TODO get all events at once
        timestamp = ClockworkWeb.redis.get("clockwork:last_run:#{event.job}")
        if timestamp
          time_ago_in_words(Time.at(timestamp.to_i))
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
clockwork_web-0.0.1 app/helpers/clockwork_web/home_helper.rb