New: Unify series custom filter options

Closes #3548
This commit is contained in:
Robin Dadswell 2021-01-30 22:34:20 +00:00 committed by GitHub
parent 39ca348666
commit ec058436d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 198 additions and 271 deletions

View File

@ -11,7 +11,7 @@ function createMapStateToProps() {
return { return {
sectionItems, sectionItems,
filterBuilderProps, filterBuilderProps,
customFilterType: 'seasonPass' customFilterType: 'series'
}; };
} }
); );

View File

@ -18,10 +18,10 @@ class SeasonPassRow extends Component {
render() { render() {
const { const {
seriesId, seriesId,
status,
titleSlug,
title,
monitored, monitored,
status,
title,
titleSlug,
seasons, seasons,
isSaving, isSaving,
isSelected, isSelected,
@ -84,10 +84,10 @@ class SeasonPassRow extends Component {
SeasonPassRow.propTypes = { SeasonPassRow.propTypes = {
seriesId: PropTypes.number.isRequired, seriesId: PropTypes.number.isRequired,
status: PropTypes.string.isRequired,
titleSlug: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
monitored: PropTypes.bool.isRequired, monitored: PropTypes.bool.isRequired,
status: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
titleSlug: PropTypes.string.isRequired,
seasons: PropTypes.arrayOf(PropTypes.object).isRequired, seasons: PropTypes.arrayOf(PropTypes.object).isRequired,
isSaving: PropTypes.bool.isRequired, isSaving: PropTypes.bool.isRequired,
isSelected: PropTypes.bool, isSelected: PropTypes.bool,

View File

@ -11,7 +11,7 @@ function createMapStateToProps() {
return { return {
sectionItems, sectionItems,
filterBuilderProps, filterBuilderProps,
customFilterType: 'seriesEditor' customFilterType: 'series'
}; };
} }
); );

View File

@ -27,17 +27,17 @@ class SeriesEditorRow extends Component {
render() { render() {
const { const {
id, id,
status,
titleSlug,
title,
monitored, monitored,
languageProfile, status,
qualityProfile, title,
titleSlug,
seriesType, seriesType,
seasonFolder, qualityProfile,
languageProfile,
path, path,
statistics = {},
tags, tags,
seasonFolder,
statistics = {},
columns, columns,
isSelected, isSelected,
onSelectedChange onSelectedChange

View File

@ -11,7 +11,7 @@ function createMapStateToProps() {
return { return {
sectionItems, sectionItems,
filterBuilderProps, filterBuilderProps,
customFilterType: 'seriesIndex' customFilterType: 'series'
}; };
} }
); );

View File

@ -1,12 +1,12 @@
import { createAction } from 'redux-actions'; import { createAction } from 'redux-actions';
import createAjaxRequest from 'Utilities/createAjaxRequest'; import createAjaxRequest from 'Utilities/createAjaxRequest';
import { filterBuilderTypes, filterBuilderValueTypes, sortDirections } from 'Helpers/Props'; import { sortDirections } from 'Helpers/Props';
import { createThunk, handleThunks } from 'Store/thunks'; import { createThunk, handleThunks } from 'Store/thunks';
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer'; import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer'; import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
import createHandleActions from './Creators/createHandleActions'; import createHandleActions from './Creators/createHandleActions';
import { set } from './baseActions'; import { set } from './baseActions';
import { fetchSeries, filters, filterPredicates } from './seriesActions'; import { fetchSeries, filters, filterPredicates, filterBuilderProps } from './seriesActions';
// //
// Variables // Variables
@ -27,48 +27,7 @@ export const defaultState = {
filters, filters,
filterPredicates, filterPredicates,
filterBuilderProps: [ filterBuilderProps
{
name: 'monitored',
label: 'Monitored',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.BOOL
},
{
name: 'status',
label: 'Status',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.SERIES_STATUS
},
{
name: 'seriesType',
label: 'Series Type',
type: filterBuilderTypes.EXACT
},
{
name: 'qualityProfileId',
label: 'Quality Profile',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.QUALITY_PROFILE
},
{
name: 'languageProfileId',
label: 'Language Profile',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.LANGUAGE_PROFILE
},
{
name: 'rootFolderPath',
label: 'Root Folder Path',
type: filterBuilderTypes.EXACT
},
{
name: 'tags',
label: 'Tags',
type: filterBuilderTypes.ARRAY,
valueType: filterBuilderValueTypes.TAG
}
]
}; };
export const persistState = [ export const persistState = [

View File

@ -2,8 +2,9 @@ import _ from 'lodash';
import { createAction } from 'redux-actions'; import { createAction } from 'redux-actions';
import { batchActions } from 'redux-batched-actions'; import { batchActions } from 'redux-batched-actions';
import createAjaxRequest from 'Utilities/createAjaxRequest'; import createAjaxRequest from 'Utilities/createAjaxRequest';
import sortByName from 'Utilities/Array/sortByName';
import dateFilterPredicate from 'Utilities/Date/dateFilterPredicate'; import dateFilterPredicate from 'Utilities/Date/dateFilterPredicate';
import { filterTypePredicates, filterTypes, sortDirections } from 'Helpers/Props'; import { filterBuilderTypes, filterBuilderValueTypes, filterTypePredicates, filterTypes, sortDirections } from 'Helpers/Props';
import { createThunk, handleThunks } from 'Store/thunks'; import { createThunk, handleThunks } from 'Store/thunks';
import createSetSettingValueReducer from './Creators/Reducers/createSetSettingValueReducer'; import createSetSettingValueReducer from './Creators/Reducers/createSetSettingValueReducer';
import createFetchHandler from './Creators/createFetchHandler'; import createFetchHandler from './Creators/createFetchHandler';
@ -89,6 +90,23 @@ export const filters = [
]; ];
export const filterPredicates = { export const filterPredicates = {
episodeProgress: function(item, filterValue, type) {
const { statistics = {} } = item;
const {
episodeCount = 0,
episodeFileCount
} = statistics;
const progress = episodeCount ?
episodeFileCount / episodeCount * 100 :
100;
const predicate = filterTypePredicates[type];
return predicate(progress, filterValue);
},
missing: function(item) { missing: function(item) {
const { statistics = {} } = item; const { statistics = {} } = item;
@ -130,6 +148,142 @@ export const filterPredicates = {
} }
}; };
export const filterBuilderProps = [
{
name: 'monitored',
label: 'Monitored',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.BOOL
},
{
name: 'status',
label: 'Status',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.SERIES_STATUS
},
{
name: 'seriesType',
label: 'Type',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.SERIES_TYPES
},
{
name: 'network',
label: 'Network',
type: filterBuilderTypes.STRING,
optionsSelector: function(items) {
const tagList = items.reduce((acc, series) => {
if (series.network) {
acc.push({
id: series.network,
name: series.network
});
}
return acc;
}, []);
return tagList.sort(sortByName);
}
},
{
name: 'qualityProfileId',
label: 'Quality Profile',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.QUALITY_PROFILE
},
{
name: 'languageProfileId',
label: 'Language Profile',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.LANGUAGE_PROFILE
},
{
name: 'nextAiring',
label: 'Next Airing',
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
{
name: 'previousAiring',
label: 'Previous Airing',
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
{
name: 'added',
label: 'Added',
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
{
name: 'seasonCount',
label: 'Season Count',
type: filterBuilderTypes.NUMBER
},
{
name: 'episodeProgress',
label: 'Episode Progress',
type: filterBuilderTypes.NUMBER
},
{
name: 'path',
label: 'Path',
type: filterBuilderTypes.STRING
},
{
name: 'rootFolderPath',
label: 'Root Folder Path',
type: filterBuilderTypes.EXACT
},
{
name: 'sizeOnDisk',
label: 'Size on Disk',
type: filterBuilderTypes.NUMBER,
valueType: filterBuilderValueTypes.BYTES
},
{
name: 'genres',
label: 'Genres',
type: filterBuilderTypes.ARRAY,
optionsSelector: function(items) {
const tagList = items.reduce((acc, series) => {
series.genres.forEach((genre) => {
acc.push({
id: genre,
name: genre
});
});
return acc;
}, []);
return tagList.sort(sortByName);
}
},
{
name: 'ratings',
label: 'Rating',
type: filterBuilderTypes.NUMBER
},
{
name: 'certification',
label: 'Certification',
type: filterBuilderTypes.EXACT
},
{
name: 'tags',
label: 'Tags',
type: filterBuilderTypes.ARRAY,
valueType: filterBuilderValueTypes.TAG
},
{
name: 'useSceneNumbering',
label: 'Scene Numbering',
type: filterBuilderTypes.EXACT
}
];
export const sortPredicates = { export const sortPredicates = {
status: function(item) { status: function(item) {
let result = 0; let result = 0;

View File

@ -1,14 +1,14 @@
import { createAction } from 'redux-actions'; import { createAction } from 'redux-actions';
import { batchActions } from 'redux-batched-actions'; import { batchActions } from 'redux-batched-actions';
import createAjaxRequest from 'Utilities/createAjaxRequest'; import createAjaxRequest from 'Utilities/createAjaxRequest';
import { filterBuilderTypes, filterBuilderValueTypes, sortDirections } from 'Helpers/Props'; import { sortDirections } from 'Helpers/Props';
import { createThunk, handleThunks } from 'Store/thunks'; import { createThunk, handleThunks } from 'Store/thunks';
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer'; import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer'; import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer'; import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
import createHandleActions from './Creators/createHandleActions'; import createHandleActions from './Creators/createHandleActions';
import { set, updateItem } from './baseActions'; import { set, updateItem } from './baseActions';
import { filters, filterPredicates, sortPredicates } from './seriesActions'; import { filters, filterPredicates, filterBuilderProps } from './seriesActions';
// //
// Variables // Variables
@ -90,61 +90,7 @@ export const defaultState = {
} }
], ],
filterBuilderProps: [ filterBuilderProps
{
name: 'monitored',
label: 'Monitored',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.BOOL
},
{
name: 'status',
label: 'Status',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.SERIES_STATUS
},
{
name: 'seriesType',
label: 'Series Type',
type: filterBuilderTypes.EXACT
},
{
name: 'qualityProfileId',
label: 'Quality Profile',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.QUALITY_PROFILE
},
{
name: 'languageProfileId',
label: 'Language Profile',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.LANGUAGE_PROFILE
},
{
name: 'path',
label: 'Path',
type: filterBuilderTypes.STRING
},
{
name: 'rootFolderPath',
label: 'Root Folder Path',
type: filterBuilderTypes.EXACT
},
{
name: 'sizeOnDisk',
label: 'Size on Disk',
type: filterBuilderTypes.NUMBER,
valueType: filterBuilderValueTypes.BYTES
},
{
name: 'tags',
label: 'Tags',
type: filterBuilderTypes.ARRAY,
valueType: filterBuilderValueTypes.TAG
}
],
sortPredicates
}; };
export const persistState = [ export const persistState = [

View File

@ -1,12 +1,11 @@
import moment from 'moment'; import moment from 'moment';
import { createAction } from 'redux-actions'; import { createAction } from 'redux-actions';
import sortByName from 'Utilities/Array/sortByName'; import { sortDirections } from 'Helpers/Props';
import { filterBuilderTypes, filterBuilderValueTypes, filterTypePredicates, sortDirections } from 'Helpers/Props';
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer'; import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer'; import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer'; import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
import createHandleActions from './Creators/createHandleActions'; import createHandleActions from './Creators/createHandleActions';
import { filters, filterPredicates, sortPredicates } from './seriesActions'; import { filters, filterPredicates, filterBuilderProps, sortPredicates } from './seriesActions';
// //
// Variables // Variables
@ -247,157 +246,9 @@ export const defaultState = {
filters, filters,
filterPredicates: { filterPredicates,
...filterPredicates,
episodeProgress: function(item, filterValue, type) { filterBuilderProps
const { statistics = {} } = item;
const {
episodeCount = 0,
episodeFileCount
} = statistics;
const progress = episodeCount ?
episodeFileCount / episodeCount * 100 :
100;
const predicate = filterTypePredicates[type];
return predicate(progress, filterValue);
}
},
filterBuilderProps: [
{
name: 'monitored',
label: 'Monitored',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.BOOL
},
{
name: 'status',
label: 'Status',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.SERIES_STATUS
},
{
name: 'seriesType',
label: 'Type',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.SERIES_TYPES
},
{
name: 'network',
label: 'Network',
type: filterBuilderTypes.STRING,
optionsSelector: function(items) {
const tagList = items.reduce((acc, series) => {
if (series.network) {
acc.push({
id: series.network,
name: series.network
});
}
return acc;
}, []);
return tagList.sort(sortByName);
}
},
{
name: 'qualityProfileId',
label: 'Quality Profile',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.QUALITY_PROFILE
},
{
name: 'languageProfileId',
label: 'Language Profile',
type: filterBuilderTypes.EXACT,
valueType: filterBuilderValueTypes.LANGUAGE_PROFILE
},
{
name: 'nextAiring',
label: 'Next Airing',
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
{
name: 'previousAiring',
label: 'Previous Airing',
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
{
name: 'added',
label: 'Added',
type: filterBuilderTypes.DATE,
valueType: filterBuilderValueTypes.DATE
},
{
name: 'seasonCount',
label: 'Season Count',
type: filterBuilderTypes.NUMBER
},
{
name: 'episodeProgress',
label: 'Episode Progress',
type: filterBuilderTypes.NUMBER
},
{
name: 'path',
label: 'Path',
type: filterBuilderTypes.STRING
},
{
name: 'sizeOnDisk',
label: 'Size on Disk',
type: filterBuilderTypes.NUMBER,
valueType: filterBuilderValueTypes.BYTES
},
{
name: 'genres',
label: 'Genres',
type: filterBuilderTypes.ARRAY,
optionsSelector: function(items) {
const tagList = items.reduce((acc, series) => {
series.genres.forEach((genre) => {
acc.push({
id: genre,
name: genre
});
});
return acc;
}, []);
return tagList.sort(sortByName);
}
},
{
name: 'ratings',
label: 'Rating',
type: filterBuilderTypes.NUMBER
},
{
name: 'certification',
label: 'Certification',
type: filterBuilderTypes.EXACT
},
{
name: 'tags',
label: 'Tags',
type: filterBuilderTypes.ARRAY,
valueType: filterBuilderValueTypes.TAG
},
{
name: 'useSceneNumbering',
label: 'Scene Numbering',
type: filterBuilderTypes.EXACT
}
]
}; };
export const persistState = [ export const persistState = [

View File

@ -0,0 +1,17 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(151)]
public class remove_custom_filter_type : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Update.Table("CustomFilters").Set(new { Type = "series" }).Where(new { Type = "seriesIndex" });
Update.Table("CustomFilters").Set(new { Type = "series" }).Where(new { Type = "seriesEditor" });
Update.Table("CustomFilters").Set(new { Type = "series" }).Where(new { Type = "seasonPass" });
}
}
}