def save_issues(self):
        """
        Save all new issues.  Delete all fixed issues.
        """
        app.logger.debug("\n\nSaving Issues.")
        for item in self.items:
            if not hasattr(item, 'db_item'):
                item.db_item = self.datastore._get_item(item.index, item.region, item.account, item.name)

            existing_issues = item.db_item.issues
            new_issues = item.audit_issues

            # Add new issues
            old_scored = [("{} -- {}".format(old_issue.issue, old_issue.notes), old_issue.score) for old_issue in existing_issues]
            for new_issue in new_issues:
                nk = "{} -- {}".format(new_issue.issue, new_issue.notes)
                if (nk, new_issue.score) not in old_scored:
                    app.logger.debug("Saving NEW issue {}".format(nk))
                    item.found_new_issue = True
                    item.confirmed_new_issues.append(new_issue)
                    item.db_item.issues.append(new_issue)
                    db.session.add(item.db_item)
                    db.session.add(new_issue)
                else:
                    for issue in existing_issues:
                        if issue.issue == new_issue.issue and issue.notes == new_issue.notes and issue.score == new_issue.score:
                            item.confirmed_existing_issues.append(issue)
                            break
                    key = "{}/{}/{}/{}".format(item.index, item.region, item.account, item.name)
                    app.logger.debug("Issue was previously found. Not overwriting.\n\t{}\n\t{}".format(key, nk))

            # Delete old issues
            new_scored = [("{} -- {}".format(new_issue.issue, new_issue.notes), new_issue.score) for new_issue in new_issues]
            for old_issue in existing_issues:
                ok = "{} -- {}".format(old_issue.issue, old_issue.notes)
                if (ok, old_issue.score) not in new_scored:
                    app.logger.debug("Deleting FIXED issue {}".format(ok))
                    item.confirmed_fixed_issues.append(old_issue)
                    db.session.delete(old_issue)

        db.session.commit()
        self._create_auditor_settings()
dataset/ETHPy150Open Netflix/security_monkey/security_monkey/auditor.py/Auditor.save_issues/original