def _run_update_authornames_tables_from_paper(record_ids=None, all_records=False): ''' Runs the update on the papers which have been modified since the last run @note: This should be run as often as possible to keep authornames and authornames_bibrefs cache tables up to date. ''' if not all_records and not record_ids: last_log = get_user_log(userinfo='daemon', action='UATFP', only_most_recent=True) if len(last_log) >= 1: #select only the most recent papers recently_modified, min_date = get_papers_recently_modified(date=last_log[0][2]) insert_user_log('daemon', '-1', 'UATFP', 'bibsched', 'status', comment='bibauthorid_daemon, update_authornames_tables_from_paper', timestamp=min_date[0][0]) if not recently_modified: bibtask.write_message("update_authornames_tables_from_paper: " "All names up to date.", stream=sys.stdout, verbose=0) else: bibtask.write_message( "update_authornames_tables_from_paper: Running on %s papers " % str( len(recently_modified)), stream=sys.stdout, verbose=0) update_authornames_tables_from_paper(recently_modified) else: #this is the first time the utility is run, run on all the papers? #Probably better to write the log on the first authornames population #@todo: authornames population writes the log recently_modified, min_date = get_papers_recently_modified() insert_user_log('daemon', '-1', 'UATFP', 'bibsched', 'status', comment='bibauthorid_daemon, update_authornames_tables_from_paper', timestamp=min_date[0][0]) bibtask.write_message( "update_authornames_tables_from_paper: Running on %s papers " % str( len(recently_modified)), stream=sys.stdout, verbose=0) update_authornames_tables_from_paper(recently_modified) else: bibtask.write_message("update_authornames_tables_from_paper: Running " "on all papers ", stream=sys.stdout, verbose=0) update_authornames_tables_from_paper(record_ids)
def rabbit_with_log(papers, check_invalid_papers, log_comment, partial=False): from bibauthorid_rabbit import rabbit starting_time = get_sql_time() rabbit(papers, check_invalid_papers) if partial: action = 'PID_UPDATE_PARTIAL' else: action = 'PID_UPDATE' insert_user_log('daemon', '-1', action, 'bibsched', 'status', comment=log_comment, timestamp=starting_time)
def rabbit_with_log(papers, check_invalid_papers, log_comment, partial=False): from bibauthorid_rabbit import rabbit starting_time = get_sql_time() rabbit(papers, check_invalid_papers) if partial: action = "PID_UPDATE_PARTIAL" else: action = "PID_UPDATE" insert_user_log("daemon", "-1", action, "bibsched", "status", comment=log_comment, timestamp=starting_time)
def run_tortoise(from_scratch): from bibauthorid_tortoise import tortoise, tortoise_from_scratch if from_scratch: tortoise_from_scratch() else: start_time = get_sql_time() tortoise_db_name = 'tortoise' last_run = get_user_log(userinfo=tortoise_db_name, only_most_recent=True) if last_run: modified = get_recently_modified_record_ids(last_run[0][2]) else: modified = [] tortoise(modified) insert_user_log(tortoise_db_name, '-1', '', '', '', timestamp=start_time)
def _run_update_personID_table_from_paper(record_ids=None, all_records=False): ''' Runs the update on the papers which have been modified since the last run This is removing no-longer existing papers from the personid table. @note: Update recommended monthly. @warning: quite resource intensive. ''' if not record_ids and not all_records: last_log = get_user_log(userinfo='daemon', action='UPITFP', only_most_recent=True) if len(last_log) >= 1: #select only the most recent papers recently_modified, min_date = get_papers_recently_modified(date=last_log[0][2]) insert_user_log('daemon', '-1', 'UPITFP', 'bibsched', 'status', comment='bibauthorid_daemon, update_personID_table_from_paper', timestamp=min_date[0][0]) if not recently_modified: bibtask.write_message("update_personID_table_from_paper: " "All person entities up to date.", stream=sys.stdout, verbose=0) else: bibtask.write_message("update_personID_table_from_paper: Running on: " + str(recently_modified), stream=sys.stdout, verbose=0) update_personID_table_from_paper(recently_modified) else: # Should not process all papers, hence authornames population writes # the appropriate log. In case the log is missing, process everything. recently_modified, min_date = get_papers_recently_modified() insert_user_log('daemon', '-1', 'UPITFP', 'bibsched', 'status', comment='bibauthorid_daemon, update_personID_table_from_paper', timestamp=min_date[0][0]) bibtask.write_message("update_personID_table_from_paper: Running on: " + str(recently_modified), stream=sys.stdout, verbose=0) update_personID_table_from_paper(recently_modified) else: update_personID_table_from_paper(record_ids)
def _run_personid_gc(paperslist, all_records=False): # insert_user_log('daemon', '-1', 'PGC', 'bibsched', 'status', # comment='bibauthorid_daemon, personid_gc (update_personid_from_papers) on ' # + str(paperslist)) if not paperslist and all_records: #update_authornames_tables_from_paper() insert_user_log('daemon', '-1', 'PGC', 'bibsched', 'status', comment='bibauthorid_daemon, personid_gc (update_personid_from_papers) on all papers') update_personID_table_from_paper() elif not paperslist: last_log = get_user_log(userinfo='daemon', action='PGC', only_most_recent=True) if len(last_log) >= 1: #select only the most recent papers recently_modified, min_date = get_papers_recently_modified(date=last_log[0][2]) insert_user_log('daemon', '-1', 'PGC', 'bibsched', 'status', comment='bibauthorid_daemon, update_personid_from_papers on ' + str([paperslist, all_records, recently_modified]), timestamp=min_date[0][0]) if not recently_modified: bibtask.write_message("update_personID_table_from_paper: " "All person entities up to date.", stream=sys.stdout, verbose=0) else: bibtask.write_message("update_personID_table_from_paper: Running on: " + str(recently_modified), stream=sys.stdout, verbose=0) personid_fast_assign_papers(recently_modified) else: insert_user_log('daemon', '-1', 'PGC', 'bibsched', 'status', comment='bibauthorid_daemon, personid_gc (update_personid_from_papers) on all papers') update_personID_table_from_paper() else: insert_user_log('daemon', '-1', 'PGC', 'bibsched', 'status', comment='bibauthorid_daemon, personid_gc (update_personid_from_papers) on ' + str(paperslist)) update_authornames_tables_from_paper(paperslist) update_personID_table_from_paper(paperslist)