def update_job_source(guid, buid, name, clear_cache=False):
    """Composed method for resopnding to a guid update."""

    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]
    for job in jobs:
        job['link'] = make_redirect(job, bu).make_link()
    add_jobs(jobs)
    remove_expired_jobs(buid, jobs)

    # Update business information
    bu.associated_jobs = len(jobs)
    bu.date_updated = datetime.datetime.utcnow()
    bu.save()
    if clear_cache:
        # Clear cache in 25 minutes to allow for solr replication
        tasks.task_clear_bu_cache.delay(buid=bu.id, countdown=1500)
Beispiel #2
0
def add_redirect(job, bu):
    job['link'] = make_redirect(job, bu).make_link()
    return job
Beispiel #3
0
def add_redirect(job, bu):
    job['link'] = make_redirect(job, bu).make_link()
    return job