# Path: django_datawatch/datawatch.py
# class DatawatchHandler(object):
# class Scheduler(object):
#     def __init__(self):
#     def autodiscover_checks(self, module_name='checks'):
#     def register(self, check_class):
#     def get_all_registered_checks(self):
#     def get_all_registered_check_slugs(self):
#     def get_check_class(self, slug):
#     def get_checks_for_related_model(self, model):
#     def get_checks_for_model(self, model):
#     def get_slug(self, module, class_name):
#     def get_backend(self):
#     def delete_results(self, sender, instance):
#     def update_related(self, sender, instance):
#     def run_checks(self, force=False, slug=None):
#     def get_last_executions(self):
# def make_model_uid(model):
# def delete_results(sender, instance, using, **kwargs):
# def run_checks(sender, instance, created, raw, using, **kwargs):


from django.core.management.base import BaseCommand
from django_datawatch.datawatch import datawatch
# -*- coding: UTF-8 -*-



class Command(BaseCommand):
    def add_arguments(self, parser):
        parser.add_argument(
            '--slug',
            dest='slug',
            default=None,
            help='Slug of check to refresh, all checks will be refreshed if slug is not provided',
        )

    def handle(self, slug, *args, **options):
        # refresh single check
        if slug:
            self.refresh(slug)
            return

        # refresh all
        checks = datawatch.get_all_registered_checks()
        for check_class in checks:
            check = check_class()
            self.refresh(check.slug)

    def refresh(self, slug):

# Path: django_datawatch/datawatch.py
# class DatawatchHandler(object):
# class Scheduler(object):
#     def __init__(self):
#     def autodiscover_checks(self, module_name='checks'):
#     def register(self, check_class):
#     def get_all_registered_checks(self):
#     def get_all_registered_check_slugs(self):
#     def get_check_class(self, slug):
#     def get_checks_for_related_model(self, model):
#     def get_checks_for_model(self, model):
#     def get_slug(self, module, class_name):
#     def get_backend(self):
#     def delete_results(self, sender, instance):
#     def update_related(self, sender, instance):
#     def run_checks(self, force=False, slug=None):
#     def get_last_executions(self):
# def make_model_uid(model):
# def delete_results(sender, instance, using, **kwargs):
# def run_checks(sender, instance, created, raw, using, **kwargs):


# Path: django_datawatch/management/commands/datawatch_refresh_results.py
from django.core.management.base import BaseCommand
from django_datawatch.datawatch import datawatch

# -*- coding: UTF-8 -*-



class Command(BaseCommand):
    def add_arguments(self, parser):
        parser.add_argument(
            '--slug',
            dest='slug',
            default=None,
            help='Slug of check to refresh, all checks will be refreshed if slug is not provided',
        )

    def handle(self, slug, *args, **options):
        # refresh single check
        if slug:
            self.refresh(slug)
            return

        # refresh all
        checks = datawatch.get_all_registered_checks()
        for check_class in checks:
            check = check_class()
            self.refresh(check.slug)

    def refresh(self, slug):

        backend = datawatch.get_backend()