Ejemplo n.º 1
0
            NewFields = [LatestState,LatestTimeStamp]
            EnhancedDuplicate.extend(NewFields)
            ActionList.append(EnhancedDuplicate)
        
    if (len(ActionList) != 0) : ActionLists.append(ActionList)   

# Iterate through ActionLists structure creating duplicate (counter) entries and removing
# duplicate vacancies.
DuplicateCount  = 0

for ActionList in ActionLists :

    # Add a duplicate counter value
    Fieldnames = ['engine_id','found']
    Fieldvalues = [str(Duplicate[0]),str(len(ActionList))]
    SQLcommand =  Db.GenSQLinsert(DuplicateTable,Fieldnames,DuplicateFields,Fieldvalues)
    SQLresponse = ( Db.SQLload(DbObject,DbCursor,SQLcommand,failure) )
    Errormessage = 'SQLresponse error for SQL command ' + '\"' + SQLcommand + '\"'
    if ( (SQLresponse) == failure ): File.Logerror(ErrorfileObject,module,Errormessage,warning)
    
    # Remove all but latest 'New' vacancy    
    for DuplicateIndex in range(0,(len(ActionList) - 1)) :
    
        Engine_Id = str(ActionList[DuplicateIndex][0])
        Vacancy_Id = str(ActionList[DuplicateIndex][1])
        Vacancy_Url = str(ActionList[DuplicateIndex][2])
    
        # Change state of duplicate vacancy to 'Dropped'
        PrimaryValues = {}
        VacancyUpdate = {}
        PrimaryValues['engine_id'] = Engine_Id
        SQLcommand = Db.GenSQLselect(VacancyTable, SelectCriteria)
        SQLresponse = Db.SQLload(DbObject, DbCursor, SQLcommand, failure)
        Errormessage = 'SQLresponse error for SQL command ' + '\"' + SQLcommand + '\"'
        if ((SQLresponse) == failure):
            File.Logerror(ErrorfileObject, module, Errormessage, warning)
        if (Db.GetSQLrowcount(SQLresponse) == 1): continue

        urlcount += 1
        Totalurlcount += 1

        # Add entry in table 'vacancy'.
        Fieldnames = [
            'engine_id', 'vacancy_id', 'vacancy_url', 'vacancy_state'
        ]
        Fieldvalues = [str(EngineIDList[EngineIndex]), Jobid, Joburl, 'New']
        SQLcommand = Db.GenSQLinsert(VacancyTable, Fieldnames, Vacancyfields,
                                     Fieldvalues)
        SQLresponse = (Db.SQLload(DbObject, DbCursor, SQLcommand, failure))
        Errormessage = 'SQLresponse error for SQL command ' + '\"' + SQLcommand + '\"'
        if ((SQLresponse) == failure):
            File.Logerror(ErrorfileObject, module, Errormessage, warning)

        # Add entry in table 'history' to reflect the change in state of the vacancy.
        Fieldnames = ['engine_id', 'vacancy_id', 'vacancy_state']
        Fieldvalues = [str(EngineIDList[EngineIndex]), Jobid, 'New']
        SQLcommand = Db.GenSQLinsert(HistoryTable, Fieldnames, Historyfields,
                                     Fieldvalues)
        SQLresponse = (Db.SQLload(DbObject, DbCursor, SQLcommand, failure))
        Errormessage = 'SQLresponse error for SQL command ' + '\"' + SQLcommand + '\"'
        if ((SQLresponse) == failure):
            File.Logerror(ErrorfileObject, module, Errormessage, warning)
Ejemplo n.º 3
0
    VacancyUpdate = {}
    PrimaryValues['engine_id'] = Duplicate['engine_id']
    PrimaryValues['vacancy_id'] = Duplicate['vacancy_id']

    VacancyUpdate['vacancy_state'] = 'Dropped'
    SQLcommand = Db.GenSQLupdate(VacancyTable, VacancyUpdate, VacancyFields,
                                 PrimaryValues)
    SQLresponse = Db.SQLload(DbObject, DbCursor, SQLcommand, failure)
    Errormessage = 'SQLresponse error for SQL command ' + '\"' + SQLcommand + '\"'
    if ((SQLresponse) == failure):
        File.Logerror(ErrorfileObject, module, Errormessage, error)

    # Add entry in table 'history' to reflect the change in state of the vacancy.
    Fieldnames = ['engine_id', 'vacancy_id', 'vacancy_state']
    Fieldvalues = [Duplicate['engine_id'], Duplicate['vacancy_id'], 'Dropped']
    SQLcommand = Db.GenSQLinsert(HistoryTable, Fieldnames, HistoryFields,
                                 Fieldvalues)
    SQLresponse = (Db.SQLload(DbObject, DbCursor, SQLcommand, failure))
    Errormessage = 'SQLresponse error for SQL command ' + '\"' + SQLcommand + '\"'
    if ((SQLresponse) == failure):
        File.Logerror(ErrorfileObject, module, Errormessage, warning)

    Errormessage = 'Vacancy ID %s Vacancy URL %s has been \'Dropped\'' % (
        Duplicate['vacancy_id'], Duplicate['vacancy_url'])
    File.Logerror(ErrorfileObject, module, Errormessage, info)

    DuplicateCount += 1

# Progress update
if (len(RemoveList) > 0):
    Errormessage = 'Removed %d duplicate vacancies' % DuplicateCount
    File.Logerror(ErrorfileObject, module, Errormessage, info)