Ejemplo n.º 1
0
 def get_blacklist_domain_count(cls, db):
     ungrouped = defaultdict(int)
     for urls, count in Violation.get_group_by_value_for_key(db, 'blacklist.domains'):
         for url in urls:
             domain, null = get_domain_from_url(url)
             ungrouped[domain] += count
     blacklist = sorted(ungrouped.items(), key=lambda xz: -xz[1])
     return [dict(zip(('domain', 'count'), x)) for x in blacklist]
Ejemplo n.º 2
0
 def get_blacklist_domain_count(cls, db):
     ungrouped = defaultdict(int)
     for urls, count in Violation.get_group_by_value_for_key(
             db, 'blacklist.domains'):
         for url in urls:
             domain, null = get_domain_from_url(url)
             ungrouped[domain] += count
     blacklist = sorted(ungrouped.items(), key=lambda xz: -xz[1])
     return [dict(zip(('domain', 'count'), x)) for x in blacklist]
Ejemplo n.º 3
0
    def add_violation(self, key, value, points, domain):
        if self.is_complete:
            raise ValueError("Can't add anything to a completed review.")

        from holmes.models.violation import Violation  # to avoid circular dependency

        violation = Violation(key=key,
                              value=value,
                              points=int(float(points)),
                              domain=domain)

        self.violations.append(violation)
Ejemplo n.º 4
0
    def get_violation_count_for_domains(cls, db):
        grouped = {}

        violations_count = Violation.get_group_by_key_id_for_all_domains(db)

        for key_id, domain_name, count in violations_count:

            if key_id not in grouped:
                grouped[key_id] = []

            grouped[key_id].append({'name': domain_name, 'count': count})

        return grouped
Ejemplo n.º 5
0
    def get_violation_count_for_domains(cls, db):
        grouped = {}

        violations_count = Violation.get_group_by_key_id_for_all_domains(db)

        for key_id, domain_name, count in violations_count:

            if key_id not in grouped:
                grouped[key_id] = []

            grouped[key_id].append({
                'name': domain_name,
                'count': count
            })

        return grouped
Ejemplo n.º 6
0
    def get_top_violations_in_category_for_all_domains(cls, db, limit):
        grouped = {}

        top_violations = Violation.get_top_in_category_for_all_domains(db, limit)

        for domain_name, key_category_id, key_name, count in top_violations:

            if domain_name not in grouped:
                grouped[domain_name] = {}

            if key_category_id not in grouped[domain_name]:
                grouped[domain_name][key_category_id] = []

            grouped[domain_name][key_category_id].append({
                'key_name': key_name,
                'count': count
            })

        return grouped
Ejemplo n.º 7
0
    def get_top_violations_in_category_for_all_domains(cls, db, limit):
        grouped = {}

        top_violations = Violation.get_top_in_category_for_all_domains(
            db, limit)

        for domain_name, key_category_id, key_name, count in top_violations:

            if domain_name not in grouped:
                grouped[domain_name] = {}

            if key_category_id not in grouped[domain_name]:
                grouped[domain_name][key_category_id] = []

            grouped[domain_name][key_category_id].append({
                'key_name': key_name,
                'count': count
            })

        return grouped