From 09a901da99a09665e49a1d52a6f489118ca5bf99 Mon Sep 17 00:00:00 2001 From: SurfaceS Date: Sun, 22 Oct 2023 22:18:07 +0200 Subject: [PATCH] rating as integer sort by desc --- .../net/pms/database/MediaTableTVSeries.java | 2 +- .../pms/database/MediaTableVideoMetadata.java | 2 +- .../store/container/MediaLibraryFolder.java | 20 ++++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/pms/database/MediaTableTVSeries.java b/src/main/java/net/pms/database/MediaTableTVSeries.java index cdd43875dc8..9cc5d5ebe8d 100644 --- a/src/main/java/net/pms/database/MediaTableTVSeries.java +++ b/src/main/java/net/pms/database/MediaTableTVSeries.java @@ -149,7 +149,7 @@ public final class MediaTableTVSeries extends MediaTable { */ public static final String CHILD_ID = "TVSERIESID"; public static final String FIRSTAIRDATE_FORMATED = "FORMATDATETIME(" + TABLE_COL_FIRSTAIRDATE + ", 'yyyy')"; - public static final String FLOOR_RATING = "FLOOR(" + TABLE_COL_RATING + ")"; + public static final String FLOOR_RATING = "CAST(FLOOR(" + TABLE_COL_RATING + ") AS INT)"; /** * Checks and creates or upgrades the table as needed. diff --git a/src/main/java/net/pms/database/MediaTableVideoMetadata.java b/src/main/java/net/pms/database/MediaTableVideoMetadata.java index bf0cd7719f0..7eec48453b1 100644 --- a/src/main/java/net/pms/database/MediaTableVideoMetadata.java +++ b/src/main/java/net/pms/database/MediaTableVideoMetadata.java @@ -148,7 +148,7 @@ public class MediaTableVideoMetadata extends MediaTable { private static final int SIZE_IMDBID = 16; private static final int SIZE_TVEPISODENUMBER = 8; public static final String RELEASEDATE_FORMATED = "FORMATDATETIME(" + TABLE_COL_RELEASEDATE + ", 'yyyy')"; - public static final String FLOOR_RATING = "FLOOR(" + TABLE_COL_RATING + ")"; + public static final String FLOOR_RATING = "CAST(FLOOR(" + TABLE_COL_RATING + ") AS INT)"; /** * Checks and creates or upgrades the table as needed. diff --git a/src/main/java/net/pms/store/container/MediaLibraryFolder.java b/src/main/java/net/pms/store/container/MediaLibraryFolder.java index 1a4bee35aa4..335cf48b24a 100644 --- a/src/main/java/net/pms/store/container/MediaLibraryFolder.java +++ b/src/main/java/net/pms/store/container/MediaLibraryFolder.java @@ -158,9 +158,9 @@ private static List getTVSeriesQueries(String tableName, String columnNa return queries; } - private static List getTVSeriesQueries(String columnName) { + private static List getTVSeriesQueries(String columnName, boolean desc) { List queries = new ArrayList<>(); - queries.add(SELECT + columnName + FROM + MediaTableTVSeries.TABLE_NAME + ORDER_BY + columnName + ASC); + queries.add(SELECT + columnName + FROM + MediaTableTVSeries.TABLE_NAME + ORDER_BY + columnName + (desc ? DESC : ASC)); queries.add(SELECT + MediaTableTVSeries.TABLE_COL_ID + ", " + MediaTableTVSeries.TABLE_COL_TITLE + FROM + MediaTableTVSeries.TABLE_NAME + WHERE + columnName + EQUAL + "'${0}'" + ORDER_BY + MediaTableTVSeries.TABLE_COL_TITLE + ASC); queries.add(SELECT_ALL + FROM_FILES_VIDEOMETA_TV_SERIES + WHERE + FORMAT_TYPE_VIDEO + AND + TVEPISODE_CONDITION + AND + MediaTableTVSeries.TABLE_COL_ID + EQUAL + "${0}" + ORDER_BY + MediaTableVideoMetadata.TABLE_COL_TVEPISODENUMBER); return queries; @@ -314,8 +314,8 @@ public void doRefreshChildren() { countriesSqls = getTVSeriesQueries(MediaTableVideoMetadataCountries.TABLE_NAME, MediaTableVideoMetadataCountries.TABLE_COL_COUNTRY); directorsSqls = getTVSeriesQueries(MediaTableVideoMetadataDirectors.TABLE_NAME, MediaTableVideoMetadataDirectors.TABLE_COL_DIRECTOR); genresSqls = getTVSeriesQueries(MediaTableVideoMetadataGenres.TABLE_NAME, MediaTableVideoMetadataGenres.TABLE_COL_GENRE); - ratedSqls = getTVSeriesQueries(MediaTableTVSeries.TABLE_COL_RATED); - ratingSqls = getTVSeriesQueries(MediaTableTVSeries.FLOOR_RATING); + ratedSqls = getTVSeriesQueries(MediaTableTVSeries.TABLE_COL_RATED, false); + ratingSqls = getTVSeriesQueries(MediaTableTVSeries.FLOOR_RATING, true); releasedSqls = getTVSeriesQueriesByFirstAirDate(); } else { actorsSqls.add(getFirstNonTVSeriesQuery(firstSql, MediaTableVideoMetadataActors.TABLE_NAME, MediaTableVideoMetadataActors.TABLE_COL_ACTOR, false)); @@ -440,9 +440,6 @@ public void doRefreshChildren() { break; } - int[] filteredExpectedOutputsWithPrependedTexts = filteredExpectedOutputs.clone(); - filteredExpectedOutputsWithPrependedTexts = ArrayUtils.insert(0, filteredExpectedOutputsWithPrependedTexts, TEXTS); - if (!unwatchedSqls.isEmpty() && !watchedSqls.isEmpty()) { LocalizedStoreContainer filterByProgress = new LocalizedStoreContainer(renderer, "FilterByProgress"); filterByProgress.addChild(new MediaLibraryFolder( @@ -460,6 +457,11 @@ public void doRefreshChildren() { addChild(filterByProgress); } if (!genresSqls.isEmpty()) { + int[] filteredExpectedOutputsWithPrependedTexts = filteredExpectedOutputs.clone(); + filteredExpectedOutputsWithPrependedTexts = ArrayUtils.insert(0, filteredExpectedOutputsWithPrependedTexts, TEXTS); + int[] filteredExpectedOutputsWithPrependedTextsNoSort = filteredExpectedOutputs.clone(); + filteredExpectedOutputsWithPrependedTextsNoSort = ArrayUtils.insert(0, filteredExpectedOutputsWithPrependedTextsNoSort, TEXTS_NOSORT); + LocalizedStoreContainer filterByInformation = new LocalizedStoreContainer(renderer, "FilterByInformation"); filterByInformation.addChild(new MediaLibraryFolder( renderer, @@ -495,13 +497,13 @@ public void doRefreshChildren() { renderer, "Rating", ratingSqls.toArray(String[]::new), - filteredExpectedOutputsWithPrependedTexts + filteredExpectedOutputsWithPrependedTextsNoSort )); filterByInformation.addChild(new MediaLibraryFolder( renderer, "Released", releasedSqls.toArray(String[]::new), - filteredExpectedOutputsWithPrependedTexts + filteredExpectedOutputsWithPrependedTextsNoSort )); LOGGER.trace("filteredExpectedOutputsWithPrependedTexts: " + Arrays.toString(filteredExpectedOutputsWithPrependedTexts)); LOGGER.trace("genresSqls: " + genresSqls.toString());