def update_agency_totals(): all_agencies = Agency.all() # For each agency, update their report counts for every domain they have. for agency in all_agencies: # TODO: Do direct DB queries for answers, rather than iterating. # Analytics eligible = Domain.eligible_for_agency(agency['slug'], 'analytics') agency_report = { 'eligible': len(eligible), 'participating': 0 } for domain in eligible: report = domain['analytics'] if report['participating'] == True: agency_report['participating'] += 1 print("[%s][%s] Adding report." % (agency['slug'], 'analytics')) Agency.add_report(agency['slug'], 'analytics', agency_report) # HTTPS eligible = Domain.eligible_for_agency(agency['slug'], 'https') eligible_https = list(map(lambda w: w['https'], eligible)) agency_report = total_https_report(eligible_https) # agency_report['subdomains'] = total_https_subdomain_report(eligible) print("[%s][%s] Adding report." % (agency['slug'], 'https')) Agency.add_report(agency['slug'], 'https', agency_report)
def update_agency_totals(): all_agencies = Agency.all() # For each agency, update their report counts for every domain they have. for agency in all_agencies: # TODO: Do direct DB queries for answers, rather than iterating. # Analytics eligible = Domain.eligible_for_agency(agency['slug'], 'analytics') agency_report = { 'eligible': len(eligible), 'participating': 0 } for domain in eligible: report = domain['analytics'] if report['participating'] == True: agency_report['participating'] += 1 print("[%s][%s] Adding report." % (agency['slug'], 'analytics')) Agency.add_report(agency['slug'], 'analytics', agency_report) # HTTPS eligible = Domain.eligible_for_agency(agency['slug'], 'https') agency_report = { 'eligible': len(eligible), 'uses': 0, 'enforces': 0, 'hsts': 0, 'grade': 0 } for domain in eligible: report = domain['https'] # Needs to be enabled, with issues is allowed if report['uses'] >= 1: agency_report['uses'] += 1 # Needs to be Default or Strict to be 'Yes' if report['enforces'] >= 2: agency_report['enforces'] += 1 # Needs to be present with >= 1 year max-age for canonical endpoint if report['hsts'] >= 2: agency_report['hsts'] += 1 # Needs to be A- or above if report['grade'] >= 4: agency_report['grade'] += 1 print("[%s][%s] Adding report." % (agency['slug'], 'https')) Agency.add_report(agency['slug'], 'https', agency_report)
def update_agency_totals(): all_agencies = Agency.all() # For each agency, update their report counts for every domain they have. for agency in all_agencies: # TODO: Do direct DB queries for answers, rather than iterating. # Analytics eligible = Domain.eligible_for_agency(agency['slug'], 'analytics') agency_report = { 'eligible': len(eligible), 'participating': 0 } for domain in eligible: report = domain['analytics'] if report['participating'] == True: agency_report['participating'] += 1 print("[%s][%s] Adding report." % (agency['slug'], 'analytics')) Agency.add_report(agency['slug'], 'analytics', agency_report) # HTTPS eligible = Domain.eligible_for_agency(agency['slug'], 'https') agency_report = { 'eligible': len(eligible), 'uses': 0, 'enforces': 0, 'hsts': 0, 'grade': 0 } for domain in eligible: report = domain['https'] # Needs to be enabled, with issues is allowed if report['uses'] >= 1: agency_report['uses'] += 1 # Needs to be Default or Strict to be 'Yes' if report['enforces'] >= 2: agency_report['enforces'] += 1 # Needs to be at least partially present if report['hsts'] >= 1: agency_report['hsts'] += 1 # Needs to be A- or above if report['grade'] >= 4: agency_report['grade'] += 1 print("[%s][%s] Adding report." % (agency['slug'], 'https')) Agency.add_report(agency['slug'], 'https', agency_report)
def update_agency_totals(): all_agencies = Agency.all() # For each agency, update their report counts for every domain they have. for agency in all_agencies: # TODO: Do direct DB queries for answers, rather than iterating. # Analytics eligible = Domain.eligible_for_agency(agency['slug'], 'analytics') agency_report = {'eligible': len(eligible), 'participating': 0} for domain in eligible: report = domain['analytics'] if report['participating'] == True: agency_report['participating'] += 1 print("[%s][%s] Adding report." % (agency['slug'], 'analytics')) Agency.add_report(agency['slug'], 'analytics', agency_report) # HTTPS eligible = Domain.eligible_for_agency(agency['slug'], 'https') eligible_https = list(map(lambda w: w['https'], eligible)) agency_report = total_https_report(eligible_https) # agency_report['subdomains'] = total_https_subdomain_report(eligible) print("[%s][%s] Adding report." % (agency['slug'], 'https')) Agency.add_report(agency['slug'], 'https', agency_report) # A11Y eligible = Domain.eligible_for_agency(agency['slug'], 'a11y') pages_count = len(eligible) errors = {e: 0 for e in A11Y_ERRORS.values()} for domain in eligible: a11y = domain['a11y'] for error in a11y['errorlist']: errors[error] += a11y['errorlist'][error] total_errors = sum(errors.values()) avg_errors_per_page = ('n/a' if pages_count == 0 else round( float(total_errors) / pages_count, 2)) agency_report = { 'pages_count': pages_count, 'eligible': pages_count, 'Average Errors per Page': avg_errors_per_page } if pages_count: averages = ({ e: round(mean([d['a11y']['errorlist'][e] for d in eligible]), 2) for e in A11Y_ERRORS.values() }) else: averages = {e: 'n/a' for e in A11Y_ERRORS.values()} agency_report.update(averages) print("[%s][%s] Adding report." % (agency['slug'], 'a11y')) Agency.add_report(agency['slug'], 'a11y', agency_report) # Customer satisfaction eligible = Domain.eligible_for_agency(agency['slug'], 'cust_sat') agency_report = {'eligible': len(eligible), 'participating': 0} agency_report['participating'] += len( [d for d in eligible if d['cust_sat']['participating']]) print("[%s][%s] Adding report." % (agency['slug'], 'cust_sat')) Agency.add_report(agency['slug'], 'cust_sat', agency_report)
def update_agency_totals(): all_agencies = Agency.all() # For each agency, update their report counts for every domain they have. for agency in all_agencies: # TODO: Do direct DB queries for answers, rather than iterating. # Analytics eligible = Domain.eligible_for_agency(agency['slug'], 'analytics') agency_report = { 'eligible': len(eligible), 'participating': 0 } for domain in eligible: report = domain['analytics'] if report['participating'] == True: agency_report['participating'] += 1 print("[%s][%s] Adding report." % (agency['slug'], 'analytics')) Agency.add_report(agency['slug'], 'analytics', agency_report) # HTTPS eligible = Domain.eligible_for_agency(agency['slug'], 'https') eligible_https = list(map(lambda w: w['https'], eligible)) agency_report = total_https_report(eligible_https) # agency_report['subdomains'] = total_https_subdomain_report(eligible) print("[%s][%s] Adding report." % (agency['slug'], 'https')) Agency.add_report(agency['slug'], 'https', agency_report) # A11Y eligible = Domain.eligible_for_agency(agency['slug'], 'a11y') pages_count = len(eligible) errors = {e:0 for e in A11Y_ERRORS.values()} for domain in eligible: a11y = domain['a11y'] for error in a11y['errorlist']: errors[error] += a11y['errorlist'][error] total_errors = sum(errors.values()) avg_errors_per_page = ( 'n/a' if pages_count == 0 else round(float(total_errors) / pages_count, 2) ) agency_report = { 'pages_count': pages_count, 'eligible': pages_count, 'Average Errors per Page': avg_errors_per_page } if pages_count: averages = ({ e: round(mean([d['a11y']['errorlist'][e] for d in eligible]), 2) for e in A11Y_ERRORS.values() }) else: averages = {e: 'n/a' for e in A11Y_ERRORS.values()} agency_report.update(averages) print("[%s][%s] Adding report." % (agency['slug'], 'a11y')) Agency.add_report(agency['slug'], 'a11y', agency_report) # Customer satisfaction eligible = Domain.eligible_for_agency(agency['slug'], 'cust_sat') agency_report = { 'eligible': len(eligible), 'participating': 0 } agency_report['participating'] += len([d for d in eligible if d['cust_sat']['participating']]) print("[%s][%s] Adding report." % (agency['slug'], 'cust_sat')) Agency.add_report(agency['slug'], 'cust_sat', agency_report)