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 _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_rabbit(paperslist, all_records=False): if not paperslist and all_records: rabbit_with_log(None, True, 'bibauthorid_daemon, update_personid on all papers') elif not paperslist: last_log = get_user_log(userinfo='daemon', action='PID_UPDATE', only_most_recent=True) if len(last_log) >= 1: #select only the most recent papers recently_modified = get_papers_recently_modified(date=last_log[0][2]) 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) rabbit_with_log(recently_modified, True, 'bibauthorid_daemon, run_personid_fast_assign_papers on ' + str([paperslist, all_records, recently_modified])) else: rabbit_with_log(None, True, 'bibauthorid_daemon, update_personid on all papers') else: rabbit_with_log(paperslist, True, 'bibauthorid_daemon, personid_fast_assign_papers on ' + str(paperslist), partial=True)
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)