class Qless::Server
The Qless
web interface
Constants
- PAGE_SIZE
Attributes
client[R]
I'm not sure what this option is – I'll look it up later set :static, true
Public Class Methods
new(client)
click to toggle source
Calls superclass method
# File lib/qless/server.rb, line 22 def initialize(client) @client = client super end
Public Instance Methods
application_name()
click to toggle source
# File lib/qless/server.rb, line 90 def application_name client.config['application'] end
current_page()
click to toggle source
# File lib/qless/server.rb, line 60 def current_page @current_page ||= begin Integer(params[:page]) rescue 1 end end
failed()
click to toggle source
# File lib/qless/server.rb, line 106 def failed client.jobs.failed end
json(obj)
click to toggle source
Return the supplied object back as JSON
# File lib/qless/server.rb, line 111 def json(obj) content_type :json obj.to_json end
next_page_url()
click to toggle source
# File lib/qless/server.rb, line 52 def next_page_url page_url(1) end
page_url(offset)
click to toggle source
# File lib/qless/server.rb, line 46 def page_url(offset) url_with_modified_query do |query| query.merge('page' => current_page + offset) end end
paginated(qless_object, method, *args)
click to toggle source
# File lib/qless/server.rb, line 74 def paginated(qless_object, method, *args) qless_object.send(method, *(args + pagination_values)) end
pagination_values()
click to toggle source
# File lib/qless/server.rb, line 69 def pagination_values start = (current_page - 1) * PAGE_SIZE [start, start + PAGE_SIZE] end
path_prefix()
click to toggle source
# File lib/qless/server.rb, line 35 def path_prefix request.env['SCRIPT_NAME'] end
prev_page_url()
click to toggle source
# File lib/qless/server.rb, line 56 def prev_page_url page_url(-1) end
queues()
click to toggle source
# File lib/qless/server.rb, line 94 def queues client.queues.counts end
sanitize_attr(attr)
click to toggle source
Make the id acceptable as an id / att in HTML
# File lib/qless/server.rb, line 117 def sanitize_attr(attr) return unless attr attr.gsub(/[^a-zA-Z\:\_]/, '-') end
strftime(t)
click to toggle source
# File lib/qless/server.rb, line 138 def strftime(t) # From http://stackoverflow.com/questions/195740 diff_seconds = Time.now - t formatted = t.strftime('%b %e, %Y %H:%M:%S') case diff_seconds when 0 .. 59 "#{formatted} (#{diff_seconds.to_i} seconds ago)" when 60 ... 3600 "#{formatted} (#{(diff_seconds / 60).to_i} minutes ago)" when 3600 ... 3600 * 24 "#{formatted} (#{(diff_seconds / 3600).to_i} hours ago)" when (3600 * 24) ... (3600 * 24 * 30) "#{formatted} (#{(diff_seconds / (3600 * 24)).to_i} days ago)" else formatted end end
tabs()
click to toggle source
# File lib/qless/server.rb, line 78 def tabs [ { name: 'Queues' , path: '/queues' }, { name: 'Workers' , path: '/workers' }, { name: 'Track' , path: '/track' }, { name: 'Failed' , path: '/failed' }, { name: 'Completed', path: '/completed'}, { name: 'Config' , path: '/config' }, { name: 'About' , path: '/about' } ] end
tracked()
click to toggle source
# File lib/qless/server.rb, line 98 def tracked client.jobs.tracked end
url_path(*path_parts)
click to toggle source
# File lib/qless/server.rb, line 30 def url_path(*path_parts) [path_prefix, path_parts].join('/').squeeze('/') end
url_with_modified_query() { |existing_query)| ... }
click to toggle source
# File lib/qless/server.rb, line 39 def url_with_modified_query url = URI(request.url) existing_query = Rack::Utils.parse_query(url.query) url.query = Rack::Utils.build_query(yield existing_query) url.to_s end
workers()
click to toggle source
# File lib/qless/server.rb, line 102 def workers client.workers.counts end