Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions apps/dashboard/app/models/active_jobs/jobstatusdata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def extended_data_torque(info)
attributes.push Attribute.new "Job Name", self.jobname
attributes.push Attribute.new "User", self.username
attributes.push Attribute.new "Account", self.account
append_submission_time_attribute(attributes, info)
attributes.push Attribute.new "Walltime", (info.native.fetch(:Resource_List, {})[:walltime].presence || "00:00:00")
attributes.push Attribute.new "Walltime Used", self.walltime_used
node_count = info.native.fetch(:Resource_List, {})[:nodect].to_i
Expand Down Expand Up @@ -120,6 +121,7 @@ def extended_data_slurm(info)
attributes.push Attribute.new "Total CPUs", info.native[:cpus]
attributes.push Attribute.new "Time Limit", info.native[:time_limit]
attributes.push Attribute.new "Time Used", self.walltime_used
append_submission_time_attribute(attributes, info)
attributes.push Attribute.new "Start Time", safe_parse_time(info.native[:start_time])
attributes.push Attribute.new "End Time", safe_parse_time(info.native[:end_time])
attributes.push Attribute.new "Memory", info.native[:min_memory]
Expand Down Expand Up @@ -152,7 +154,7 @@ def extended_data_lsf(info)
attributes.push Attribute.new "From Host", info.native[:from_host]
attributes.push Attribute.new "Exec Host", info.native[:exec_host]
attributes.push Attribute.new "Job Name", self.jobname
attributes.push Attribute.new "Submit Time", info.native[:submit_time]
append_submission_time_attribute(attributes, info)
attributes.push Attribute.new "Project Name", info.native[:project]
attributes.push Attribute.new "CPU Used", info.native[:cpu_used]
attributes.push Attribute.new "Mem", info.native[:mem]
Expand Down Expand Up @@ -183,6 +185,7 @@ def extended_data_pbspro(info)
attributes.push Attribute.new "Job Name", self.jobname
attributes.push Attribute.new "User", self.username
attributes.push Attribute.new "Account", self.account if info.accounting_id
append_submission_time_attribute(attributes, info)
attributes.push Attribute.new "Group List", info.native[:group_list] if info.native[:group_list]
attributes.push Attribute.new "Walltime", (info.native.fetch(:Resource_List, {})[:walltime].presence || "00:00:00")
walltime_used = info.wallclock_time || 0
Expand Down Expand Up @@ -276,7 +279,7 @@ def extended_data_fujitsu_tcs(info)
attributes = []
attributes.push Attribute.new "Nodes", info.native[:NODES]
attributes.push Attribute.new "Time Limit", pretty_time(info.wallclock_limit)
attributes.push Attribute.new "Submission Time", info.native[:ACCEPT]
append_submission_time_attribute(attributes, info)
attributes.push Attribute.new "Start Time", info.native[:START_DATE]
self.native_attribs = attributes

Expand Down Expand Up @@ -317,6 +320,24 @@ def safe_parse_time(time)
end
end

def submission_time_display(info)
nat = info.native if info.native.is_a?(Hash)

if (v = nat&.dig(:ACCEPT)).present?
return safe_parse_time(v).presence || v.to_s.strip
end

t = info.submission_time
return t.strftime('%Y-%m-%d %H:%M:%S') if t.respond_to?(:strftime)

safe_parse_time(nat&.dig(:submit_time))
end

def append_submission_time_attribute(attributes, info)
text = submission_time_display(info)
attributes.push(Attribute.new('Submission Time', text)) if text.present?
end

def build_file_explorer_url(path)
writable_path = (path.writable? ? path : ENV["HOME"]).to_s

Expand Down
38 changes: 38 additions & 0 deletions apps/dashboard/test/models/active_jobs/jobstatusdata_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'test_helper'

class ActiveJobs::JobstatusdataTest < ActiveSupport::TestCase
setup do
@job = ActiveJobs::Jobstatusdata.allocate
end

test 'submission_time_display prefers Info#submission_time when set' do
t = Time.utc(2024, 6, 15, 14, 30, 0)
info = OpenStruct.new(submission_time: t, native: { submit_time: 'ignored' })

assert_equal '2024-06-15 14:30:00', @job.send(:submission_time_display, info)
end

test 'submission_time_display uses native ACCEPT for Fujitsu-style payloads' do
info = OpenStruct.new(
submission_time: nil,
native: { ACCEPT: '2024-06-15 14:30:00' }
)

assert_equal '2024-06-15 14:30:00', @job.send(:submission_time_display, info)
end

test 'submission_time_display falls back to native submit_time' do
info = OpenStruct.new(
submission_time: nil,
native: { submit_time: '2024-06-15 14:30:00' }
)

assert_equal '2024-06-15 14:30:00', @job.send(:submission_time_display, info)
end

test 'submission_time_display returns empty when unknown' do
info = OpenStruct.new(submission_time: nil, native: {})

assert_equal '', @job.send(:submission_time_display, info)
end
end
Loading