diff --git a/VERSION b/VERSION index 2714f53..57cf282 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6.4 +2.6.5 diff --git a/api/web_routes.py b/api/web_routes.py index df98688..302352f 100644 --- a/api/web_routes.py +++ b/api/web_routes.py @@ -149,18 +149,9 @@ async def get_tv_series_list(dependencies: dict, """Get paginated list of TV series with episode counts""" db = dependencies["db"] - # Debug logging for 422 troubleshooting - try: - print(f"DEBUG: Series list params - skip:{skip}, limit:{limit}, search:'{search}', imdb_search:'{imdb_search}', date_filter:'{date_filter}', source_filter:'{source_filter}'") - - # Validate date_filter values - if date_filter and date_filter not in ['complete', 'incomplete', 'none']: - print(f"ERROR: Invalid date_filter value: '{date_filter}'") - raise HTTPException(status_code=422, detail=f"Invalid date_filter: must be 'complete', 'incomplete', or 'none', got '{date_filter}'") - - except Exception as e: - print(f"ERROR: Parameter validation failed: {e}") - raise + # Validate date_filter values + if date_filter and date_filter not in ['complete', 'incomplete', 'none']: + raise HTTPException(status_code=422, detail=f"Invalid date_filter: must be 'complete', 'incomplete', or 'none', got '{date_filter}'") with db.get_connection() as conn: cursor = conn.cursor() diff --git a/static/js/app.js b/static/js/app.js index 9921799..f550935 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -186,13 +186,21 @@ function getChartColor(index) { // Movies async function loadMovies(page = 1) { + // Ensure page is a valid number + if (isNaN(page) || page < 1) { + page = 1; + } + const search = document.getElementById('movies-search').value; const imdbSearch = document.getElementById('movies-imdb-search').value; const hasDate = document.getElementById('movies-filter-date').value; const sourceFilter = document.getElementById('movies-filter-source').value; + const skip = (page - 1) * 100; + console.log(`DEBUG: loadMovies called with page=${page}, calculated skip=${skip}`); + const params = new URLSearchParams({ - skip: (page - 1) * 100, + skip: skip, limit: 100 }); @@ -206,7 +214,7 @@ async function loadMovies(page = 1) { updateMoviesTable(data); updateMoviesPagination(data); updateMoviesSourceFilter(data); - currentMoviesPage = page; + currentMoviesPage = (isNaN(page) || page < 1) ? 1 : page; } catch (error) { console.error('Failed to load movies:', error); } @@ -347,18 +355,26 @@ async function loadSeriesSources() { } function refreshMovies() { - loadMovies(currentMoviesPage); + loadMovies(isNaN(currentMoviesPage) ? 1 : currentMoviesPage); } // TV Series async function loadSeries(page = 1) { + // Ensure page is a valid number + if (isNaN(page) || page < 1) { + page = 1; + } + const search = document.getElementById('series-search').value; const imdbSearch = document.getElementById('series-imdb-search').value; const dateFilter = document.getElementById('series-filter-date').value; const sourceFilter = document.getElementById('series-filter-source').value; + const skip = (page - 1) * 50; + console.log(`DEBUG: loadSeries called with page=${page}, calculated skip=${skip}`); + const params = new URLSearchParams({ - skip: (page - 1) * 50, + skip: skip, limit: 50 }); @@ -371,7 +387,7 @@ async function loadSeries(page = 1) { const data = await apiCall(`/api/series?${params}`); updateSeriesTable(data); updateSeriesPagination(data); - currentSeriesPage = page; + currentSeriesPage = (isNaN(page) || page < 1) ? 1 : page; } catch (error) { console.error('Failed to load series:', error); } @@ -437,7 +453,7 @@ function updateSeriesPagination(data) { } function refreshSeries() { - loadSeries(currentSeriesPage); + loadSeries(isNaN(currentSeriesPage) ? 1 : currentSeriesPage); } async function viewSeriesEpisodes(imdbId) {