Modified network releases query to accomodate date sorting. Showing upcoming releases first to last.
This commit is contained in:
parent
58f01a2f75
commit
9da63baf65
|
@ -89,7 +89,7 @@ async function fetchNetwork() {
|
|||
// .concat(this.studios)
|
||||
.sort(({ name: nameA }, { name: nameB }) => nameA.localeCompare(nameB));
|
||||
|
||||
this.releases = this.network.sites.map(site => site.releases).flat();
|
||||
this.releases = this.network.releases;
|
||||
}
|
||||
|
||||
async function mounted() {
|
||||
|
|
|
@ -52,6 +52,7 @@ function initActorActions(store, _router) {
|
|||
$limit:Int = 1000,
|
||||
$after:Date = "1900-01-01",
|
||||
$before:Date = "2100-01-01",
|
||||
$orderBy:[ReleasesActorsOrderBy!]
|
||||
) {
|
||||
actor: actorBySlug(slug: $actorSlug) {
|
||||
id
|
||||
|
@ -120,7 +121,7 @@ function initActorActions(store, _router) {
|
|||
}
|
||||
},
|
||||
first: $limit,
|
||||
orderBy: RELEASE_BY_RELEASE_ID__DATE_DESC,
|
||||
orderBy: $orderBy
|
||||
) {
|
||||
release {
|
||||
id
|
||||
|
@ -151,6 +152,7 @@ function initActorActions(store, _router) {
|
|||
limit,
|
||||
after: store.getters.after,
|
||||
before: store.getters.before,
|
||||
orderBy: store.state.ui.range === 'upcoming' ? 'RELEASE_BY_RELEASE_ID__DATE_ASC' : 'RELEASE_BY_RELEASE_ID__DATE_DESC',
|
||||
});
|
||||
|
||||
return curateActor(actor);
|
||||
|
|
|
@ -48,7 +48,7 @@ function curateSite(site, network) {
|
|||
return curatedSite;
|
||||
}
|
||||
|
||||
function curateNetwork(network) {
|
||||
function curateNetwork(network, releases) {
|
||||
const curatedNetwork = {
|
||||
id: network.id,
|
||||
name: network.name,
|
||||
|
@ -56,13 +56,9 @@ function curateNetwork(network) {
|
|||
url: network.url,
|
||||
};
|
||||
|
||||
if (network.sites) {
|
||||
curatedNetwork.sites = network.sites.map(site => curateSite(site, curatedNetwork));
|
||||
}
|
||||
|
||||
if (network.studios) {
|
||||
curatedNetwork.studios = network.studios;
|
||||
}
|
||||
if (network.sites) curatedNetwork.sites = network.sites.map(site => curateSite(site, curatedNetwork));
|
||||
if (network.studios) curatedNetwork.studios = network.studios;
|
||||
if (releases) curatedNetwork.releases = releases.map(release => curateRelease(release));
|
||||
|
||||
return curatedNetwork;
|
||||
}
|
||||
|
|
|
@ -95,6 +95,24 @@ const releaseTrailerFragment = `
|
|||
}
|
||||
`;
|
||||
|
||||
const releaseFields = `
|
||||
id
|
||||
title
|
||||
date
|
||||
createdAt
|
||||
url
|
||||
${releaseActorsFragment}
|
||||
${releaseTagsFragment}
|
||||
${releasePosterFragment}
|
||||
${siteFragment}
|
||||
studio {
|
||||
id
|
||||
name
|
||||
slug
|
||||
url
|
||||
}
|
||||
`;
|
||||
|
||||
const releasesFragment = `
|
||||
releases(
|
||||
filter: {
|
||||
|
@ -104,23 +122,9 @@ const releasesFragment = `
|
|||
}
|
||||
},
|
||||
first: $limit,
|
||||
orderBy: DATE_DESC,
|
||||
orderBy: $orderBy,
|
||||
) {
|
||||
id
|
||||
title
|
||||
date
|
||||
createdAt
|
||||
url
|
||||
${releaseActorsFragment}
|
||||
${releaseTagsFragment}
|
||||
${releasePosterFragment}
|
||||
${siteFragment}
|
||||
studio {
|
||||
id
|
||||
name
|
||||
slug
|
||||
url
|
||||
}
|
||||
${releaseFields}
|
||||
}
|
||||
`;
|
||||
|
||||
|
@ -151,6 +155,7 @@ const releaseFragment = `
|
|||
|
||||
export {
|
||||
releaseActorsFragment,
|
||||
releaseFields,
|
||||
releaseTagsFragment,
|
||||
releasePosterFragment,
|
||||
releasePhotosFragment,
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import { graphql } from '../api';
|
||||
import { sitesFragment, releasesFragment } from '../fragments';
|
||||
import { sitesFragment, releaseFields } from '../fragments';
|
||||
import { curateNetwork } from '../curate';
|
||||
|
||||
function initNetworksActions(store, _router) {
|
||||
async function fetchNetworkBySlug(networkSlug, limit = 100) {
|
||||
const { network } = await graphql(`
|
||||
const { network, releases } = await graphql(`
|
||||
query Network(
|
||||
$networkSlug: String!
|
||||
$limit:Int = 1000,
|
||||
$after:Date = "1900-01-01",
|
||||
$before:Date = "2100-01-01",
|
||||
$orderBy: [ReleasesOrderBy!]
|
||||
) {
|
||||
network: networkBySlug(slug: $networkSlug) {
|
||||
id
|
||||
|
@ -17,18 +18,17 @@ function initNetworksActions(store, _router) {
|
|||
slug
|
||||
url
|
||||
sites {
|
||||
id
|
||||
name
|
||||
slug
|
||||
url
|
||||
independent
|
||||
${releasesFragment}
|
||||
network {
|
||||
id
|
||||
name
|
||||
slug
|
||||
url
|
||||
}
|
||||
independent
|
||||
network {
|
||||
id
|
||||
name
|
||||
slug
|
||||
url
|
||||
}
|
||||
}
|
||||
studios {
|
||||
id
|
||||
|
@ -37,15 +37,29 @@ function initNetworksActions(store, _router) {
|
|||
url
|
||||
}
|
||||
}
|
||||
releases(
|
||||
first: $limit,
|
||||
orderBy: $orderBy,
|
||||
filter: {
|
||||
site: { network: { slug: { equalTo: $networkSlug } } }
|
||||
date: {
|
||||
lessThan: $before,
|
||||
greaterThan: $after,
|
||||
}
|
||||
}
|
||||
) {
|
||||
${releaseFields}
|
||||
}
|
||||
}
|
||||
`, {
|
||||
networkSlug,
|
||||
limit,
|
||||
after: store.getters.after,
|
||||
before: store.getters.before,
|
||||
orderBy: store.state.ui.range === 'upcoming' ? 'DATE_ASC' : 'DATE_DESC',
|
||||
});
|
||||
|
||||
return curateNetwork(network);
|
||||
return curateNetwork(network, releases);
|
||||
}
|
||||
|
||||
async function fetchNetworks({ _commit }, networkSlug) {
|
||||
|
|
|
@ -11,6 +11,7 @@ function initReleasesActions(store, _router) {
|
|||
$limit:Int = 1000,
|
||||
$after:Date = "1900-01-01",
|
||||
$before:Date = "2100-01-01",
|
||||
$orderBy:[ReleasesOrderBy!]
|
||||
) {
|
||||
${releasesFragment}
|
||||
}
|
||||
|
@ -18,6 +19,7 @@ function initReleasesActions(store, _router) {
|
|||
limit,
|
||||
after: store.getters.after,
|
||||
before: store.getters.before,
|
||||
orderBy: store.state.ui.range === 'upcoming' ? 'DATE_ASC' : 'DATE_DESC',
|
||||
});
|
||||
|
||||
return releases.map(release => curateRelease(release));
|
||||
|
|
|
@ -10,6 +10,7 @@ function initSitesActions(store, _router) {
|
|||
$limit:Int = 100,
|
||||
$after:Date = "1900-01-01",
|
||||
$before:Date = "2100-01-01",
|
||||
$orderBy:[ReleasesOrderBy!]
|
||||
) {
|
||||
site: siteBySlug(slug: $siteSlug) {
|
||||
name
|
||||
|
@ -29,10 +30,9 @@ function initSitesActions(store, _router) {
|
|||
limit,
|
||||
after: store.getters.after,
|
||||
before: store.getters.before,
|
||||
orderBy: store.state.ui.range === 'upcoming' ? 'DATE_ASC' : 'DATE_DESC',
|
||||
});
|
||||
|
||||
console.log(site);
|
||||
|
||||
return curateSite(site);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import { graphql, get } from '../api';
|
||||
import {
|
||||
releasePosterFragment,
|
||||
releaseActorsFragment,
|
||||
releaseTagsFragment,
|
||||
siteFragment,
|
||||
releaseFields,
|
||||
} from '../fragments';
|
||||
import { curateTag } from '../curate';
|
||||
|
||||
function initTagsActions(store, _router) {
|
||||
async function fetchTagBySlug(tagSlug) {
|
||||
async function fetchTagBySlug(tagSlug, limit = 100) {
|
||||
const { tagBySlug } = await graphql(`
|
||||
query Tag($tagSlug:String!) {
|
||||
query Tag(
|
||||
$tagSlug:String!
|
||||
$limit:Int = 1000,
|
||||
$after:Date = "1900-01-01",
|
||||
$before:Date = "2100-01-01",
|
||||
$orderBy: [ReleasesTagsOrderBy!]
|
||||
) {
|
||||
tagBySlug(slug:$tagSlug) {
|
||||
id
|
||||
name
|
||||
|
@ -36,23 +39,30 @@ function initTagsActions(store, _router) {
|
|||
comment
|
||||
}
|
||||
}
|
||||
releases: releasesTags {
|
||||
releases: releasesTags(
|
||||
filter: {
|
||||
release: {
|
||||
date: {
|
||||
lessThan: $before,
|
||||
greaterThan: $after,
|
||||
}
|
||||
}
|
||||
},
|
||||
first: $limit,
|
||||
orderBy: $orderBy,
|
||||
) {
|
||||
release {
|
||||
id
|
||||
title
|
||||
date
|
||||
createdAt
|
||||
url
|
||||
${releaseActorsFragment}
|
||||
${releaseTagsFragment}
|
||||
${releasePosterFragment}
|
||||
${siteFragment}
|
||||
${releaseFields}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`, {
|
||||
tagSlug,
|
||||
limit,
|
||||
after: store.getters.after,
|
||||
before: store.getters.before,
|
||||
orderBy: store.state.ui.range === 'upcoming' ? 'RELEASE_BY_RELEASE_ID__DATE_ASC' : 'RELEASE_BY_RELEASE_ID__DATE_DESC',
|
||||
});
|
||||
|
||||
return curateTag(tagBySlug);
|
||||
|
@ -70,21 +80,27 @@ function initTagsActions(store, _router) {
|
|||
}
|
||||
|
||||
const { tags } = await graphql(`
|
||||
query Tags($slugs: [String!] = [], $limit: Int = 100) {
|
||||
tags(filter: {slug: {in: $slugs}}, first: $limit) {
|
||||
id
|
||||
name
|
||||
slug
|
||||
poster: tagsPosterByTagId {
|
||||
media {
|
||||
thumbnail
|
||||
}
|
||||
}
|
||||
group {
|
||||
query Tags(
|
||||
$slugs: [String!] = [],
|
||||
$limit: Int = 100
|
||||
) {
|
||||
tags(
|
||||
filter: { slug: { in: $slugs } },
|
||||
first: $limit
|
||||
) {
|
||||
id
|
||||
name
|
||||
slug
|
||||
poster: tagsPosterByTagId {
|
||||
media {
|
||||
thumbnail
|
||||
}
|
||||
}
|
||||
group {
|
||||
name
|
||||
slug
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`, {
|
||||
slugs,
|
||||
|
|
Loading…
Reference in New Issue