summaryrefslogtreecommitdiff
path: root/app/models/run.rb
diff options
context:
space:
mode:
authorDavid Gay <eapoems@riseup.net>2023-10-31 02:04:58 -0400
committerDavid Gay <eapoems@riseup.net>2023-10-31 02:04:58 -0400
commit47be31b415f33efbe73055fd0bb297e88f758731 (patch)
treed73604168c4b493b6f1ce4332bd3fab05d33ce5d /app/models/run.rb
parent52d46329e525133077b4f116c9e608128d8ba982 (diff)
Checkpoint kinds: comment, checkin, checkout
Diffstat (limited to 'app/models/run.rb')
-rw-r--r--app/models/run.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/models/run.rb b/app/models/run.rb
index 7c9209e..023202b 100644
--- a/app/models/run.rb
+++ b/app/models/run.rb
@@ -3,5 +3,11 @@ class Run < ApplicationRecord
belongs_to :user
has_many :checkpoints, dependent: :destroy
- validates_presence_of :title
+ validates :title, presence: true
+
+ def checked_in?
+ last_checkpoint = checkpoints.where.not(kind: :comment).last
+ # If there are no non-comment checkpoints, then the run was never checked in.
+ last_checkpoint.nil? ? false : last_checkpoint.checkin?
+ end
end