From 1e6a633d09d0e5f6a5a44f24b12216e464f3f8b6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Tue, 1 Aug 2017 08:42:26 +0000 Subject: [PATCH] Create model for Podcast update results --- mygpo/data/models.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 mygpo/data/models.py diff --git a/mygpo/data/models.py b/mygpo/data/models.py new file mode 100644 index 00000000..879a3b04 --- /dev/null +++ b/mygpo/data/models.py @@ -0,0 +1,45 @@ +from datetime import datetime + +from django.db import models + +from mygpo.podcasts.models import Podcast + + +class PodcastUpdateResult(models.Model): + """ Results of a podcast update + + Once an instance is stored, the update is assumed to be finished. """ + + # The podcast that was updated + podcast = models.ForeignKey(Podcast, on_delete=models.CASCADE) + + # The timestamp at which the updated started to be executed + start = models.DateTimeField(default=datetime.utcnow) + + # The duration of the update + duration = models.DurationField() + + # A flad indicating whether the update was successful + successful = models.BooleanField() + + # An error message. Should be empty if the update was successful + error_message = models.TextField() + + # A flag indicating whether the update created the podcast + podcast_created = models.BooleanField() + + # The number of episodes that were created by the update + episodes_added = models.IntegerField() + + class Meta(object): + + get_latest_by = 'start' + + order_with_respect_to = 'podcast' + + ordering = ['-start'] + + indexes = [ + models.Index(fields=['podcast', 'start']) + ] + -- 2.11.4.GIT