refactor(storage): remove duplicate watchlist query

This commit is contained in:
leefer
2026-07-30 12:07:05 +08:00
parent 67e279a1d5
commit e0b065e38b
4 changed files with 17 additions and 19 deletions
@@ -50,6 +50,7 @@ from backend.features.market.insights.support import (
valid_date as _date,
)
from backend.features.market.insights.themes import build_theme_detail, build_theme_library
from backend.features.review.repository import ReviewRepository
SHANGHAI = ZoneInfo("Asia/Shanghai")
@@ -60,10 +61,15 @@ class MarketInsightError(RuntimeError):
class MarketInsightService:
def __init__(
self, database: Database, repository: MarketRepository, gateway: DataGateway
self,
database: Database,
repository: MarketRepository,
watchlists: ReviewRepository,
gateway: DataGateway,
) -> None:
self._database = database
self._repository = repository
self._watchlists = watchlists
self._gateway = gateway
def workspace(
@@ -211,7 +217,7 @@ class MarketInsightService:
market_rows = list(result.pop("_market_rows", ()))
with self._database.read() as connection:
watchlist = tuple(
dict(row) for row in self._repository.watchlist(connection, user_id)
dict(row) for row in self._watchlists.watchlist(connection, user_id)
)
result["watchlist_rows"] = build_watchlist_rows(
market_rows,