feat: get_paper_meta_from_openalex 可触发自己2
This commit is contained in:
parent
07a260136b
commit
fce9039e9a
|
|
@ -20,7 +20,7 @@ config.retry_http_codes = [429, 500, 503]
|
|||
config.api_key = "4KJZdkCFA0uFb6IsYKc8cd"
|
||||
|
||||
@shared_task(base=CustomTask)
|
||||
def get_paper_meta_from_openalex(publication_year:int, search_key:str):
|
||||
def get_paper_meta_from_openalex(publication_year:int, search_key:str, end_year:int=2026):
|
||||
cache_key = f"openalex_cursor_{publication_year}_{search_key}"
|
||||
cache_cursor = cache.get(cache_key, "*")
|
||||
pager = Works().filter(
|
||||
|
|
@ -58,8 +58,8 @@ def get_paper_meta_from_openalex(publication_year:int, search_key:str):
|
|||
papers.append(paper)
|
||||
Paper.objects.bulk_create(papers, ignore_conflicts=True)
|
||||
cache.set(cache_key, next_cursor, timeout=None)
|
||||
if publication_year + 1 <= 2026:
|
||||
get_paper_meta_from_openalex.delay(publication_year + 1, search_key)
|
||||
if publication_year + 1 <= end_year:
|
||||
get_paper_meta_from_openalex.delay(publication_year + 1, search_key, end_year)
|
||||
|
||||
|
||||
ELSEVIER_APIKEY = 'aa8868cac9e27d6153ab0a0acd7b50bf'
|
||||
|
|
|
|||
Loading…
Reference in New Issue