Skip to content

Commit 7fb0ca3

Browse files
codecat555HazelGrant
authored andcommitted
Add completed_at attribute to mark job finish. (#3424)
1 parent 6cb08dc commit 7fb0ca3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

apps/dashboard/app/models/batch_connect/session.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ def get_binding
3131
# @return [Integer] created at
3232
attr_accessor :created_at
3333

34+
# When this session finished, as a unix timestamp
35+
# @return [Integer] completed at
36+
attr_accessor :completed_at
37+
3438
# Token describing app and sub app
3539
# @return [String] app token
3640
attr_accessor :token
@@ -87,7 +91,7 @@ def app
8791
# Attributes used for serialization
8892
# @return [Hash] attributes to be serialized
8993
def attributes
90-
%w(id cluster_id job_id created_at token title script_type cache_completed).map do |attribute|
94+
%w(id cluster_id job_id created_at token title script_type cache_completed completed_at).map do |attribute|
9195
[ attribute, nil ]
9296
end.to_h
9397
end
@@ -421,6 +425,7 @@ def update_info
421425
def update_cache_completed!
422426
if (! cache_completed) && completed?
423427
self.cache_completed = true
428+
self.completed_at = Time.now.to_i
424429
db_file.write(to_json)
425430
end
426431
end

apps/dashboard/test/models/batch_connect/session_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,8 @@ def completed?
551551
'token' => 'bc_jupyter',
552552
'title' => 'Jupyter Notebook',
553553
'script_type' => 'basic',
554-
'cache_completed' => nil
554+
'cache_completed' => nil,
555+
'completed_at' => nil
555556
}
556557
Timecop.freeze(now) do
557558
assert session.save(app: bc_jupyter_app, context: ctx), session.errors.each(&:to_s).to_s

0 commit comments

Comments
 (0)