From c1c8284023ba6df6e87dc5f9d5841573c1e7abc6 Mon Sep 17 00:00:00 2001 From: yezi Date: Wed, 28 Feb 2024 06:39:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=87=E7=AB=A0=E6=94=B6=E7=9B=8A?= =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C=E5=8A=A0=E5=85=A5=E5=94=AF=E4=B8=80?= =?UTF-8?q?=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jobs/fetch_article_earning_ranking_records.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/jobs/fetch_article_earning_ranking_records.py b/jobs/fetch_article_earning_ranking_records.py index 042733b..07f8a7e 100644 --- a/jobs/fetch_article_earning_ranking_records.py +++ b/jobs/fetch_article_earning_ranking_records.py @@ -7,6 +7,7 @@ from jkit.ranking.article_earning import ArticleEarningRanking, RecordField from prefect import flow, get_run_logger from prefect.states import Completed, State +from pymongo import ASCENDING, IndexModel from utils.config_generators import generate_deployment_config, generate_flow_config from utils.db import DB @@ -100,6 +101,10 @@ async def process_item( ) ) async def flow_func() -> State: + await COLLECTION.create_indexes( + [IndexModel([("date", ASCENDING), ("ranking", ASCENDING)], unique=True)] + ) + target_date = datetime.now().date() - timedelta(days=1) data: List[ArticleEarningRankingRecordDocument] = []