def background_issues_update(task): """Update linked IssueTracker issues for provided objects.""" # pylint: disable=too-many-locals try: from ggrc.integrations import issuetracker_bulk_sync comment_updater = issuetracker_bulk_sync.IssueTrackerCommentUpdater() bulk_updater = issuetracker_bulk_sync.IssueTrackerBulkUpdater() bulk_creator = issuetracker_bulk_sync.IssueTrackerBulkCreator() params = getattr(task, "parameters", {}) revision_ids = params.get("revision_ids") mail_data = params.get("mail_data") update_args = integration_utils.build_updated_objects_args( revision_ids, mail_data) update_errors = None if update_args.get("objects"): (_, update_errors) = bulk_updater.sync_issuetracker(update_args) create_args = integration_utils.build_created_objects_args( revision_ids, mail_data) create_errors = None if create_args.get("objects"): (_, create_errors) = bulk_creator.sync_issuetracker(create_args) comment_args = integration_utils.build_comments_args( revision_ids, mail_data) if comment_args.get("comments"): comment_updater.sync_issuetracker(comment_args) errors = _merge_errors(create_errors, update_errors) return bulk_creator.make_response(errors) except integrations_errors.Error as error: logger.error('Bulk issue update failed with error: %s', error.message) raise exceptions.BadRequest(error.message)
def background_issues_update(task): """Update linked IssueTracker issues for provided objects.""" # pylint: disable=too-many-locals try: from ggrc.integrations import issuetracker_bulk_sync comment_updater = issuetracker_bulk_sync.IssueTrackerCommentUpdater() bulk_updater = issuetracker_bulk_sync.IssueTrackerBulkUpdater() bulk_creator = issuetracker_bulk_sync.IssueTrackerBulkCreator() params = getattr(task, "parameters", {}) revision_ids = params.get("revision_ids") mail_data = params.get("mail_data") update_args = integration_utils.build_updated_objects_args(revision_ids, mail_data) update_errors = None if update_args.get("objects"): (_, update_errors) = bulk_updater.sync_issuetracker(update_args) create_args = integration_utils.build_created_objects_args(revision_ids, mail_data) create_errors = None if create_args.get("objects"): (_, create_errors) = bulk_creator.sync_issuetracker(create_args) comment_args = integration_utils.build_comments_args(revision_ids, mail_data) if comment_args.get("comments"): comment_updater.sync_issuetracker(comment_args) errors = _merge_errors(create_errors, update_errors) return bulk_creator.make_response(errors) except integrations_errors.Error as error: logger.error('Bulk issue update failed with error: %s', error.message) raise exceptions.BadRequest(error.message)