services.price_history
源文件
services/price_history.py· 由scripts/gen_api_docs.py自动生成,请勿手改
模块说明:
Market price history — ESI /markets/{region_id}/history/ Cache in market.db price_history table
函数
_ensure_table
python
def _ensure_table(db=None) -> NoneEnsure price_history table(与索引)exists in market.db
定义行:45
fetch_history
python
async def fetch_history(type_id: int, region_id: int=REGION_ID, session: aiohttp.ClientSession | None=None) -> list[dict] | NoneFetch price history from ESI /markets/{region_id}/history/
定义行:53
get_cached_history
python
def get_cached_history(type_id: int, region_id: int=REGION_ID, _db=None) -> list[dict] | NoneRead cached history from market.db
定义行:84
save_cache
python
def save_cache(type_id: int, region_id: int, data: list[dict], _db=None) -> NoneSave price history to market.db cache
定义行:113
get_history_summary
python
def get_history_summary(type_ids, region_id: int=REGION_ID, days: int=SUMMARY_DAYS, _db=None, today: date | None=None) -> dict[int, dict]读本地缓存,算「最近 days 个日历天的平均订单量 / 成交量」→ {type_id: {...}}。
定义行:151
类
class PriceHistoryService
价格历史服务 — 容器注入 DatabaseManager(替代模块级 get_db 单例)
定义行:236
方法
__init__
python
def __init__(self, db)⚠️ 待补 docstring
此函数暂无 docstring,欢迎补充。
定义行:239
fetch
python
async def fetch(self, type_id: int, region_id: int=REGION_ID, session=None) -> list[dict] | None拉取 ESI 历史价格(失败返回 None)
定义行:242
get_cached
python
def get_cached(self, type_id: int, region_id: int=REGION_ID) -> list[dict] | None读取缓存历史价格(TTL 内命中,否则 None)
定义行:246
save
python
def save(self, type_id: int, region_id: int, data: list[dict]) -> None写入缓存历史价格
定义行:250