def subReqCandScorer(requisitionId, db, logFile):
    try:
        scBeginTime = datetime.now()
        reqParsed = list(db.requisition_skills_from_parsed_requisition.find({"requisition_id":requisitionId},{"parsedWords":1,"_id":0}))
        for words in reqParsed:
            if(words["parsedWords"] == []):
                reqParsed = []

        if(len(reqParsed) == 0):
            status = scoreInserter(requisitionId)
            logFile.write("[" + datetime.now().isoformat() + "] RequisitionId [" + str(requisitionId) + "] No description" + "\n")
            return("No Requisition description")

        jobid = list(db.requisition.find({"requisition_id":requisitionId},{"new_global_job_category_id":1,"_id":0}))
        for id in jobid:
            gjid1 = id["new_global_job_category_id"]
        idealSkillList = db.ideal_candidate_characteritics.find_one({"global_job_category_id":gjid1},{"Skills":1,"_id":0})
        if(idealSkillList is None):
            idealSkills = 'NA'
        else:
            idealSkills = idealSkillList['Skills']
        status = reqScorer(reqParsed, jobid, idealSkills, requisitionId)
        logFile.write("[" + datetime.now().isoformat() + "] RequisitionId [" + str(requisitionId) + "] Submitted candidates scoring complete. Elapsed time [" + str(datetime.now() - scBeginTime) + "]" + "\n")
        return("Scoring Complete")
    except Exception as e:
        DebugException(e)
        #print("Requisition Incremental Scorer failed due to error [" + str(e) + "]")
        logFile.write("[" + datetime.now().isoformat() + "] RequisitionId [" + str(requisitionId) + "] [subReqCandScorer()] Requisition Incremental Scorer failed due to error [" + str(e) + "]" + "\n")
Ejemplo n.º 2
0
def requisitionIncrementalScorer(requisitionId,db):
    try:

        reqParsed = list(db.requisition_skills_from_parsed_requisition.find({"requisition_id":requisitionId},{"parsedWords":1,"_id":0}))
        for words in reqParsed:
            if(words["parsedWords"] == []):
                reqParsed = []
        if(len(reqParsed) == 0):
            status = scoreInserter(requisitionId)
            return("No Requisition description")
        ### - Working on Submitted Candidates
        jobid = list(db.requisition.find({"requisition_id":requisitionId},{"global_job_category_id":1,"_id":0}))
        for id in jobid:
            gjid1 = id["global_job_category_id"]
        idealSkillList = db.ideal_candidate_characteritics.find_one({"global_job_category_id":gjid1},{"Skills":1,"_id":0})
        idealSkills = idealSkillList['Skills']
        status = reqScorer(reqParsed,jobid,idealSkills)

        ## - Search & Score
        candidates = list(db.category_candidate_map.find({"global_job_category_id":id},{"candidates":1,"_id":0}))
        for candidate in candidates:
            candidateId = candidate["candidates"]
        status = candidateScorer(candidateId,reqParsed,idealSkills,requisitionId)
        return("Scoring Complete")
    except Exception as e:
        DebugException(e)
        print("Requisition Incremental Scorer failed due to error [" + str(e) + "]")
def candidateIncrementalScorer(candidateId, db):
    #print(str(candidateId))
    candIdList = [candidateId]
    try:
        ##Working on Submitted requisitions
        requisitionList = list(db.requisition_candidate.find({"candidate_id":candidateId}).distinct("requisition_id"))
        if(len(requisitionList) > 0):
            for requisition in requisitionList:
                reqParsed = list(db.requisition_skills_from_parsed_requisition.find({"requisition_id":requisition},{"parsedWords":1,"_id":0}))
                for words in reqParsed:
                    if(words["parsedWords"] == []):
                        reqParsed = []
                if(len(reqParsed) == 0):
                    status = scoreInserter(requisition)
                    continue

                jobid = list(db.requisition.find({"requisition_id":requisition},{"new_global_job_category_id":1,"_id":0}))
                for id in jobid:
                    gjid1 = id["new_global_job_category_id"]
                idealSkillList = db.ideal_candidate_characteritics.find_one({"global_job_category_id":gjid1},{"Skills":1,"_id":0})
                idealSkills = idealSkillList['Skills']
                status = reqScorer(reqParsed,jobid,idealSkills,requisition)

        ##Working on Classified Job Id's
        jobId = list(db.category_candidate_map.find({"candidates":candidateId}).distinct("global_job_category_id"))
        for id in jobId:
            #print("Working on Job Category %s" %(id))
            #requisitionList = list(db.requisition.find({"new_global_job_category_id": id,"pre_identified_req": False},{"requisition_id":1,"_id":0}))
            requisitionList = list(db.requisition.find({"new_global_job_category_id": id,"pre_identified_req": False,"req_status_id" : {"$in":statusID}},{"requisition_id":1,"_id":0}))
            if(not requisitionList):
                #print("No Requisition for this Job ID - %s " % (id))
                continue
            idealSkillList = db.ideal_candidate_characteritics.find_one({"global_job_category_id":id},{"Skills":1,"_id":0})
            if (idealSkillList is None):
                idealSkills = 'NA'
            else:
                idealSkills = idealSkillList['Skills']
            for requisition in requisitionList:
                #print("Working on Requisition %s for Job Category %s" %(requisition["requisition_id"],id))
                reqParsed = list(db.requisition_skills_from_parsed_requisition.find({"requisition_id": requisition["requisition_id"]},{"parsedWords":1,"_id":0}))
                #print("Working on Requisition - %s" % requisition)
                if(len(reqParsed)==0):
                    #print("No Requisition Description - Time Elapsed %s" % (time.time() - reqTime))
                    continue
                status = candidateScorer(candIdList, reqParsed, idealSkills, requisition["requisition_id"])

        return("Scoring Complete")

    except Exception as e:
        DebugException(e)
        print("Candidate Incremental Scorer failed due to error [" + str(e) + "]")
def requisitionIncrementalScorer(requisitionId, db, logFile):
    try:

        reqParsed = list(db.requisition_skills_from_parsed_requisition.find({"requisition_id":requisitionId},{"parsedWords":1,"_id":0}))
        for words in reqParsed:
            if(words["parsedWords"] == []):
                reqParsed = []
        if(len(reqParsed) == 0):
            status = scoreInserter(requisitionId)
            return("No Requisition description")
            logFile.write("[" + datetime.now().isoformat() + "] RequisitionId [" + str(requisitionId) + "] No description" + "\n")

        ### - Submitted Candidates processing
        scBeginTime = datetime.now()
        candidateCount = db.requisition_candidate.find({"requisition_id":requisitionId}).count()
        jobid = list(db.requisition.find({"requisition_id": requisitionId}, {"new_global_job_category_id": 1, "_id": 0}))
        for id in jobid:
            gjid1 = id["new_global_job_category_id"]
        idealSkillList = db.ideal_candidate_characteritics.find_one({"global_job_category_id": gjid1}, {"Skills": 1, "_id": 0})
        if(idealSkillList is None):
            idealSkills = 'NA'
        else:
            idealSkills = idealSkillList['Skills']
        if(candidateCount >=1):
            #print("Working on Submitted Candidates")
            status = reqScorer(reqParsed, jobid, idealSkills, requisitionId)
            logFile.write("[" + datetime.now().isoformat() + "] RequisitionId [" + str(requisitionId) + "] Submitted candidates scoring complete. Candidate Count ["+ str(candidateCount) + "] Elapsed time [" + str(datetime.now() - scBeginTime) + "]" + "\n")
        else:
            logFile.write("[" + datetime.now().isoformat() + "] RequisitionId [" + str(requisitionId) + "] no submitted candidates found" + "\n")

        ## - Search & Score
        ssBeginTime = datetime.now()
        candidateList = []
        candidates = list(db.category_candidate_map.find({"global_job_category_id":gjid1}, {"candidates":1,"_id":0}))
        for candidate in candidates:
            candidateList = candidate["candidates"]
        candidateTotal = len(candidateList)
        if(candidateTotal == 0):
            logFile.write("[" + datetime.now().isoformat() + "] RequisitionId [" + str(requisitionId) + "] No Candidates associated to this Job Category [" + str(gjid1) + "]" + "\n")
            #print("No Candidates associated to this Job Category")
            return("Scoring Method Completed Successfully")
        #print("Requisition %s has %s affiliated candidates" % (requisitionId, candidateTotal))
        status = candidateScorer(candidateList, reqParsed, idealSkills, requisitionId)
        logFile.write("[" + datetime.now().isoformat() + "] RequisitionId [" + str(requisitionId) + "] Search & Score scoring complete. Candidate Count ["+ str(candidateTotal) + "] Elapsed time [" + str(datetime.now() - ssBeginTime) + "]" + "\n")
        return("Scoring Complete")
    except Exception as e:
        DebugException(e)
        logFile.write("[" + datetime.now().isoformat() + "] RequisitionId [" + str(requisitionId) + "] [requisitionIncrementalScorer()] Requisition Incremental Scorer failed due to error [" + str(e) + "]" + "\n")
def subReqCandScorer(requisitionId,db):
    try:
        reqParsed = list(db.requisition_skills_from_parsed_requisition.find({"requisition_id":requisitionId},{"parsedWords":1,"_id":0}))
        for words in reqParsed:
            if(words["parsedWords"] == []):
                reqParsed = []
        if(len(reqParsed) == 0):
            status = scoreInserter(requisitionId)
            return("No Requisition description")
        jobid = list(db.requisition.find({"requisition_id":requisitionId},{"new_global_job_category_id":1,"_id":0}))
        for id in jobid:
            gjid1 = id["new_global_job_category_id"]
        idealSkillList = db.ideal_candidate_characteritics.find_one({"global_job_category_id":gjid1},{"Skills":1,"_id":0})
        idealSkills = idealSkillList['Skills']
        status = reqScorer(reqParsed,jobid,idealSkills,requisitionId)
        return("Scoring Complete")
    except Exception as e:
        DebugException(e)
        print("Requisition Incremental Scorer failed due to error [" + str(e) + "]")