refactor: remove database access from core layer
- Remove db_session parameter from SeriesApp, SerieList, SerieScanner - Move all database operations to AnimeService (service layer) - Add add_series_to_db, contains_in_db methods to AnimeService - Update sync_series_from_data_files to use inline DB operations - Remove obsolete test classes for removed DB methods - Fix pylint issues: add broad-except comments, fix line lengths - Core layer (src/core/) now has zero database imports 722 unit tests pass
This commit is contained in:
@@ -169,43 +169,6 @@ async def get_optional_database_session() -> AsyncGenerator:
|
||||
yield None
|
||||
|
||||
|
||||
async def get_series_app_with_db(
|
||||
db: AsyncSession = Depends(get_optional_database_session),
|
||||
) -> SeriesApp:
|
||||
"""
|
||||
Dependency to get SeriesApp instance with database support.
|
||||
|
||||
This creates or returns a SeriesApp instance and injects the
|
||||
database session for database-backed storage.
|
||||
|
||||
Args:
|
||||
db: Optional database session from dependency injection
|
||||
|
||||
Returns:
|
||||
SeriesApp: The main application instance with database support
|
||||
|
||||
Raises:
|
||||
HTTPException: If SeriesApp is not initialized or anime directory
|
||||
is not configured
|
||||
|
||||
Example:
|
||||
@app.post("/api/anime/scan")
|
||||
async def scan_anime(
|
||||
series_app: SeriesApp = Depends(get_series_app_with_db)
|
||||
):
|
||||
# series_app has db_session configured
|
||||
await series_app.serie_scanner.scan_async()
|
||||
"""
|
||||
# Get the base SeriesApp
|
||||
app = get_series_app()
|
||||
|
||||
# Inject database session if available
|
||||
if db:
|
||||
app.set_db_session(db)
|
||||
|
||||
return app
|
||||
|
||||
|
||||
def get_current_user(
|
||||
credentials: Optional[HTTPAuthorizationCredentials] = Depends(
|
||||
http_bearer_security
|
||||
|
||||
Reference in New Issue
Block a user