😝修复判断数量的逻辑问题,更新说明文档
This commit is contained in:
parent
a736d8d897
commit
74ffbb98d4
@ -406,7 +406,7 @@ def marge_errors_from_json_url(errors, marge_json_url):
|
||||
|
||||
def deal_with_large_data(result):
|
||||
"""
|
||||
处理文章数据,保留前200篇及其作者在后续文章中的出现。
|
||||
处理文章数据,保留前150篇及其作者在后续文章中的出现。
|
||||
|
||||
参数:
|
||||
result (dict): 包含统计数据和文章数据的字典。
|
||||
@ -414,17 +414,18 @@ def deal_with_large_data(result):
|
||||
返回:
|
||||
dict: 处理后的数据,只包含需要的文章。
|
||||
"""
|
||||
result = sort_articles_by_time(result)
|
||||
article_data = result.get("article_data", [])
|
||||
|
||||
# 检查文章数量是否大于 200
|
||||
if len(article_data) > 200:
|
||||
# 检查文章数量是否大于 150
|
||||
if len(article_data) > 150:
|
||||
print("数据量较大,开始进行处理···")
|
||||
# 获取前 200 篇文章的作者集合
|
||||
first_200_authors = {article["author"] for article in article_data[:200]}
|
||||
|
||||
# 从第201篇开始过滤,只保留前200篇出现过的作者的文章
|
||||
filtered_articles = article_data[:200] + [
|
||||
article for article in article_data[200:]
|
||||
# 从第151篇开始过滤,只保留前150篇出现过的作者的文章
|
||||
filtered_articles = article_data[:150] + [
|
||||
article for article in article_data[150:]
|
||||
if article["author"] in first_200_authors
|
||||
]
|
||||
|
||||
|
17
readme.md
17
readme.md
@ -11,6 +11,12 @@
|
||||
|
||||
## 开发进度
|
||||
|
||||
### 2024-10-29
|
||||
|
||||
* 完善github数据获取,从环境变量中直接获取,配置文件仅用于自部署
|
||||
* 限制文章数量,防止因为数量过大导致的api文件加载缓慢,仅保留150左右文章([#23](https://github.com/willow-god/Friend-Circle-Lite/pull/23))
|
||||
* 修改action中写错的github_token拼写
|
||||
|
||||
### 2024-10-07
|
||||
|
||||
* 添加随机文章刷新按钮
|
||||
@ -22,13 +28,13 @@
|
||||
* 美化展示页面UI(@JLinMr),添加背景图片
|
||||
* 优化作者卡片弹窗动效(@JLinMr)
|
||||
|
||||
### 2024-09-22
|
||||
|
||||
* 修复 #18 提出的,由于rss倒序导致限制抓取错误的问题,改为先全部获取后,按照时间排序,再选择性获取
|
||||
|
||||
<details>
|
||||
<summary>查看更多</summary>
|
||||
|
||||
<h3>2024-09-22</h3>
|
||||
|
||||
* 修复 #18 提出的,由于rss倒序导致限制抓取错误的问题,改为先全部获取后,按照时间排序,再选择性获取
|
||||
|
||||
<h3>2024-09-05</h3>
|
||||
|
||||
* 更新部署方式,将静态文件放到page分支下,主分支不放数据文件
|
||||
@ -426,3 +432,6 @@ python3 run.py
|
||||
|
||||
如果遇到任何问题或有建议,请[提交一个 issue](https://github.com/willow-god/Friend-Circle-Lite/issues)。欢迎贡献代码!
|
||||
|
||||
## Star增长曲线
|
||||
|
||||
[](https://star-history.com/#willow-god/Friend-Circle-Lite&Timeline)
|
4
run.py
4
run.py
@ -23,9 +23,9 @@ if config["spider_settings"]["enable"]:
|
||||
result = marge_data_from_json_url(result, marge_json_url + "/all.json")
|
||||
lost_friends = marge_errors_from_json_url(lost_friends, marge_json_url + "/errors.json")
|
||||
result = deal_with_large_data(result)
|
||||
sorted_result = sort_articles_by_time(result)
|
||||
|
||||
with open("all.json", "w", encoding="utf-8") as f:
|
||||
json.dump(sorted_result, f, ensure_ascii=False, indent=2)
|
||||
json.dump(result, f, ensure_ascii=False, indent=2)
|
||||
with open("errors.json", "w", encoding="utf-8") as f:
|
||||
json.dump(lost_friends, f, ensure_ascii=False, indent=2)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user