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 get_paper_by_doi(doi): ccf = get_ccf() oai = OaiPaperSource(ccf=ccf, max_results=10) crps = CrossRefPaperSource(ccf=ccf, oai=oai, max_results=10) p = crps.create_paper_by_doi(doi) if p is not None: p = Paper.from_bare(p) return p
def recluster_researcher(pk): ccf = get_ccf() try: r = Researcher.objects.get(pk=pk) ccf.reclusterBatch(r) finally: r.update_stats() update_researcher_task(r, None) del ccf
def init_profile_from_orcid(pk): """ Populates the profile from ORCID and Proaixy. Does not fetch DOIs from ORCID as it can be slow. This task is intended to be very quick, so that users can see their ORCID publications quickly. """ ccf = get_ccf() r = Researcher.objects.get(pk=pk) update_task = lambda name: update_researcher_task(r, name) update_task('clustering') fetch_everything_for_researcher(pk) ccf.clear()
def setUpClass(self): super(PaperTest, self).setUpClass() self.ccf = get_ccf()