Merge "Make possiblity to disable cached checked tests"
diff --git a/testrail_bot/control/celery_tasks/testrail_pipeline.py b/testrail_bot/control/celery_tasks/testrail_pipeline.py
index 350f37b..af2b59b 100644
--- a/testrail_bot/control/celery_tasks/testrail_pipeline.py
+++ b/testrail_bot/control/celery_tasks/testrail_pipeline.py
@@ -363,7 +363,8 @@
         failed_tests = test_rail_api.get_failed_tests(bot_test_run.run_id,
                                                       by_plans=is_testplan)
         for test in failed_tests:
-            if test["id"] in bot_test_run.checked_tests:
+            if bot_test_run.caching_tests_enabled and \
+                    test["id"] in bot_test_run.checked_tests:
                 continue
             process_test(f, test,
                          bot_test_run.testrail_filters,
diff --git a/testrail_bot/control/forms.py b/testrail_bot/control/forms.py
index 0ad6c12..76379ee 100644
--- a/testrail_bot/control/forms.py
+++ b/testrail_bot/control/forms.py
@@ -10,6 +10,7 @@
             date.today().year + i for i in range(-3, 5)])
         self.fields["created_before"].widget = forms.SelectDateWidget(years=[
             date.today().year + i for i in range(-3, 5)])
+
     class Meta:
         model = TestRailTestRun
         fields = "__all__"
@@ -27,6 +28,7 @@
                                      "compare comments",
             "created_after": "Search in period from",
             "created_before": "till",
+            "caching_tests_enabled": "Don't check already checked results"
 
         }
         help_texts = {
diff --git a/testrail_bot/control/migrations/0007_testrailtestrun_caching_tests_enabled.py b/testrail_bot/control/migrations/0007_testrailtestrun_caching_tests_enabled.py
new file mode 100644
index 0000000..a33fc75
--- /dev/null
+++ b/testrail_bot/control/migrations/0007_testrailtestrun_caching_tests_enabled.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.7 on 2024-01-20 18:54
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('control', '0006_alter_testrailtestrun_created_after_and_more'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='testrailtestrun',
+            name='caching_tests_enabled',
+            field=models.BooleanField(default=False),
+        ),
+    ]
diff --git a/testrail_bot/control/models.py b/testrail_bot/control/models.py
index a68d088..71fd861 100644
--- a/testrail_bot/control/models.py
+++ b/testrail_bot/control/models.py
@@ -1,5 +1,3 @@
-import datetime
-
 from django.core.files.storage import FileSystemStorage
 from django.db import models
 from django.utils.timezone import now
@@ -39,6 +37,7 @@
     test_pattern = models.CharField(max_length=300, blank=True)
     run_id = models.CharField(max_length=300)
     checked_tests = IntegerListField(default=list())
+    caching_tests_enabled = models.BooleanField(default=False)
     created_by_id = models.IntegerField(default='109')
     filter_func = models.TextField(null=True, blank=True)
     ip_filter = models.BooleanField(default=True)
@@ -95,13 +94,13 @@
             ("11188", "[MCP2.0_XENA]Tempest"),
             ("11170", "[MCP2.0_YOGA]Tempest"),
             ("11192", "[MCP2.0_ANTELOPE]Tempest"))
-        ),
+         ),
         ("Stepler", (
             ("10886", "[MCP2.0_USSURI]Stepler"),
             ("10887", "[MCP2.0_VICTORIA]Stepler"),
             ("11171", "[MCP2.0_YOGA]Stepler"),
             ("11193", "[MCP2.0_ANTELOPE]Stepler"))
-        ),
+         ),
     ]
     suite_id = models.CharField(max_length=20, choices=SUITE_CHOICES)
     suite_name = models.CharField(max_length=100, blank=True)
diff --git a/testrail_bot/control/templates/control/update_run.html b/testrail_bot/control/templates/control/update_run.html
index 3082fec..1ca8930 100644
--- a/testrail_bot/control/templates/control/update_run.html
+++ b/testrail_bot/control/templates/control/update_run.html
@@ -70,6 +70,14 @@
         <div class="col-sm-auto mx-3">
           {% bootstrap_field form.created_before size='sm' %}
         </div>
+        <div class="col-md-5">
+          {% bootstrap_field form.caching_tests_enabled size='sm'%}
+            Already checked tests:
+            {% for test_id in checked_tests %}
+                <a href="https://mirantis.testrail.com/index.php?/tests/view/{{ test_id }}">{{ test_id }}</a>
+            {% endfor %}
+        </div>
+
       </div>
       <div class="p-3 mt-5 bg-light bg-gradient">
         <h5>Text filters</h5>
@@ -117,10 +125,6 @@
     </div>
     {% endbuttons %}
   </form>
-  Already checked tests:
-  {% for test_id in checked_tests %}
-      <a href="https://mirantis.testrail.com/index.php?/tests/view/{{ test_id }}">{{ test_id }}</a>
-  {% endfor %}
 
 </div>
 {% endblock %}
\ No newline at end of file