Remove JSON-based ad-hoc history storage and migrate to SQLAlchemy database backend with improved duration parsing and comprehensive CRUD operations

This commit is contained in:
2025-12-05 09:34:40 -05:00
parent ad3a8a5639
commit 123ca2cc08
14 changed files with 1237 additions and 1147 deletions
+7
View File
@@ -35,6 +35,13 @@ class HostRepository:
result = await self.session.execute(stmt)
return result.scalar_one_or_none()
async def get_by_name(self, name: str, include_deleted: bool = False) -> Optional[Host]:
stmt = select(Host).where(Host.name == name)
if not include_deleted:
stmt = stmt.where(Host.deleted_at.is_(None))
result = await self.session.execute(stmt)
return result.scalar_one_or_none()
async def create(self, *, id: str, name: str, ip_address: str, ansible_group: Optional[str] = None,
status: str = "unknown", reachable: bool = False, last_seen: Optional[datetime] = None) -> Host:
host = Host(