Skip to content

Commit

Permalink
Add completed_at attribute to mark job finish.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris McRae committed Mar 15, 2024
1 parent f5f3b55 commit 6e9e054
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion apps/dashboard/app/models/batch_connect/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def get_binding
# @return [Integer] created at
attr_accessor :created_at

# When this session finished, as a unix timestamp
# @return [Integer] completed at
attr_accessor :completed_at

# Token describing app and sub app
# @return [String] app token
attr_accessor :token
Expand Down Expand Up @@ -87,7 +91,7 @@ def app
# Attributes used for serialization
# @return [Hash] attributes to be serialized
def attributes
%w(id cluster_id job_id created_at token title script_type cache_completed modified_at).map do |attribute|
%w(id cluster_id job_id created_at token title script_type cache_completed completed_at).map do |attribute|
[ attribute, nil ]
end.to_h
end
Expand Down Expand Up @@ -421,6 +425,7 @@ def update_info
def update_cache_completed!
if (! cache_completed) && completed?
self.cache_completed = true
self.completed_at = Time.now.to_i
db_file.write(to_json)
end
end
Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/test/models/batch_connect/session_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,8 @@ def completed?
'token' => 'bc_jupyter',
'title' => 'Jupyter Notebook',
'script_type' => 'basic',
'cache_completed' => nil
'cache_completed' => nil,
'completed_at' => nil
}
Timecop.freeze(now) do
assert session.save(app: bc_jupyter_app, context: ctx), session.errors.each(&:to_s).to_s
Expand Down

0 comments on commit 6e9e054

Please sign in to comment.