def add_to_solr(self): """ Microsites is expecting following fields: id (postajob.job.id), apply_info, city, company (company.id), country, country_short, date_new, date_updated, description, guid, link, on_sites, state, state_short, reqid, title, uid, and zipcode. """ jobs = self.solr_dict() if jobs: jobs = [transform_for_postajob(job) for job in jobs] add_jobs(jobs)
def update_job_source(guid, buid, name): """Composed method for resopnding to a guid update.""" assert re.match(r'^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$', guid.upper()), \ "%s is not a valid guid" % guid assert re.match(r'^\d+$', str(buid)), "%s is not a valid buid" % buid logger.info("Updating Job Source %s", guid) # Make the BusinessUnit and Company create_businessunit(buid) bu = BusinessUnit.objects.get(id=buid) bu.title = name bu.save() add_company(bu) # Lookup the jobs, filter then, transform them, and then load the jobs zf = get_jobsfs_zipfile(guid) jobs = get_jobs_from_zipfile(zf, guid) jobs = filter_current_jobs(jobs, bu) jobs = (hr_xml_to_json(job, bu) for job in jobs) jobs = (add_redirect(job, bu) for job in jobs) # AT&T Showed that large numbers of MOCs can cause import issues due to the size of documents. # Therefore, when processing AT&T lower the document chunk size. if int(buid) == 19389: logger.warn( "AT&T has large amounts of mapped_mocs, that cause problems. Reducing chunk size." ) upload_chunk_size = 64 else: upload_chunk_size = 1024 job_ids = add_jobs(jobs, upload_chunk_size) remove_expired_jobs(buid, job_ids) # Update business information bu.associated_jobs = len(job_ids) bu.date_updated = datetime.datetime.utcnow() bu.save()
def update_job_source(guid, buid, name): """Composed method for resopnding to a guid update.""" assert re.match(r'^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$', guid.upper()), \ "%s is not a valid guid" % guid assert re.match(r'^\d+$', str(buid)), "%s is not a valid buid" % buid logger.info("Updating Job Source %s", guid) # Make the BusinessUnit and Company create_businessunit(buid) bu = BusinessUnit.objects.get(id=buid) bu.title = name bu.save() add_company(bu) # Lookup the jobs, filter then, transform them, and then load the jobs zf = get_jobsfs_zipfile(guid) jobs = get_jobs_from_zipfile(zf, guid) jobs = filter_current_jobs(jobs, bu) jobs = (hr_xml_to_json(job, bu) for job in jobs) jobs = (add_redirect(job, bu) for job in jobs) # AT&T Showed that large numbers of MOCs can cause import issues due to the size of documents. # Therefore, when processing AT&T lower the document chunk size. if int(buid) == 19389: logger.warn("AT&T has large amounts of mapped_mocs, that cause problems. Reducing chunk size.") upload_chunk_size = 64 else: upload_chunk_size = 1024 job_ids = add_jobs(jobs, upload_chunk_size) remove_expired_jobs(buid, job_ids) # Update business information bu.associated_jobs = len(job_ids) bu.date_updated = datetime.datetime.utcnow() bu.save()