Skip to content

Commit 4d08a80

Browse files
committed
JFetcher v4.2.0
功能变动: - 优化数据库连接池配置 - 升级到 Ruff v0.11.0,并应用最新静态检查规则 - 调整部署配置 - 移除未被实际使用的数据库连接池准备代码 - 更新依赖库 错误修复: - 修复采集简书资产排行榜数据工作流断点续采异常的问题
2 parents b9aa964 + 5a7ea35 commit 4d08a80

19 files changed

+194
-203
lines changed

docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ networks:
66

77
services:
88
main:
9-
image: jfetcher:4.1.0
9+
image: jfetcher:4.2.0
1010
container_name: jfetcher
1111
build: .
1212
volumes:
@@ -20,7 +20,7 @@ services:
2020
deploy:
2121
resources:
2222
limits:
23-
memory: 1G
23+
memory: 768M
2424
restart_policy:
2525
condition: on-failure
2626
delay: 5s

flows/beijiaoyi/fetch_ftn_market_orders_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def get_fetch_time() -> datetime:
1818
time = datetime.now().replace(second=0, microsecond=0)
1919

2020
# 12:01 -> timedelta = -1 minute
21-
if time.minute % 10 < 5: # noqa: PLR2004
21+
if time.minute % 10 < 5:
2222
delta = timedelta(minutes=time.minute % 10)
2323
return time - delta
2424
# 11:57 -> timedelta = +3 minute

flows/jianshu/fetch_core_user_assets_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_fetch_time() -> datetime:
2626
time = datetime.now().replace(second=0, microsecond=0)
2727

2828
# 12:13 -> 12:00
29-
if time.minute < 30: # noqa: PLR2004
29+
if time.minute < 30:
3030
return time.replace(minute=0)
3131
# 12:49 -> 13:00
3232
else: # noqa: RET505

flows/jianshu/fetch_user_assets_ranking_data.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,10 @@ async def iter_user_assets_ranking(
6262
start_ranking: int,
6363
total_count: int,
6464
) -> AsyncGenerator[RecordData]:
65-
current_count = 0
6665
async for item in UserAssetsRanking(start_ranking=start_ranking).iter_records():
6766
yield item
68-
current_count += 1
6967

70-
if current_count == total_count:
68+
if item.ranking == total_count:
7169
return
7270

7371

@@ -130,7 +128,7 @@ async def save_user_assets_ranking_record_data(
130128

131129
try:
132130
assets_info: AssetsInfoData = await get_user_assets_info(item)
133-
except Exception:
131+
except ResourceUnavailableError:
134132
assets_info = None # type: ignore
135133
else:
136134
if assets_info.ftn_amount is None and assets_info.assets_amount is None:

flows/jpep/fetch_ftn_market_orders_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def get_fetch_time() -> datetime:
1616
time = datetime.now().replace(second=0, microsecond=0)
1717

1818
# 12:01 -> timedelta = -1 minute
19-
if time.minute % 10 < 5: # noqa: PLR2004
19+
if time.minute % 10 < 5:
2020
delta = timedelta(minutes=time.minute % 10)
2121
return time - delta
2222
# 11:57 -> timedelta = +3 minute

models/__init__.py

-7
This file was deleted.

models/beijiaoyi/ftn_market_record.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FtnMarketRecord(Table, frozen=True):
2020
completed_trades_count: NonNegativeInt
2121

2222
@classmethod
23-
async def create( # noqa: PLR0913
23+
async def create(
2424
cls,
2525
*,
2626
fetch_time: datetime,

models/beijiaoyi/ftn_market_summary_record.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FtnMarketSummaryRecord(Table, frozen=True):
2020
remaining_amount: int
2121

2222
@classmethod
23-
async def create( # noqa: PLR0913
23+
async def create(
2424
cls,
2525
*,
2626
fetch_time: datetime,

models/jianshu/article_earning_ranking_record.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ArticleEarningRankingRecord(Table, frozen=True):
1919
voter_earning: PositiveFloat
2020

2121
@classmethod
22-
async def create( # noqa: PLR0913
22+
async def create(
2323
cls,
2424
*,
2525
date: date,

models/jianshu/user.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class User(Table, frozen=True):
2424
membership_expire_time: datetime | None
2525

2626
@classmethod
27-
async def create( # noqa: PLR0913
27+
async def create(
2828
cls,
2929
*,
3030
slug: str,

models/jianshu/user_assets_ranking_record.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class UserAssetsRankingRecord(Table, frozen=True):
1818
assets: NonNegativeFloat | None
1919

2020
@classmethod
21-
async def create( # noqa: PLR0913
21+
async def create(
2222
cls,
2323
*,
2424
date: date,

models/jianshu/user_earning_ranking_record.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class UserEarningRankingRecord(Table, frozen=True):
2222
voting_earning: NonNegativeFloat
2323

2424
@classmethod
25-
async def create( # noqa: PLR0913
25+
async def create(
2626
cls,
2727
*,
2828
date: date,

models/jpep/ftn_market_record.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class FtnMarketRecord(Table, frozen=True):
1919
completed_trades_count: NonNegativeInt
2020

2121
@classmethod
22-
async def create( # noqa: PLR0913
22+
async def create(
2323
cls,
2424
*,
2525
fetch_time: datetime,

models/jpep/ftn_market_summary_record.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FtnMarketSummaryRecord(Table, frozen=True):
2020
remaining_amount: int
2121

2222
@classmethod
23-
async def create( # noqa: PLR0913
23+
async def create(
2424
cls,
2525
*,
2626
fetch_time: datetime,

pyproject.toml

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "jfetcher"
3-
version = "4.1.0"
3+
version = "4.2.0"
44
description = "简书数据采集工具"
55
readme = "README.md"
66
license = { file = "LICENSE" }
@@ -13,7 +13,7 @@ dependencies = [
1313
]
1414

1515
[tool.uv]
16-
dev-dependencies = ["pyright>=1.1.0", "ruff>=0.9.0"]
16+
dev-dependencies = ["pyright>=1.1.0", "ruff>=0.11.0"]
1717

1818
[tool.ruff]
1919
target-version = "py39"
@@ -23,16 +23,19 @@ lint.select = [
2323
"ARG",
2424
"ASYNC",
2525
"B",
26+
"BLE",
2627
"C4",
2728
"E",
2829
"F",
2930
"FA",
3031
"FBT",
32+
"FLY",
3133
"FURB",
3234
"I",
3335
"ISC",
3436
"N",
3537
"PERF",
38+
"PGH",
3639
"PIE",
3740
"PL",
3841
"PT",
@@ -43,21 +46,19 @@ lint.select = [
4346
"RUF",
4447
"S",
4548
"SIM",
46-
"SLF",
47-
"T20",
48-
"TID",
4949
"TRY",
5050
"UP",
5151
"W",
5252
]
5353
lint.ignore = [
54-
"A005",
5554
"PERF203",
55+
"PGH003",
56+
"PLR0913",
57+
"PLR2004",
5658
"RUF001",
5759
"RUF002",
5860
"RUF003",
5961
"S311",
6062
"TRY003",
6163
]
62-
63-
lint.flake8-builtins.builtins-ignorelist = ["id", "range", "type"]
64+
lint.flake8-builtins.builtins-ignorelist = ["id", "range", "type"]

requirements-dev.txt

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
aiosqlite==0.21.0
22
alembic==1.15.1
33
annotated-types==0.7.0
4-
anyio==4.8.0
4+
anyio==4.9.0
55
apprise==1.9.2
66
asgi-lifespan==2.1.0
77
async-timeout==5.0.1 ; python_full_version < '3.11'
88
asyncpg==0.30.0
9-
attrs==25.2.0
9+
attrs==25.3.0
1010
cachetools==5.5.2
1111
certifi==2025.1.31
1212
cffi==1.17.1 ; platform_python_implementation != 'PyPy'
@@ -24,7 +24,7 @@ fastapi==0.115.11
2424
fsspec==2025.3.0
2525
graphviz==0.20.3
2626
greenlet==3.1.1
27-
griffe==1.6.0
27+
griffe==1.6.2
2828
h11==0.14.0
2929
h2==4.2.0
3030
hpack==4.1.0
@@ -33,7 +33,7 @@ httpx==0.28.1
3333
humanize==4.12.1
3434
hyperframe==6.1.0
3535
idna==3.10
36-
importlib-metadata==8.5.0
36+
importlib-metadata==8.6.1
3737
jinja2==3.1.6
3838
jinja2-humanize-extension==0.4.0
3939
jkit==3.0.0b5
@@ -49,28 +49,28 @@ mdurl==0.1.2
4949
msgspec==0.19.0
5050
nodeenv==1.9.1
5151
oauthlib==3.2.2
52-
opentelemetry-api==1.30.0
52+
opentelemetry-api==1.31.1
5353
orjson==3.10.15
5454
packaging==24.2
5555
pathspec==0.12.1
5656
pendulum==3.0.0
57-
prefect==3.2.12
57+
prefect==3.2.14
5858
prometheus-client==0.21.1
59-
psycopg==3.2.5
60-
psycopg-binary==3.2.5 ; implementation_name != 'pypy'
59+
psycopg==3.2.6
60+
psycopg-binary==3.2.6 ; implementation_name != 'pypy'
6161
pycparser==2.22 ; platform_python_implementation != 'PyPy'
6262
pydantic==2.10.6
6363
pydantic-core==2.27.2
6464
pydantic-extra-types==2.10.3
6565
pydantic-settings==2.8.1
6666
pygments==2.19.1
67-
pyright==1.1.396
67+
pyright==1.1.397
6868
python-dateutil==2.9.0.post0
6969
python-dotenv==1.0.1
7070
python-slugify==8.0.4
7171
python-socks==2.7.1
7272
pytz==2025.1
73-
pywin32==309 ; sys_platform == 'win32'
73+
pywin32==310 ; sys_platform == 'win32'
7474
pyyaml==6.0.2
7575
readchar==4.2.1
7676
referencing==0.36.2
@@ -82,7 +82,7 @@ rich==13.9.4
8282
rpds-py==0.23.1
8383
ruamel-yaml==0.18.10
8484
ruamel-yaml-clib==0.2.12 ; python_full_version < '3.13' and platform_python_implementation == 'CPython'
85-
ruff==0.9.10
85+
ruff==0.11.2
8686
shellingham==1.5.4
8787
six==1.17.0
8888
sniffio==1.3.1
@@ -99,7 +99,7 @@ tzdata==2025.1
9999
tzlocal==5.3.1
100100
ujson==5.10.0
101101
urllib3==2.3.0
102-
uv==0.6.6
102+
uv==0.6.9
103103
uvicorn==0.34.0
104104
websockets==15.0.1
105105
wrapt==1.17.2

requirements.txt

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
aiosqlite==0.21.0
22
alembic==1.15.1
33
annotated-types==0.7.0
4-
anyio==4.8.0
4+
anyio==4.9.0
55
apprise==1.9.2
66
asgi-lifespan==2.1.0
77
async-timeout==5.0.1 ; python_full_version < '3.11'
88
asyncpg==0.30.0
9-
attrs==25.2.0
9+
attrs==25.3.0
1010
cachetools==5.5.2
1111
certifi==2025.1.31
1212
cffi==1.17.1 ; platform_python_implementation != 'PyPy'
@@ -24,7 +24,7 @@ fastapi==0.115.11
2424
fsspec==2025.3.0
2525
graphviz==0.20.3
2626
greenlet==3.1.1
27-
griffe==1.6.0
27+
griffe==1.6.2
2828
h11==0.14.0
2929
h2==4.2.0
3030
hpack==4.1.0
@@ -33,7 +33,7 @@ httpx==0.28.1
3333
humanize==4.12.1
3434
hyperframe==6.1.0
3535
idna==3.10
36-
importlib-metadata==8.5.0
36+
importlib-metadata==8.6.1
3737
jinja2==3.1.6
3838
jinja2-humanize-extension==0.4.0
3939
jkit==3.0.0b5
@@ -48,15 +48,15 @@ markupsafe==3.0.2
4848
mdurl==0.1.2
4949
msgspec==0.19.0
5050
oauthlib==3.2.2
51-
opentelemetry-api==1.30.0
51+
opentelemetry-api==1.31.1
5252
orjson==3.10.15
5353
packaging==24.2
5454
pathspec==0.12.1
5555
pendulum==3.0.0
56-
prefect==3.2.12
56+
prefect==3.2.14
5757
prometheus-client==0.21.1
58-
psycopg==3.2.5
59-
psycopg-binary==3.2.5 ; implementation_name != 'pypy'
58+
psycopg==3.2.6
59+
psycopg-binary==3.2.6 ; implementation_name != 'pypy'
6060
pycparser==2.22 ; platform_python_implementation != 'PyPy'
6161
pydantic==2.10.6
6262
pydantic-core==2.27.2
@@ -68,7 +68,7 @@ python-dotenv==1.0.1
6868
python-slugify==8.0.4
6969
python-socks==2.7.1
7070
pytz==2025.1
71-
pywin32==309 ; sys_platform == 'win32'
71+
pywin32==310 ; sys_platform == 'win32'
7272
pyyaml==6.0.2
7373
readchar==4.2.1
7474
referencing==0.36.2
@@ -96,7 +96,7 @@ tzdata==2025.1
9696
tzlocal==5.3.1
9797
ujson==5.10.0
9898
urllib3==2.3.0
99-
uv==0.6.6
99+
uv==0.6.9
100100
uvicorn==0.34.0
101101
websockets==15.0.1
102102
wrapt==1.17.2

utils/db.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66

77
jianshu_pool = Pool(
88
CONFIG.jianshu_postgres.connection_string,
9-
min_size=1,
9+
min_size=2,
1010
max_size=4,
1111
app_name="JFetcher",
1212
)
1313
jpep_pool = Pool(
1414
CONFIG.jpep_postgres.connection_string,
15-
min_size=1,
16-
max_size=4,
15+
min_size=2,
16+
max_size=2,
1717
app_name="JFetcher",
1818
)
1919
beijiaoyi_pool = Pool(
2020
CONFIG.beijiaoyi_postgres.connection_string,
21-
min_size=1,
22-
max_size=4,
21+
min_size=2,
22+
max_size=2,
2323
app_name="JFetcher",
2424
)

0 commit comments

Comments
 (0)