Enabled network filters for actors. Separated filter definition for entities.

This commit is contained in:
DebaucheryLibrarian
2020-09-09 03:28:33 +02:00
parent 00f1fc39fa
commit d1cdd60ee8
6 changed files with 97 additions and 47 deletions

View File

@@ -1,6 +1,6 @@
import config from 'config';
import { graphql, get } from '../api';
import { releaseFields } from '../fragments';
import { releaseFields, getIncludedEntities } from '../fragments';
import { curateActor, curateRelease } from '../curate';
import getDateRange from '../get-date-range';
@@ -12,8 +12,7 @@ function initActorActions(store, router) {
range = 'latest',
}) {
const { before, after, orderBy } = getDateRange(range);
const includeChannels = router.currentRoute.query.channels ? router.currentRoute.query.channels.split(',') : [];
const includeTags = router.currentRoute.query.tags ? router.currentRoute.query.tags.split(',') : [];
const includedTags = router.currentRoute.query.tags ? router.currentRoute.query.tags.split(',') : [];
const mode = router.currentRoute.query.mode || 'all';
const { actor } = await graphql(`
@@ -25,9 +24,9 @@ function initActorActions(store, router) {
$before:Datetime = "2100-01-01",
$orderBy:[ReleasesOrderBy!]
$selectableTags: [String],
$includeTags: [String!],
$includedTags: [String!],
$mode: String!,
${includeChannels.length > 0 ? '$includeChannels: [String!]' : ''}
$includedEntities: [ReleaseFilter!]
) {
actor(id: $actorId) {
id
@@ -167,14 +166,9 @@ function initActorActions(store, router) {
lessThan: $before,
greaterThan: $after,
}
${includeChannels.length > 0 ? `
entity: {
slug: {
in: $includeChannels
}
}` : ''}
or: $includedEntities
}
selectedTags: $includeTags
selectedTags: $includedTags
mode: $mode
first: $limit
offset: $offset
@@ -196,8 +190,8 @@ function initActorActions(store, router) {
selectableTags: config.selectableTags,
orderBy,
excludeTags: store.state.ui.filter,
includeTags,
includeChannels,
includedTags,
includedEntities: getIncludedEntities(router),
mode,
});

View File

@@ -319,6 +319,48 @@ const releaseFragment = `
}
`;
function getIncludedEntities(router) {
const includedChannels = router.currentRoute.query.channels ? router.currentRoute.query.channels.split(',') : [];
const includedNetworks = router.currentRoute.query.networks ? router.currentRoute.query.networks.split(',') : [];
if (includedChannels.length === 0 && includedNetworks.length === 0) {
return [];
}
return [
{
entity: {
slug: {
in: includedChannels,
},
},
},
{
entity: {
parent: {
type: {
equalTo: 'network',
},
slug: {
in: includedNetworks,
},
},
},
},
{
entity: {
type: {
equalTo: 'network',
},
slug: {
in: includedNetworks,
},
},
},
];
}
export {
releaseActorsFragment,
releaseFields,
@@ -330,4 +372,5 @@ export {
releaseFragment,
siteFragment,
sitesFragment,
getIncludedEntities,
};