def store_jobs(job_collections, chunk_size): errors = [] for repository_name, jobs in job_collections.iteritems(): for collection in jobs.get_chunks(chunk_size=chunk_size): try: repository = Repository.objects.get(name=repository_name) collection.validate() store_job_data(repository, collection.get_collection_data()) except Exception: newrelic.agent.record_exception() errors.append({ "project": repository_name, "collection": "job", "message": traceback.format_exc() }) if errors: raise common.CollectionNotStoredException(errors)
def store_jobs(job_collections, chunk_size): errors = [] for repository, jobs in job_collections.iteritems(): with JobsModel(repository) as jm: for collection in jobs.get_chunks(chunk_size=chunk_size): try: collection.validate() jm.store_job_data(collection.get_collection_data()) except Exception: newrelic.agent.record_exception() errors.append({ "project": repository, "collection": "job", "message": traceback.format_exc() }) if errors: raise common.CollectionNotStoredException(errors)