from django.db import models class JobRun(models.Model): """The record of one run of one job. Owned by `scheduler` (AD-19).""" class Status(models.TextChoices): RUNNING = "running" OK = "ok" ERROR = "error" job = models.CharField(max_length=60) started_at = models.DateTimeField() finished_at = models.DateTimeField(null=True, blank=True) status = models.CharField(max_length=10, choices=Status.choices, default=Status.RUNNING) # A short summary, or the name of the error. Never personal content. detail = models.CharField(max_length=200, blank=True) class Meta: indexes = [models.Index(fields=["job", "-started_at"])] ordering = ["-started_at", "-id"]