new changes
This commit is contained in:
@@ -626,6 +626,34 @@ async def get_site_count(db: AsyncSession) -> int:
|
||||
return result.scalar() or 0
|
||||
|
||||
|
||||
async def ssl_alert_summary(db: AsyncSession) -> dict:
|
||||
"""Sites with LE certs expiring soon or expired (for dashboard banners)."""
|
||||
result = await db.execute(select(Site).order_by(Site.id))
|
||||
sites = result.scalars().all()
|
||||
expired: list[dict] = []
|
||||
expiring: list[dict] = []
|
||||
for s in sites:
|
||||
domain_result = await db.execute(select(Domain).where(Domain.pid == s.id).order_by(Domain.id))
|
||||
domain_rows = domain_result.scalars().all()
|
||||
hostnames = [d.name for d in domain_rows]
|
||||
if not hostnames:
|
||||
continue
|
||||
ssl = _best_ssl_for_hostnames(hostnames)
|
||||
if ssl["status"] == "expired":
|
||||
expired.append({
|
||||
"site": s.name,
|
||||
"primary": hostnames[0],
|
||||
"days_left": ssl.get("days_left"),
|
||||
})
|
||||
elif ssl["status"] == "expiring":
|
||||
expiring.append({
|
||||
"site": s.name,
|
||||
"primary": hostnames[0],
|
||||
"days_left": ssl.get("days_left"),
|
||||
})
|
||||
return {"expired": expired, "expiring": expiring}
|
||||
|
||||
|
||||
async def get_site_with_domains(db: AsyncSession, site_id: int) -> dict | None:
|
||||
"""Get site with domain list for editing."""
|
||||
result = await db.execute(select(Site).where(Site.id == site_id))
|
||||
|
||||
Reference in New Issue
Block a user