- Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathjob_status_generation.rb
50 lines (40 loc) · 1.04 KB
/
job_status_generation.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
moduleJobStatusGeneration
defto_status
rep=[]
rep << "Job #{ident} <#{url}>."
ifstarted_by
ifnote
rep << "Started by #{started_by}; reason: #{note}."
else
rep << "Started by #{started_by}."
end
end
ifaborted?
rep << "Job aborted."
elsiffinished?
rep << "Job completed."
elsifpending?
rep << "In queue."
elsifin_progress?
rep << "In progress. Downloaded #{mb_downloaded.round(2)} MiB, #{error_count.to_i} errors, #{item_count} queued."
rep << "#{concurrency.to_i} workers, delay: #{delay_min.to_f}, #{delay_max.to_f} ms."
end
if(t=ttl) && (t != -1)
rep << "Eligible for rearchival in #{formatted_ttl(t)}."
end
[rep.join(" ")]
end
private
defmb_downloaded
bytes_downloaded.to_f / (1024 * 1024)
end
defitem_count
items_queued.to_i - items_downloaded.to_i
end
defformatted_ttl(ttl)
hr=ttl / 3600
min=(ttl % 3600) / 60
sec=(ttl % 3600) % 60
"#{hr}h #{min}m #{sec}s"
end
end