-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
功能变动: - **实现数据双写逻辑** - **添加新版数据库模型与迁移脚本** - 更新部署配置
- Loading branch information
Showing
35 changed files
with
1,237 additions
and
663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from asyncio import run as asyncio_run | ||
from asyncio import sleep | ||
from datetime import datetime | ||
|
||
from jkit.article import Article | ||
from jkit.exceptions import ResourceUnavailableError | ||
|
||
from models.jianshu.article_earning_ranking_record import ( | ||
ArticleEarningRankingRecordDocument, | ||
) | ||
|
||
|
||
async def main() -> None: | ||
async for item in ArticleEarningRankingRecordDocument.find_many( | ||
{"date": {"$gte": datetime(2024, 10, 23)}, "authorSlug": None}, | ||
sort={"date": "ASC", "ranking": "ASC"}, | ||
): | ||
if not item.article.slug: | ||
print("Skipping because article slug is missing") | ||
continue | ||
|
||
try: | ||
article = Article.from_slug(item.article.slug) | ||
author_slug = (await article.info).author_info.slug | ||
|
||
await ArticleEarningRankingRecordDocument.update_one( | ||
{"date": item.date, "ranking": item.ranking}, | ||
{"$set": {"authorSlug": author_slug}}, | ||
) | ||
print(f"Fixed author slug for {item.article.slug} to {author_slug}") | ||
except ResourceUnavailableError: | ||
print("Skipping because article is deleted") | ||
|
||
await sleep(0.5) | ||
|
||
|
||
asyncio_run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.