PRODX-39509 Implementing auto-triggering the analyzing of today's run
Added time enums for easy controlling of time duration in code
Added clock to the nav bar
Changed default created_after to more proper way of definition through the Django's timedelta,
because standard datetime library can't pass it's value to the model
Change-Id: I8411853dfc3c420a96254a1091f093c24a4217ae
diff --git a/testrail_bot/control/models.py b/testrail_bot/control/models.py
index 46c5049..6d7840b 100644
--- a/testrail_bot/control/models.py
+++ b/testrail_bot/control/models.py
@@ -1,6 +1,7 @@
from django.core.files.storage import FileSystemStorage
from django.db import models
-from django.utils.timezone import now
+from django.utils.timezone import now, timedelta
+from django_celery_beat.models import PeriodicTask
class IntegerListField(models.Field):
@@ -29,6 +30,10 @@
return ','.join(str(int(x)) for x in value)
+def default_created_after():
+ return now() + timedelta(days=-3 * 30)
+
+
class TestRailTestRun(models.Model):
project_name = models.CharField(max_length=300,
default="Mirantis Cloud Platform")
@@ -44,7 +49,7 @@
uuid_filter = models.BooleanField(default=True)
filter_last_traceback = models.BooleanField(default=True)
created_before = models.DateField(default=now)
- created_after = models.DateField(default=now)
+ created_after = models.DateField(default=default_created_after)
@property
def text_filters(self):
@@ -121,3 +126,24 @@
blank=True)
started_at = models.DateTimeField(auto_created=True,
auto_now=True)
+
+
+TASK_CHOICES = [
+ ("control.celery_tasks.tasks.check_today_testplan",
+ "Check today testplan",
+ []
+ ),
+ ("control.celery_tasks.tasks.task_to_check_testplan",
+ "Check testplan",
+ ["testplan_id"]
+ ),
+ ]
+
+
+class CronPeriodicTask(PeriodicTask):
+ cron = models.CharField(default="",
+ max_length=300,
+ blank=False)
+
+ class Meta:
+ ordering = ["id"]