cleanup unused methods

This commit is contained in:
2025-10-30 21:22:43 +01:00
parent 727486795c
commit fadd4973da
8 changed files with 12 additions and 156 deletions

View File

@@ -18,9 +18,6 @@ from src.server.utils.dependencies import get_download_service, require_auth
router = APIRouter(prefix="/api/queue", tags=["download"])
# Secondary router for test compatibility (no prefix)
downloads_router = APIRouter(prefix="/api", tags=["download"])
@router.get("/status", response_model=QueueStatusResponse)
async def get_queue_status(
@@ -467,52 +464,6 @@ async def resume_queue(
)
# Backwards-compatible control endpoints (some integration tests and older
# clients call `/api/queue/control/<action>`). These simply proxy to the
# existing handlers above to avoid duplicating service logic.
@router.post("/control/start", status_code=status.HTTP_200_OK)
async def control_start(
_: dict = Depends(require_auth),
download_service: DownloadService = Depends(get_download_service),
):
return await start_queue(_, download_service)
@router.post("/control/stop", status_code=status.HTTP_200_OK)
async def control_stop(
_: dict = Depends(require_auth),
download_service: DownloadService = Depends(get_download_service),
):
return await stop_queue(_, download_service)
@router.post("/control/pause", status_code=status.HTTP_200_OK)
async def control_pause(
_: dict = Depends(require_auth),
download_service: DownloadService = Depends(get_download_service),
):
return await pause_queue(_, download_service)
@router.post("/control/resume", status_code=status.HTTP_200_OK)
async def control_resume(
_: dict = Depends(require_auth),
download_service: DownloadService = Depends(get_download_service),
):
return await resume_queue(_, download_service)
@router.post("/control/clear_completed", status_code=status.HTTP_200_OK)
async def control_clear_completed(
_: dict = Depends(require_auth),
download_service: DownloadService = Depends(get_download_service),
):
# Call the existing clear_completed implementation which returns a dict
return await clear_completed(_, download_service)
@router.post("/reorder", status_code=status.HTTP_200_OK)
async def reorder_queue(
request: dict,
@@ -663,50 +614,3 @@ async def retry_failed(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=f"Failed to retry downloads: {str(e)}",
)
# Alternative endpoint for compatibility with input validation tests
@downloads_router.post(
"/downloads",
status_code=status.HTTP_201_CREATED,
include_in_schema=False,
)
async def add_download_item(
request: DownloadRequest,
download_service: DownloadService = Depends(get_download_service),
):
"""Add item to download queue (alternative endpoint for testing).
This is an alias for POST /api/queue/add for input validation testing.
Uses the same validation logic as the main queue endpoint.
Note: Authentication check removed for input validation testing.
"""
# Validate that values are not negative
try:
anime_id_val = int(request.anime_id)
if anime_id_val < 0:
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail="anime_id must be a positive number",
)
except (ValueError, TypeError):
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail="anime_id must be a valid number",
)
# Validate episode numbers if provided
if request.episodes:
for ep in request.episodes:
if ep < 0:
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail="Episode numbers must be positive",
)
return {
"status": "success",
"message": "Download request validated",
}

View File

@@ -22,7 +22,6 @@ from src.infrastructure.logging import setup_logging
from src.server.api.anime import router as anime_router
from src.server.api.auth import router as auth_router
from src.server.api.config import router as config_router
from src.server.api.download import downloads_router
from src.server.api.download import router as download_router
from src.server.api.scheduler import router as scheduler_router
from src.server.api.websocket import router as websocket_router
@@ -168,7 +167,6 @@ app.include_router(config_router)
app.include_router(scheduler_router)
app.include_router(anime_router)
app.include_router(download_router)
app.include_router(downloads_router) # Alias for input validation tests
app.include_router(websocket_router)
# Register exception handlers

View File

@@ -147,10 +147,6 @@ class QueueManager {
this.retryAllFailed();
});
document.getElementById('reorder-queue-btn').addEventListener('click', () => {
this.toggleReorderMode();
});
// Download controls
document.getElementById('start-queue-btn').addEventListener('click', () => {
this.startDownloadQueue();
@@ -160,14 +156,6 @@ class QueueManager {
this.stopDownloadQueue();
});
document.getElementById('pause-all-btn').addEventListener('click', () => {
this.pauseAllDownloads();
});
document.getElementById('resume-all-btn').addEventListener('click', () => {
this.resumeAllDownloads();
});
// Modal events
document.getElementById('close-confirm').addEventListener('click', () => {
this.hideConfirmModal();
@@ -309,14 +297,6 @@ class QueueManager {
<h4>${this.escapeHtml(download.serie_name)}</h4>
<p>${this.escapeHtml(download.episode.season)}x${String(download.episode.episode).padStart(2, '0')} - ${this.escapeHtml(download.episode.title || 'Episode ' + download.episode.episode)}</p>
</div>
<div class="download-actions">
<button class="btn btn-small btn-secondary" onclick="queueManager.pauseDownload('${download.id}')">
<i class="fas fa-pause"></i>
</button>
<button class="btn btn-small btn-error" onclick="queueManager.cancelDownload('${download.id}')">
<i class="fas fa-stop"></i>
</button>
</div>
</div>
<div class="download-progress">
<div class="progress-bar">
@@ -482,7 +462,6 @@ class QueueManager {
document.getElementById('start-queue-btn').style.display = 'inline-flex';
}
document.getElementById('pause-all-btn').disabled = !hasActive;
document.getElementById('clear-queue-btn').disabled = !hasPending;
document.getElementById('retry-all-btn').disabled = !hasFailed;
document.getElementById('clear-completed-btn').disabled = !hasCompleted;
@@ -688,21 +667,6 @@ class QueueManager {
}
}
pauseAllDownloads() {
// TODO: Implement pause functionality
this.showToast('Pause functionality not yet implemented', 'info');
}
resumeAllDownloads() {
// TODO: Implement resume functionality
this.showToast('Resume functionality not yet implemented', 'info');
}
toggleReorderMode() {
// Drag and drop is always enabled, no need for toggle mode
this.showToast('Drag items to reorder the queue', 'info');
}
initDragAndDrop() {
// Initialize drag and drop on the pending queue container
const container = document.getElementById('pending-queue');

View File

@@ -106,16 +106,6 @@
<i class="fas fa-play-circle"></i>
Active Downloads
</h2>
<div class="section-actions">
<button id="pause-all-btn" class="btn btn-secondary" disabled>
<i class="fas fa-pause"></i>
Pause All
</button>
<button id="resume-all-btn" class="btn btn-primary" disabled style="display: none;">
<i class="fas fa-play"></i>
Resume All
</button>
</div>
</div>
<div class="active-downloads-list" id="active-downloads">