image_mgr/wwwroot/api/image_stats.dspy

11 lines
707 B
Plaintext

env = request._run_ns
dbname = get_module_dbname('image_mgr')
try:
async with DBPools().sqlorContext(dbname) as sor:
mirrors = await sor.R('mirror_source', {})
registries = await sor.R('image_registry', {})
images = await sor.R('container_image', {})
return {'widgettype': 'Text', 'options': {'otext': '镜像: ' + str(len(mirrors or [])) + ' 镜像源\n仓库: ' + str(len(registries or [])) + ' | 镜像: ' + str(len(images or [])) + '\n活跃源: ' + str(sum(1 for m in (mirrors or []) if getattr(m,'status','')=='active')), 'cfontsize': 0.9, 'color': '#1e293b'}}
except:
return {'widgettype': 'Text', 'options': {'otext': '镜像: 加载失败', 'color': '#dc2626'}}