Skip to content

Commit

Permalink
rating as integer
Browse files Browse the repository at this point in the history
sort by desc
  • Loading branch information
SurfaceS committed Oct 22, 2023
1 parent f54fceb commit 09a901d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/pms/database/MediaTableTVSeries.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 11 additions & 9 deletions src/main/java/net/pms/store/container/MediaLibraryFolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ private static List<String> getTVSeriesQueries(String tableName, String columnNa
return queries;
}

private static List<String> getTVSeriesQueries(String columnName) {
private static List<String> getTVSeriesQueries(String columnName, boolean desc) {
List<String> 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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 09a901d

Please sign in to comment.