mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 15:38:19 +08:00
refactor(site): route runtime queries through explicit repository
This commit is contained in:
@@ -723,7 +723,10 @@ async def init_modules() -> HostRuntime:
|
|||||||
)
|
)
|
||||||
configure_passkey_service(PasskeyService(repository=PassKeyOper()))
|
configure_passkey_service(PasskeyService(repository=PassKeyOper()))
|
||||||
configure_transfer_history_provider(lambda: TransferHistoryOper())
|
configure_transfer_history_provider(lambda: TransferHistoryOper())
|
||||||
configure_site_query_service(SiteQueryService(repository=SiteOper()))
|
configure_site_query_service(SiteQueryService(repository=TransactionalSiteRepository(
|
||||||
|
sync_session=SessionFactory,
|
||||||
|
async_session=async_session_scope,
|
||||||
|
)))
|
||||||
configure_site_health_service(SiteHealthService(repository=TransactionalSiteRepository(
|
configure_site_health_service(SiteHealthService(repository=TransactionalSiteRepository(
|
||||||
sync_session=SessionFactory,
|
sync_session=SessionFactory,
|
||||||
async_session=async_session_scope,
|
async_session=async_session_scope,
|
||||||
|
|||||||
@@ -88,6 +88,14 @@ class TransactionalSiteRepository:
|
|||||||
"""查询全部站点。"""
|
"""查询全部站点。"""
|
||||||
return self._read(lambda repository: repository.list())
|
return self._read(lambda repository: repository.list())
|
||||||
|
|
||||||
|
def list_order_by_pri(self) -> list[Any]:
|
||||||
|
"""同步按优先级查询站点。"""
|
||||||
|
return self._read(lambda repository: repository.list_order_by_pri())
|
||||||
|
|
||||||
|
def get_userdata_latest(self) -> list[Any]:
|
||||||
|
"""同步查询各站点最新用户数据。"""
|
||||||
|
return self._read(lambda repository: repository.get_userdata_latest())
|
||||||
|
|
||||||
async def async_get(self, site_id: int) -> Any:
|
async def async_get(self, site_id: int) -> Any:
|
||||||
"""异步按 ID 查询站点。"""
|
"""异步按 ID 查询站点。"""
|
||||||
return await self._async_read(lambda repository: repository.async_get(site_id))
|
return await self._async_read(lambda repository: repository.async_get(site_id))
|
||||||
@@ -130,6 +138,30 @@ class TransactionalSiteRepository:
|
|||||||
lambda repository: repository.async_get_userdata_by_domain(domain, workdate)
|
lambda repository: repository.async_get_userdata_by_domain(domain, workdate)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def async_get_userdata_latest(self) -> list[Any]:
|
||||||
|
"""异步查询各站点最新用户数据。"""
|
||||||
|
return await self._async_read(
|
||||||
|
lambda repository: repository.async_get_userdata_latest()
|
||||||
|
)
|
||||||
|
|
||||||
|
async def async_get_icon_by_domain(self, domain: str) -> Any:
|
||||||
|
"""异步按域名查询站点图标。"""
|
||||||
|
return await self._async_read(
|
||||||
|
lambda repository: repository.async_get_icon_by_domain(domain)
|
||||||
|
)
|
||||||
|
|
||||||
|
async def async_get_statistic_by_domain(self, domain: str) -> Any:
|
||||||
|
"""异步按域名查询站点统计。"""
|
||||||
|
return await self._async_read(
|
||||||
|
lambda repository: repository.async_get_statistic_by_domain(domain)
|
||||||
|
)
|
||||||
|
|
||||||
|
async def async_list_statistics(self) -> list[Any]:
|
||||||
|
"""异步查询全部站点统计。"""
|
||||||
|
return await self._async_read(
|
||||||
|
lambda repository: repository.async_list_statistics()
|
||||||
|
)
|
||||||
|
|
||||||
def update(self, site_id: int, payload: dict[str, Any]) -> Any:
|
def update(self, site_id: int, payload: dict[str, Any]) -> Any:
|
||||||
"""更新站点并提交事务。"""
|
"""更新站点并提交事务。"""
|
||||||
return self._write(lambda repository: repository.update(site_id, payload))
|
return self._write(lambda repository: repository.update(site_id, payload))
|
||||||
|
|||||||
+1
-1
@@ -238,7 +238,7 @@ def configure_plugin_system_services():
|
|||||||
module_dispatcher_factory=ModuleInvocationDispatcher,
|
module_dispatcher_factory=ModuleInvocationDispatcher,
|
||||||
configuration=build_chain_runtime_config(settings),
|
configuration=build_chain_runtime_config(settings),
|
||||||
))
|
))
|
||||||
configure_site_query_service(SiteQueryService(repository=SiteOper()))
|
configure_site_query_service(SiteQueryService(repository=site_repository()))
|
||||||
configure_site_health_service(SiteHealthService(repository=site_repository()))
|
configure_site_health_service(SiteHealthService(repository=site_repository()))
|
||||||
configure_workflow_query(WorkflowQueryService(repository=WorkflowOper()))
|
configure_workflow_query(WorkflowQueryService(repository=WorkflowOper()))
|
||||||
from app.db.oper.agenttask import AgentTaskOper
|
from app.db.oper.agenttask import AgentTaskOper
|
||||||
|
|||||||
Reference in New Issue
Block a user