Skip to content

Commit

Permalink
feat: 优化数据库初始化函数命名
Browse files Browse the repository at this point in the history
  • Loading branch information
FHU-yezi committed Mar 5, 2024
1 parent fd8af38 commit 86b6915
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
8 changes: 6 additions & 2 deletions jobs/article_earning_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
ArticleEarningRankingRecordDocument,
ArticleField,
EarningField,
init_db,
insert_many,
)
from models.article_earning_ranking_record import (
init_db as init_article_earning_ranking_record_db,
)
from models.jianshu_user import init_db as init_jianshu_user_db
from models.jianshu_user import insert_or_update_one
from utils.async_retry import async_retry
from utils.config_generators import (
Expand Down Expand Up @@ -81,7 +84,8 @@ async def process_item(
)
)
async def flow_func() -> State:
await init_db()
await init_article_earning_ranking_record_db()
await init_jianshu_user_db()

target_date = datetime.now().date() - timedelta(days=1)

Expand Down
8 changes: 6 additions & 2 deletions jobs/assets_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
from models.assets_ranking_record import (
AmountField,
AssetsRankingRecordDocument,
init_db,
insert_many,
)
from models.assets_ranking_record import (
init_db as init_assets_ranking_record_db,
)
from models.jianshu_user import init_db as init_jianshu_user_db
from models.jianshu_user import insert_or_update_one
from utils.async_retry import async_retry
from utils.config_generators import (
Expand Down Expand Up @@ -82,7 +85,8 @@ async def process_item(
)
)
async def flow_func() -> State:
await init_db()
await init_assets_ranking_record_db()
await init_jianshu_user_db()

target_date = datetime.now().date()

Expand Down
8 changes: 6 additions & 2 deletions jobs/daily_update_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@

from models.daily_update_ranking_record import (
DailyUpdateRankingRecordDocument,
init_db,
insert_many,
)
from models.daily_update_ranking_record import (
init_db as init_daily_update_ranking_record_db,
)
from models.jianshu_user import init_db as init_jianshu_user_db
from models.jianshu_user import insert_or_update_one
from utils.config_generators import (
generate_deployment_config,
Expand Down Expand Up @@ -43,7 +46,8 @@ async def process_item(
)
)
async def flow_func() -> State:
await init_db()
await init_daily_update_ranking_record_db()
await init_jianshu_user_db()

current_date = datetime.now().date()

Expand Down
8 changes: 6 additions & 2 deletions jobs/jianshu_lottery.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
from models.jianshu_lottery_win_record import (
JianshuLotteryWinRecordDocument,
get_latest_record_id,
init_db,
insert_many,
)
from models.jianshu_lottery_win_record import (
init_db as init_jianshu_lottery_win_record_db,
)
from models.jianshu_user import init_db as init_jianshu_user_db
from models.jianshu_user import insert_or_update_one
from utils.config_generators import (
generate_deployment_config,
Expand Down Expand Up @@ -42,7 +45,8 @@ async def process_item(
)
)
async def flow_func() -> State:
await init_db()
await init_jianshu_lottery_win_record_db()
await init_jianshu_user_db()

logger = get_run_logger()

Expand Down
8 changes: 6 additions & 2 deletions jobs/lp_recommended_articles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
from prefect import flow, get_run_logger
from prefect.states import Completed, State

from models.jianshu_user import init_db as init_jianshu_user_db
from models.jianshu_user import insert_or_update_one
from models.lp_recommend_article_record import (
LPRecommendedArticleRecord,
init_db,
insert_many,
is_record_stored,
)
from models.lp_recommend_article_record import (
init_db as init_lp_recommend_article_record_db,
)
from utils.config_generators import (
generate_deployment_config,
generate_flow_config,
Expand Down Expand Up @@ -61,7 +64,8 @@ async def process_item(
)
)
async def flow_func() -> State:
await init_db()
await init_lp_recommend_article_record_db()
await init_jianshu_user_db()

logger = get_run_logger()

Expand Down

0 comments on commit 86b6915

Please sign in to comment.