From 47be31b415f33efbe73055fd0bb297e88f758731 Mon Sep 17 00:00:00 2001 From: David Gay Date: Tue, 31 Oct 2023 02:04:58 -0400 Subject: Checkpoint kinds: comment, checkin, checkout --- app/models/run.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/models/run.rb') 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 -- cgit v1.2.3