def update(self): """ Update bug used in this sync """ # Skip when it's already processed in instance if self.analysis is not None: logger.warn('Bug {} already processed.'.format(self.bugzilla_id)) return True # Do patch analysis try: self.analysis = bug_analysis(self.bugzilla_id, 'release') except Exception as e: logger.error('Patch analysis failed on {} : {}'.format( self.bugzilla_id, e)) # noqa # TODO: Add to report return False # Build html version of uplift comment if self.analysis.get('uplift_comment'): self.analysis['uplift_comment']['html'] = parse_uplift_comment( self.analysis['uplift_comment']['text'], self.bugzilla_id) return True
def update_bug(self, bug, use_db=True): """ Update a bug """ # Skip when it's already processed in instance bug_id = bug['id'] if bug_id in self.bugs: logger.warn('Bug {} already processed.'.format(bug_id)) return self.bugs[bug_id] # Compute the hash of the new bug bug_hash = compute_dict_hash(bug) if use_db: # Fetch or create existing bug result try: br = BugResult.query.filter_by(bugzilla_id=bug_id).one() logger.info('Update existing {}'.format(br)) # Check the bug has changed since last update if br.payload_hash == bug_hash: logger.info('Same bug hash, skip bug analysis {}'.format( br)) # noqa return br except NoResultFound: br = BugResult(bug_id) logger.info('Create new {}'.format(br)) else: # Create a new instance br = BugResult(bug_id) logger.info('Create new {}'.format(br)) # Do patch analysis try: analysis = bug_analysis(bug_id) except Exception as e: logger.error('Patch analysis failed on {} : {}'.format(bug_id, e)) return # Build html version of uplift comment if analysis['uplift_comment']: analysis['uplift_comment']['html'] = parse_uplift_comment( analysis['uplift_comment']['text'], bug_id) payload = { 'url': '{}/{}'.format(self.bugzilla_url, bug['id']), 'bug': bug, 'analysis': analysis, 'users': self.load_users(analysis), } br.payload = use_db and pickle.dumps(payload, 2) or payload br.payload_hash = bug_hash logger.info('Updated payload of {}'.format(br)) # Save in local cache self.bugs[bug_id] = br return br
def update_bug(self, bug, use_db=True): """ Update a bug """ # Skip when it's already processed in instance bug_id = bug['id'] if bug_id in self.bugs: logger.warn('Bug {} already processed.'.format(bug_id)) return self.bugs[bug_id] # Compute the hash of the new bug bug_hash = compute_dict_hash(bug) if use_db: # Fetch or create existing bug result try: br = BugResult.query.filter_by(bugzilla_id=bug_id).one() logger.info('Update existing {}'.format(br)) # Check the bug has changed since last update if br.payload_hash == bug_hash: logger.info('Same bug hash, skip bug analysis {}'.format(br)) # noqa return br except NoResultFound: br = BugResult(bug_id) logger.info('Create new {}'.format(br)) else: # Create a new instance br = BugResult(bug_id) logger.info('Create new {}'.format(br)) # Do patch analysis try: analysis = bug_analysis(bug_id) except Exception as e: logger.error('Patch analysis failed on {} : {}'.format(bug_id, e)) return # Build html version of uplift comment if analysis['uplift_comment']: analysis['uplift_comment']['html'] = parse_uplift_comment( analysis['uplift_comment']['text'], bug_id) payload = { 'url': '{}/{}'.format(self.bugzilla_url, bug['id']), 'bug': bug, 'analysis': analysis, 'users': self.load_users(analysis), } br.payload = use_db and pickle.dumps(payload, 2) or payload br.payload_hash = bug_hash logger.info('Updated payload of {}'.format(br)) # Save in local cache self.bugs[bug_id] = br return br
def update(self): ''' Update bug used in this sync ''' # Skip when it's already processed in instance if self.analysis is not None: logger.warn('Bug {} already processed.'.format(self.bugzilla_id)) return True # Do patch analysis try: self.analysis = bug_analysis(self.bugzilla_id, 'release') except Exception as e: logger.error('Patch analysis failed on {} : {}'.format(self.bugzilla_id, e)) # noqa # TODO: Add to report return False # Build html version of uplift comment if self.analysis.get('uplift_comment'): self.analysis['uplift_comment']['html'] = parse_uplift_comment( self.analysis['uplift_comment']['text'], self.bugzilla_id) return True