From fce9039e9a4e52b2d6c4333637e7c561c51d2769 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 26 Jan 2026 18:20:01 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20get=5Fpaper=5Fmeta=5Ffrom=5Fopenalex=20?= =?UTF-8?q?=E5=8F=AF=E8=A7=A6=E5=8F=91=E8=87=AA=E5=B7=B12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/resm/tasks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/resm/tasks.py b/apps/resm/tasks.py index c0de024..1ebfe10 100644 --- a/apps/resm/tasks.py +++ b/apps/resm/tasks.py @@ -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'