# Path: src/sitecheck/models.py
# class SiteCheck(models.Model):
#     site = models.ForeignKey('tlssite.Site', related_name='checks', on_delete=models.PROTECT)
#     urgent = models.BooleanField(default=False)
#     start_time = models.DateTimeField(null=True, blank=True)
#     status = models.TextField(null=True, blank=True)
#     finish_time = models.DateTimeField(null=True, blank=True)
#     json_result = models.TextField(null=True, blank=True)
#     status_message = models.TextField(null=True, blank=True)
# 
#     def __str__(self):
#         return "#%s %s: %s - %s (%s)" % (self.id, self.site.hostname, self.start_time, self.finish_time, self.status)
# 
#     class Meta:
#         ordering = ['-finish_time']


from .models import SiteCheck

def sitecheck_processor(request):
    return {
        'pendingchecks': SiteCheck.objects.filter(start_time__isnull=True).count(),

# Path: src/sitecheck/models.py
# class SiteCheck(models.Model):
#     site = models.ForeignKey('tlssite.Site', related_name='checks', on_delete=models.PROTECT)
#     urgent = models.BooleanField(default=False)
#     start_time = models.DateTimeField(null=True, blank=True)
#     status = models.TextField(null=True, blank=True)
#     finish_time = models.DateTimeField(null=True, blank=True)
#     json_result = models.TextField(null=True, blank=True)
#     status_message = models.TextField(null=True, blank=True)
# 
#     def __str__(self):
#         return "#%s %s: %s - %s (%s)" % (self.id, self.site.hostname, self.start_time, self.finish_time, self.status)
# 
#     class Meta:
#         ordering = ['-finish_time']


# Path: src/sitecheck/context_processors.py
from .models import SiteCheck


def sitecheck_processor(request):
    return {
        'pendingchecks': SiteCheck.objects.filter(start_time__isnull=True).count(),

        'runningchecks': SiteCheck.objects.filter(start_time__isnull=False, finish_time__isnull=True).count(),