Skip to content

Commit

Permalink
feat: 文章收益排行榜加入唯一索引
Browse files Browse the repository at this point in the history
  • Loading branch information
FHU-yezi committed Feb 27, 2024
1 parent 0f710e2 commit c1c8284
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jobs/fetch_article_earning_ranking_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] = []
Expand Down

0 comments on commit c1c8284

Please sign in to comment.