'Runs add_or_update_issue for every AuditorSetting, filtered by technology
and accounts, if provided.'

def sync_issues(self, accounts=None, tech_name=None):

    query = AuditorSettings.query.join((Technology, (Technology.id == AuditorSettings.tech_id))).join((Account, (Account.id == AuditorSettings.account_id))).filter((AuditorSettings.disabled == False))
    if accounts:
        query = query.filter(Account.name.in_(accounts))
    if tech_name:
        query = query.filter((Technology.name == tech_name))
    for auditorsetting in query.all():
        unjustified = [issue for issue in auditorsetting.issues if (not issue.justified)]
        self.add_or_update_issue(auditorsetting.issue_text, auditorsetting.technology.name, auditorsetting.account.name, len(unjustified))
