JobTargetStatus as a means of tracking job progress
Some checks failed
Gitea/photolib/pipeline/head There was a failure building this commit
Some checks failed
Gitea/photolib/pipeline/head There was a failure building this commit
This commit is contained in:
parent
39a7ba4b02
commit
f4c708cc82
@ -241,6 +241,7 @@ class Job(Base):
|
||||
status = Column(Enum(JobStatus), nullable=False, default=JobStatus.paused)
|
||||
|
||||
targets = relationship("JobTarget", back_populates="job")
|
||||
target_statuses = relationship("JobTargetStatus", back_populates="job")
|
||||
|
||||
def to_json(self):
|
||||
return {attr: getattr(self, attr) for attr in
|
||||
@ -260,8 +261,41 @@ class JobTarget(Base):
|
||||
job_id = Column(Integer, ForeignKey("jobs.id"), nullable=False)
|
||||
job = relationship("Job", back_populates="targets", foreign_keys=[job_id])
|
||||
target_type = Column(Enum(JobTargetType), nullable=False)
|
||||
target = Column(Integer, nullable=False)
|
||||
target = Column(Integer, nullable=False) #TODO should we refactor this to multiple columns with null and proper constraints?
|
||||
|
||||
statuses = relationship("JobTargetStatus", back_populates="job_target")
|
||||
|
||||
def to_json(self):
|
||||
return {attr: getattr(self, attr) for attr in
|
||||
{"target_type", "target"}}
|
||||
|
||||
|
||||
class JobTargetState(enum.Enum):
|
||||
new = 0
|
||||
running = 1
|
||||
complete = 2
|
||||
error = 3
|
||||
cancelled = 4
|
||||
|
||||
|
||||
class JobTargetStatus(Base):
|
||||
__tablename__ = 'job_target_status'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
job_id = Column(Integer, ForeignKey("jobs.id"), nullable=False)
|
||||
job = relationship("Job", back_populates="target_statuses", foreign_keys=[job_id])
|
||||
|
||||
job_target_id = Column(Integer, ForeignKey("job_targets.id"), nullable=False)
|
||||
job_target = relationship("JobTarget", back_populates="statuses", foreign_keys=[job_target_id])
|
||||
|
||||
"""
|
||||
all jobs are progressed by photo_id. PhotoSets can have many Photos so this is the best logical unit. How this works
|
||||
for the different `JobTargetType`s is broken down as follows:
|
||||
- photo: (obvious)
|
||||
- photoset: the job planner is given the opportunity to create JobTargetStatus for zero-all Photos under
|
||||
a PhotoSet
|
||||
- tag: same as photoset but iterated across all photosets with the tag
|
||||
"""
|
||||
target_photo_id = Column(Integer, ForeignKey("photos.id"), nullable=False)
|
||||
|
||||
status = Column(Enum(JobTargetState), nullable=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user