'Searches for existing tickets based on the summary. If one exists,
it will update the count and preserve any leading description text. If not, it will create a ticket.'

def add_or_update_issue(self, issue, technology, account, count):

    summary = '{0}    -    {1}    -    {2}'.format(issue, technology, account)
    summary_search = summary.replace('-    ', '')
    jql = 'project={0}    and    summary~"{1}"'.format(self.project, summary_search)
    issues = self.client.search_issues(jql)
    url = '{0}/#/issues/-/{1}/{2}/-/-/True/{3}/1/25'.format(self.url, technology, account, urllib.quote(issue, ''))
    timezone = time.tzname[time.localtime().tm_isdst]
    description = 'This    ticket    was    automatically    created    by    Security    Monkey.    DO    NOT    EDIT    SUMMARY    OR    BELOW    THIS    LINE\nNumber    of    issues:    {0}\nAccount:    {1}\n[View    on    Security    Monkey|{2}]\nLast    updated:    {3}    {4}'.format(count, account, url, datetime.datetime.now().isoformat(), timezone)
    for issue in issues:
        if (issue.fields.summary == summary):
            old_desc = issue.fields.description
            old_desc = old_desc[:old_desc.find('This    ticket    was    automatically    created    by    Security    Monkey')]
            issue.update(description=(old_desc + description))
            app.logger.debug('Updated    issue    {}    ({})'.format(summary, issue.key))
            if self.disable_transitions:
                return
            if ((issue.fields.status.name == app.config.get('JIRA_CLOSED', 'Closed')) and count):
                self.open_issue(issue)
                app.logger.debug('Reopened    issue    {}    ({})'.format(summary, issue.key))
            elif ((issue.fields.status.name != app.config.get('JIRA_CLOSED', 'Closed')) and (count == 0)):
                self.close_issue(issue)
                app.logger.debug('Closed    issue    {}    ({})'.format(summary, issue.key))
            return
    if (count == 0):
        return
    jira_args = {'project': {'key': self.project}, 'issuetype': {'name': self.issue_type}, 'summary': summary, 'description': description}
    if (self.assignee is not None):
        jira_args['assignee'] = {'name': self.assignee}
    try:
        issue = self.client.create_issue(**jira_args)
        app.logger.debug('Created    issue    {}    ({})'.format(summary, issue.key))
    except Exception as e:
        app.logger.error('Error    creating    issue    {}:    {}'.format(summary, e))
