Skip to content

Commit

Permalink
feat: 在工作流中加入对 JKit 配置的临时修改,以避免简书系统问题导致的数据校验失败
Browse files Browse the repository at this point in the history
  • Loading branch information
FHU-yezi committed Feb 24, 2024
1 parent 8e49de7 commit 066d2ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions jobs/fetch_article_earning_ranking_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from beanie import Document
from jkit.article import Article
from jkit.config import CONFIG
from jkit.ranking.article_earning import ArticleEarningRanking, RecordField
from jkit.user import User
from prefect import flow, get_run_logger
Expand Down Expand Up @@ -51,7 +52,10 @@ async def process_item(
logger = get_run_logger()

if item.slug:
# TODO: 临时解决简书系统问题数据负数导致的报错
CONFIG.data_validation.enabled = False
author = await get_article_author(item.slug)
CONFIG.data_validation.enabled = True
else:
logger.warning(f"文章走丢了,跳过采集文章与作者信息 ranking={item.ranking}")
author = None
Expand Down
10 changes: 7 additions & 3 deletions jobs/fetch_assets_ranking_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import List, Optional

from beanie import Document
from jkit.config import CONFIG
from jkit.exceptions import ResourceUnavailableError
from jkit.ranking.assets import AssetsRanking, AssetsRankingRecord
from prefect import flow, get_run_logger
Expand Down Expand Up @@ -39,19 +40,22 @@ async def process_item(
if item.user_info.slug:
user_obj = item.user_info.to_user_obj()
try:
# TODO
# 强制重新检查
user_obj._checked = False
# TODO: 强制重新检查
CONFIG.resource_check.force_check_safe_data = True
await user_obj.check()
CONFIG.resource_check.force_check_safe_data = False
except ResourceUnavailableError:
logger.warning(
f"用户已注销或被封禁,跳过采集简书钻与简书贝信息 ranking={item.ranking}"
)
fp_amount = None
ftn_amount = None

# TODO: 临时解决简书系统问题数据负数导致的报错
CONFIG.data_validation.enabled = False
fp_amount = await user_obj.fp_amount
ftn_amount = abs(round(item.assets_amount - fp_amount, 3))
CONFIG.data_validation.enabled = True
else:
logger.warning(f"用户不存在,跳过采集简书钻与简书贝信息 ranking={item.ranking}")
fp_amount = None
Expand Down

0 comments on commit 066d2ed

Please sign in to comment.