# Finished At
- finished_at = Column(DateTime(timezone=False), nullable=False)
+ finished_at = Column(DateTime(timezone=False))
# Date
return self.started_at and not self.finished_at and not self.aborted_at
def has_finished(self):
- # Jobs can be marked as finished
- if self.finished_at:
- return True
-
- # Jobs can be marked as aborted, too
- elif self.aborted_at:
- return True
+ """
+ Returns True if this job has finished, been aborted, etc.
+ """
+ # This check is checking if finished_at is set because SQLAlchemy is behaving
+ # a little bit stupid when we set finished_at to sqlalchemy.func.current_timestamp()
+ # because since this is a server function, it cannot know the value before we commit.
+ if self.finished_at is None:
+ return False
- return False
+ return True
# Failed