perf: optimize system concurrency, I/O stability and fix WebSocket disconnects
This commit is contained in:
@@ -190,8 +190,9 @@ class MarketStore:
|
||||
name: str | None = None,
|
||||
sector: str | None = None,
|
||||
is_active: bool = True,
|
||||
) -> None:
|
||||
) -> int:
|
||||
timestamp = _utc_timestamp()
|
||||
count = 0
|
||||
with self._connect() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
@@ -206,6 +207,8 @@ class MarketStore:
|
||||
""",
|
||||
(symbol, name, sector, 1 if is_active else 0, timestamp, timestamp),
|
||||
)
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def update_fetch_watermark(
|
||||
self,
|
||||
@@ -213,8 +216,9 @@ class MarketStore:
|
||||
symbol: str,
|
||||
price_date: str | None = None,
|
||||
news_date: str | None = None,
|
||||
) -> None:
|
||||
) -> int:
|
||||
timestamp = _utc_timestamp()
|
||||
count = 0
|
||||
with self._connect() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
@@ -227,6 +231,8 @@ class MarketStore:
|
||||
""",
|
||||
(symbol, timestamp, timestamp, price_date, news_date),
|
||||
)
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def get_ticker_watermarks(self, symbol: str) -> dict[str, Any]:
|
||||
with self._connect() as conn:
|
||||
@@ -263,6 +269,8 @@ class MarketStore:
|
||||
count = 0
|
||||
with self._connect() as conn:
|
||||
for row in rows:
|
||||
if not row.get("date"):
|
||||
continue
|
||||
conn.execute(
|
||||
"""
|
||||
INSERT INTO ohlc
|
||||
@@ -341,6 +349,7 @@ class MarketStore:
|
||||
timestamp,
|
||||
),
|
||||
)
|
||||
count += 1
|
||||
for ticker in tickers:
|
||||
conn.execute(
|
||||
"""
|
||||
@@ -349,7 +358,6 @@ class MarketStore:
|
||||
""",
|
||||
(news_id, str(ticker).strip().upper()),
|
||||
)
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def get_news_without_trade_date(self, symbol: str | None = None, *, limit: int = 5000) -> list[dict[str, Any]]:
|
||||
@@ -928,8 +936,9 @@ class MarketStore:
|
||||
as_of_date: str,
|
||||
content: str,
|
||||
source: str = "local",
|
||||
) -> None:
|
||||
) -> int:
|
||||
timestamp = _utc_timestamp()
|
||||
count = 0
|
||||
with self._connect() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
@@ -943,6 +952,8 @@ class MarketStore:
|
||||
""",
|
||||
(symbol, as_of_date, content, source, timestamp, timestamp),
|
||||
)
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def delete_story_cache(
|
||||
self,
|
||||
@@ -1002,8 +1013,9 @@ class MarketStore:
|
||||
target_date: str,
|
||||
payload: dict[str, Any],
|
||||
source: str = "local",
|
||||
) -> None:
|
||||
) -> int:
|
||||
timestamp = _utc_timestamp()
|
||||
count = 0
|
||||
with self._connect() as conn:
|
||||
conn.execute(
|
||||
"""
|
||||
@@ -1017,6 +1029,8 @@ class MarketStore:
|
||||
""",
|
||||
(symbol, target_date, _json_dumps(payload), source, timestamp, timestamp),
|
||||
)
|
||||
count += 1
|
||||
return count
|
||||
|
||||
def delete_similar_day_cache(
|
||||
self,
|
||||
|
||||
Reference in New Issue
Block a user