New: Unify series custom filter options

Closes #3548
pull/4290/head
Robin Dadswell 4 years ago committed by GitHub
parent 39ca348666
commit ec058436d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

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

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

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

@ -1,12 +1,12 @@
import { createAction } from 'redux-actions';
import createAjaxRequest from 'Utilities/createAjaxRequest';
import { filterBuilderTypes, filterBuilderValueTypes, sortDirections } from 'Helpers/Props';
import { sortDirections } from 'Helpers/Props';
import { createThunk, handleThunks } from 'Store/thunks';
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
import createHandleActions from './Creators/createHandleActions';
import { set } from './baseActions';
import { fetchSeries, filters, filterPredicates } from './seriesActions';
import { fetchSeries, filters, filterPredicates, filterBuilderProps } from './seriesActions';
//
// Variables
@ -27,48 +27,7 @@ export const defaultState = {
filters,
filterPredicates,
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
}
]
filterBuilderProps
};
export const persistState = [

@ -2,8 +2,9 @@ import _ from 'lodash';
import { createAction } from 'redux-actions';
import { batchActions } from 'redux-batched-actions';
import createAjaxRequest from 'Utilities/createAjaxRequest';
import sortByName from 'Utilities/Array/sortByName';
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 createSetSettingValueReducer from './Creators/Reducers/createSetSettingValueReducer';
import createFetchHandler from './Creators/createFetchHandler';
@ -89,6 +90,23 @@ export const filters = [
];
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) {
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 = {
status: function(item) {
let result = 0;

@ -1,14 +1,14 @@
import { createAction } from 'redux-actions';
import { batchActions } from 'redux-batched-actions';
import createAjaxRequest from 'Utilities/createAjaxRequest';
import { filterBuilderTypes, filterBuilderValueTypes, sortDirections } from 'Helpers/Props';
import { sortDirections } from 'Helpers/Props';
import { createThunk, handleThunks } from 'Store/thunks';
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
import createHandleActions from './Creators/createHandleActions';
import { set, updateItem } from './baseActions';
import { filters, filterPredicates, sortPredicates } from './seriesActions';
import { filters, filterPredicates, filterBuilderProps } from './seriesActions';
//
// Variables
@ -90,61 +90,7 @@ export const defaultState = {
}
],
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
filterBuilderProps
};
export const persistState = [

@ -1,12 +1,11 @@
import moment from 'moment';
import { createAction } from 'redux-actions';
import sortByName from 'Utilities/Array/sortByName';
import { filterBuilderTypes, filterBuilderValueTypes, filterTypePredicates, sortDirections } from 'Helpers/Props';
import { sortDirections } from 'Helpers/Props';
import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer';
import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer';
import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer';
import createHandleActions from './Creators/createHandleActions';
import { filters, filterPredicates, sortPredicates } from './seriesActions';
import { filters, filterPredicates, filterBuilderProps, sortPredicates } from './seriesActions';
//
// Variables
@ -247,157 +246,9 @@ export const defaultState = {
filters,
filterPredicates: {
...filterPredicates,
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);
}
},
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
}
]
filterBuilderProps
};
export const persistState = [

@ -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" });
}
}
}
Loading…
Cancel
Save