chore: apply pending code updates

This commit is contained in:
2026-03-17 11:39:27 +01:00
parent e5fae0a0a2
commit 92bd55ada1
45 changed files with 2236 additions and 2130 deletions

View File

@@ -98,7 +98,7 @@ async def initialize_database(
seed_data=True
)
if result["success"]:
logger.info(f"Database initialized: {result['schema_version']}")
logger.info("Database initialized: %s", result['schema_version'])
"""
if engine is None:
engine = get_engine()
@@ -117,7 +117,7 @@ async def initialize_database(
if create_schema:
tables = await create_database_schema(engine)
result["tables_created"] = tables
logger.info(f"Created {len(tables)} tables")
logger.info("Created %s tables", len(tables))
# Validate schema if requested
if validate_schema:
@@ -148,7 +148,7 @@ async def initialize_database(
return result
except Exception as e:
logger.error(f"Database initialization failed: {e}", exc_info=True)
logger.exception("Database initialization failed: %s", e)
raise RuntimeError(f"Failed to initialize database: {e}") from e
@@ -194,14 +194,14 @@ async def create_database_schema(
created_tables = [t for t in new_tables if t not in existing_tables]
if created_tables:
logger.info(f"Created tables: {', '.join(created_tables)}")
logger.info("Created tables: %s", ', '.join(created_tables))
else:
logger.info("All tables already exist")
return new_tables
except Exception as e:
logger.error(f"Failed to create schema: {e}", exc_info=True)
logger.exception("Failed to create schema: %s", e)
raise RuntimeError(f"Schema creation failed: {e}") from e
@@ -295,7 +295,7 @@ async def validate_database_schema(
return result
except Exception as e:
logger.error(f"Schema validation failed: {e}", exc_info=True)
logger.exception("Schema validation failed: %s", e)
return {
"valid": False,
"missing_tables": [],
@@ -342,7 +342,7 @@ async def get_schema_version(engine: Optional[AsyncEngine] = None) -> str:
return "unknown"
except Exception as e:
logger.error(f"Failed to get schema version: {e}")
logger.error("Failed to get schema version: %s", e)
return "error"
@@ -409,7 +409,7 @@ async def seed_initial_data(engine: Optional[AsyncEngine] = None) -> None:
logger.info("Data will be populated via normal application usage")
except Exception as e:
logger.error(f"Failed to seed initial data: {e}", exc_info=True)
logger.exception("Failed to seed initial data: %s", e)
raise
@@ -484,12 +484,12 @@ async def check_database_health(
f"(connectivity: {result['connectivity_ms']}ms)"
)
else:
logger.warning(f"Database health issues: {result['issues']}")
logger.warning("Database health issues: %s", result['issues'])
return result
except Exception as e:
logger.error(f"Database health check failed: {e}")
logger.error("Database health check failed: %s", e)
return {
"healthy": False,
"accessible": False,
@@ -547,13 +547,13 @@ async def create_database_backup(
backup_path = backup_dir / f"aniworld_{timestamp}.db"
try:
logger.info(f"Creating database backup: {backup_path}")
logger.info("Creating database backup: %s", backup_path)
shutil.copy2(db_path, backup_path)
logger.info(f"Backup created successfully: {backup_path}")
logger.info("Backup created successfully: %s", backup_path)
return backup_path
except Exception as e:
logger.error(f"Failed to create backup: {e}", exc_info=True)
logger.exception("Failed to create backup: %s", e)
raise RuntimeError(f"Backup creation failed: {e}") from e