def fetch_everything_for_researcher(pk): ccf = get_ccf() oai = OaiPaperSource(ccf, max_results=250) sources = [ ('orcid',OrcidPaperSource(ccf, oai, max_results=1000)), ('crossref',CrossRefPaperSource(ccf, oai, max_results=500)), ('oai',oai), ] r = Researcher.objects.get(pk=pk) ## If it is the first time we fetch this researcher #if r.stats is None: # make sure publications already known are also considered ccf.reclusterBatch(r) try: for key,source in sources: update_researcher_task(r, key) source.fetch_and_save(r, incremental=True) update_researcher_task(r, None) except MetadataSourceException as e: raise e finally: r = Researcher.objects.get(pk=pk) update_researcher_task(r, 'stats') r.update_stats() r.harvester = None update_researcher_task(r, None) ccf.clear() name_lookup_cache.prune()
def fetch_everything_for_researcher(pk): ccf = get_ccf() oai = OaiPaperSource(ccf, max_results=250) sources = [ ('orcid', OrcidPaperSource(ccf, oai, max_results=1000)), ('crossref', CrossRefPaperSource(ccf, oai, max_results=500)), ('oai', oai), ] r = Researcher.objects.get(pk=pk) ## If it is the first time we fetch this researcher #if r.stats is None: # make sure publications already known are also considered ccf.reclusterBatch(r) try: for key, source in sources: update_researcher_task(r, key) source.fetch_and_save(r, incremental=True) update_researcher_task(r, None) except MetadataSourceException as e: raise e finally: r = Researcher.objects.get(pk=pk) update_researcher_task(r, 'stats') r.update_stats() r.harvester = None update_researcher_task(r, None) ccf.clear() name_lookup_cache.prune()
def prune_name_lookup_cache(threshold): """ Prunes the name lookup cache (removes names which are not looked up often) """ name_lookup_cache.prune(threshold)