Skip to content

Commit

Permalink
Merge pull request #31 from AndyObtiva/development
Browse files Browse the repository at this point in the history
Display Busy tab job data correctly + Support job table queue filter combo box + Refactoring
  • Loading branch information
mperham authored Dec 19, 2023
2 parents 918e743 + e96296b commit 6526de8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
13 changes: 11 additions & 2 deletions lib/kuiq/model/job_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ class JobManager
BUSY_PROPERTIES = %i[process_size total_concurrency busy utilization total_rss]

attr_accessor :polling_interval, :live_poll
attr_reader :redis_url, :redis_info, :current_time, :retry_filter, :schedule_filter, :dead_filter
attr_reader :redis_url, :redis_info, :current_time,
:retry_filter, :schedule_filter, :dead_filter,
:work_queue_filter

def initialize
@polling_interval = POLLING_INTERVAL_DEFAULT
Expand Down Expand Up @@ -58,7 +60,14 @@ def processes
end

def works
work_set.to_a.map { |*args| Work.new(*args) }
work_objects = work_set.to_a.map { |args| Work.new(*args) }
work_objects = work_objects.select { |work| work.queue == work_queue_filter } if !work_queue_filter.to_s.strip.empty?
work_objects
end

def work_queue_filter=(string)
@work_queue_filter = string
notify_observers(:works)
end

def queues
Expand Down
27 changes: 19 additions & 8 deletions lib/kuiq/model/work.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
require 'json'

module Kuiq
module Model
class Work
attr_reader :process, :thread, :job
attr_reader :process, :thread, :job, :payload
def initialize(process, thread, hash)
@process = process
@thread = thread
@job = hash
@payload = JSON.parse(@job["payload"])
end

def queue
job["queue"]
end

def started_at
Time.at(job["run_at"]).utc.iso8601
end

def job_class
payload["class"]
end

def method_missing(method_name, *args, &block)
if @job["payload"].include?(method_name.to_s)
@job["payload"][method_name.to_s]
if payload.include?(method_name.to_s)
payload[method_name.to_s]
else
super
end
end

def respond_to_missing?(method_name, include_private = false)
super || @job["payload"].include?(method_name.to_s)
end

def started_at
Time.at(job["run_at"])
super || payload.include?(method_name.to_s)
end
end
end
Expand Down
24 changes: 21 additions & 3 deletions lib/kuiq/view/busy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,46 @@ class Busy
}]
}
}

horizontal_box {
stretchy false

# filler
label

label("#{t("Queue")}:") {
stretchy false
}

combobox {
stretchy false

items [''] + job_manager.queues.map(&:name)
selected_item <=> [job_manager, :work_queue_filter]
}
}

group(t("Jobs")) {
margined false

table {
text_column(t("Process"))
text_column(t("Started"))
text_column(t("TID"))
text_column(t("JID"))
text_column(t("Queue"))
text_column(t("Job"))
text_column(t("Arguments"))
text_column(t("Started"))

cell_rows <= [job_manager, :works,
column_attributes: {
t("Process") => :process,
t("Started") => :started_at,
t("TID") => :thread,
t("JID") => :jid,
t("Queue") => :queue,
t("Job") => :class,
t("Job") => :job_class,
t("Arguments") => :args,
t("Started") => :started_at
}]
}
}
Expand Down

0 comments on commit 6526de8

Please sign in to comment.