def update_product(product, component=None): kwargs = {'product': product, 'scrum_only': False} if component: kwargs['component'] = component bug_ids = bugzilla.get_bug_ids(**kwargs) log.debug('Updating %d bugs from %s', len(bug_ids), kwargs) for bids in chunked(bug_ids, 100): update_bugs.delay(bids)
def update_product(product, component=None): kwargs = {'product': product, 'scrum_only': True} if component and component != ALL_COMPONENTS: kwargs['component'] = component bug_ids = bugzilla.get_bug_ids(**kwargs) log.debug('Updating %d bugs from %s', len(bug_ids), kwargs) for bids in chunked(bug_ids, 100): update_bugs.delay(bids)
def fetch_new_bugs(): bug_ids = bugzilla.get_bug_ids() bug_ids = set(bug_ids) already_fetched_bugs = Bug.objects.only('id') already_fetched_bugs = [ b.id for b in already_fetched_bugs ] already_fetched_bugs = set(already_fetched_bugs) diff = bug_ids.difference(already_fetched_bugs) for bids in chunked(diff, 100): update_bugs.delay(bids)
def update_bug_chunks(bugs, chunk_size=100): """ Update bugs in chunks of `chunk_size`. :param bugs: Iterable of bug objects. """ numbugs = 0 for bchunk in chunked(bugs, chunk_size): numbugs += len(bugs) log.debug("Updating %d bugs", len(bugs)) update_bugs.delay([b.id for b in bchunk]) log.debug("Total bugs updated: %d", numbugs)