forked from DebaucheryLibrarian/traxxx
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)
|
// .concat(this.studios)
|
||||||
.sort(({ name: nameA }, { name: nameB }) => nameA.localeCompare(nameB));
|
.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() {
|
async function mounted() {
|
||||||
|
|
|
@ -52,6 +52,7 @@ function initActorActions(store, _router) {
|
||||||
$limit:Int = 1000,
|
$limit:Int = 1000,
|
||||||
$after:Date = "1900-01-01",
|
$after:Date = "1900-01-01",
|
||||||
$before:Date = "2100-01-01",
|
$before:Date = "2100-01-01",
|
||||||
|
$orderBy:[ReleasesActorsOrderBy!]
|
||||||
) {
|
) {
|
||||||
actor: actorBySlug(slug: $actorSlug) {
|
actor: actorBySlug(slug: $actorSlug) {
|
||||||
id
|
id
|
||||||
|
@ -120,7 +121,7 @@ function initActorActions(store, _router) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
first: $limit,
|
first: $limit,
|
||||||
orderBy: RELEASE_BY_RELEASE_ID__DATE_DESC,
|
orderBy: $orderBy
|
||||||
) {
|
) {
|
||||||
release {
|
release {
|
||||||
id
|
id
|
||||||
|
@ -151,6 +152,7 @@ function initActorActions(store, _router) {
|
||||||
limit,
|
limit,
|
||||||
after: store.getters.after,
|
after: store.getters.after,
|
||||||
before: store.getters.before,
|
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);
|
return curateActor(actor);
|
||||||
|
|
|
@ -48,7 +48,7 @@ function curateSite(site, network) {
|
||||||
return curatedSite;
|
return curatedSite;
|
||||||
}
|
}
|
||||||
|
|
||||||
function curateNetwork(network) {
|
function curateNetwork(network, releases) {
|
||||||
const curatedNetwork = {
|
const curatedNetwork = {
|
||||||
id: network.id,
|
id: network.id,
|
||||||
name: network.name,
|
name: network.name,
|
||||||
|
@ -56,13 +56,9 @@ function curateNetwork(network) {
|
||||||
url: network.url,
|
url: network.url,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (network.sites) {
|
if (network.sites) curatedNetwork.sites = network.sites.map(site => curateSite(site, curatedNetwork));
|
||||||
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));
|
||||||
|
|
||||||
if (network.studios) {
|
|
||||||
curatedNetwork.studios = network.studios;
|
|
||||||
}
|
|
||||||
|
|
||||||
return curatedNetwork;
|
return curatedNetwork;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,17 +95,7 @@ const releaseTrailerFragment = `
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const releasesFragment = `
|
const releaseFields = `
|
||||||
releases(
|
|
||||||
filter: {
|
|
||||||
date: {
|
|
||||||
lessThan: $before,
|
|
||||||
greaterThan: $after,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
first: $limit,
|
|
||||||
orderBy: DATE_DESC,
|
|
||||||
) {
|
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
date
|
date
|
||||||
|
@ -121,6 +111,20 @@ const releasesFragment = `
|
||||||
slug
|
slug
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const releasesFragment = `
|
||||||
|
releases(
|
||||||
|
filter: {
|
||||||
|
date: {
|
||||||
|
lessThan: $before,
|
||||||
|
greaterThan: $after,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
first: $limit,
|
||||||
|
orderBy: $orderBy,
|
||||||
|
) {
|
||||||
|
${releaseFields}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -151,6 +155,7 @@ const releaseFragment = `
|
||||||
|
|
||||||
export {
|
export {
|
||||||
releaseActorsFragment,
|
releaseActorsFragment,
|
||||||
|
releaseFields,
|
||||||
releaseTagsFragment,
|
releaseTagsFragment,
|
||||||
releasePosterFragment,
|
releasePosterFragment,
|
||||||
releasePhotosFragment,
|
releasePhotosFragment,
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
import { graphql } from '../api';
|
import { graphql } from '../api';
|
||||||
import { sitesFragment, releasesFragment } from '../fragments';
|
import { sitesFragment, releaseFields } from '../fragments';
|
||||||
import { curateNetwork } from '../curate';
|
import { curateNetwork } from '../curate';
|
||||||
|
|
||||||
function initNetworksActions(store, _router) {
|
function initNetworksActions(store, _router) {
|
||||||
async function fetchNetworkBySlug(networkSlug, limit = 100) {
|
async function fetchNetworkBySlug(networkSlug, limit = 100) {
|
||||||
const { network } = await graphql(`
|
const { network, releases } = await graphql(`
|
||||||
query Network(
|
query Network(
|
||||||
$networkSlug: String!
|
$networkSlug: String!
|
||||||
$limit:Int = 1000,
|
$limit:Int = 1000,
|
||||||
$after:Date = "1900-01-01",
|
$after:Date = "1900-01-01",
|
||||||
$before:Date = "2100-01-01",
|
$before:Date = "2100-01-01",
|
||||||
|
$orderBy: [ReleasesOrderBy!]
|
||||||
) {
|
) {
|
||||||
network: networkBySlug(slug: $networkSlug) {
|
network: networkBySlug(slug: $networkSlug) {
|
||||||
id
|
id
|
||||||
|
@ -22,7 +23,6 @@ function initNetworksActions(store, _router) {
|
||||||
slug
|
slug
|
||||||
url
|
url
|
||||||
independent
|
independent
|
||||||
${releasesFragment}
|
|
||||||
network {
|
network {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
@ -37,15 +37,29 @@ function initNetworksActions(store, _router) {
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
releases(
|
||||||
|
first: $limit,
|
||||||
|
orderBy: $orderBy,
|
||||||
|
filter: {
|
||||||
|
site: { network: { slug: { equalTo: $networkSlug } } }
|
||||||
|
date: {
|
||||||
|
lessThan: $before,
|
||||||
|
greaterThan: $after,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
${releaseFields}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`, {
|
`, {
|
||||||
networkSlug,
|
networkSlug,
|
||||||
limit,
|
limit,
|
||||||
after: store.getters.after,
|
after: store.getters.after,
|
||||||
before: store.getters.before,
|
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) {
|
async function fetchNetworks({ _commit }, networkSlug) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ function initReleasesActions(store, _router) {
|
||||||
$limit:Int = 1000,
|
$limit:Int = 1000,
|
||||||
$after:Date = "1900-01-01",
|
$after:Date = "1900-01-01",
|
||||||
$before:Date = "2100-01-01",
|
$before:Date = "2100-01-01",
|
||||||
|
$orderBy:[ReleasesOrderBy!]
|
||||||
) {
|
) {
|
||||||
${releasesFragment}
|
${releasesFragment}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +19,7 @@ function initReleasesActions(store, _router) {
|
||||||
limit,
|
limit,
|
||||||
after: store.getters.after,
|
after: store.getters.after,
|
||||||
before: store.getters.before,
|
before: store.getters.before,
|
||||||
|
orderBy: store.state.ui.range === 'upcoming' ? 'DATE_ASC' : 'DATE_DESC',
|
||||||
});
|
});
|
||||||
|
|
||||||
return releases.map(release => curateRelease(release));
|
return releases.map(release => curateRelease(release));
|
||||||
|
|
|
@ -10,6 +10,7 @@ function initSitesActions(store, _router) {
|
||||||
$limit:Int = 100,
|
$limit:Int = 100,
|
||||||
$after:Date = "1900-01-01",
|
$after:Date = "1900-01-01",
|
||||||
$before:Date = "2100-01-01",
|
$before:Date = "2100-01-01",
|
||||||
|
$orderBy:[ReleasesOrderBy!]
|
||||||
) {
|
) {
|
||||||
site: siteBySlug(slug: $siteSlug) {
|
site: siteBySlug(slug: $siteSlug) {
|
||||||
name
|
name
|
||||||
|
@ -29,10 +30,9 @@ function initSitesActions(store, _router) {
|
||||||
limit,
|
limit,
|
||||||
after: store.getters.after,
|
after: store.getters.after,
|
||||||
before: store.getters.before,
|
before: store.getters.before,
|
||||||
|
orderBy: store.state.ui.range === 'upcoming' ? 'DATE_ASC' : 'DATE_DESC',
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(site);
|
|
||||||
|
|
||||||
return curateSite(site);
|
return curateSite(site);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
import { graphql, get } from '../api';
|
import { graphql, get } from '../api';
|
||||||
import {
|
import {
|
||||||
releasePosterFragment,
|
releaseFields,
|
||||||
releaseActorsFragment,
|
|
||||||
releaseTagsFragment,
|
|
||||||
siteFragment,
|
|
||||||
} from '../fragments';
|
} from '../fragments';
|
||||||
import { curateTag } from '../curate';
|
import { curateTag } from '../curate';
|
||||||
|
|
||||||
function initTagsActions(store, _router) {
|
function initTagsActions(store, _router) {
|
||||||
async function fetchTagBySlug(tagSlug) {
|
async function fetchTagBySlug(tagSlug, limit = 100) {
|
||||||
const { tagBySlug } = await graphql(`
|
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) {
|
tagBySlug(slug:$tagSlug) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
@ -36,23 +39,30 @@ function initTagsActions(store, _router) {
|
||||||
comment
|
comment
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
releases: releasesTags {
|
releases: releasesTags(
|
||||||
|
filter: {
|
||||||
|
release: {
|
||||||
|
date: {
|
||||||
|
lessThan: $before,
|
||||||
|
greaterThan: $after,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
first: $limit,
|
||||||
|
orderBy: $orderBy,
|
||||||
|
) {
|
||||||
release {
|
release {
|
||||||
id
|
${releaseFields}
|
||||||
title
|
|
||||||
date
|
|
||||||
createdAt
|
|
||||||
url
|
|
||||||
${releaseActorsFragment}
|
|
||||||
${releaseTagsFragment}
|
|
||||||
${releasePosterFragment}
|
|
||||||
${siteFragment}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`, {
|
`, {
|
||||||
tagSlug,
|
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);
|
return curateTag(tagBySlug);
|
||||||
|
@ -70,8 +80,14 @@ function initTagsActions(store, _router) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { tags } = await graphql(`
|
const { tags } = await graphql(`
|
||||||
query Tags($slugs: [String!] = [], $limit: Int = 100) {
|
query Tags(
|
||||||
tags(filter: {slug: {in: $slugs}}, first: $limit) {
|
$slugs: [String!] = [],
|
||||||
|
$limit: Int = 100
|
||||||
|
) {
|
||||||
|
tags(
|
||||||
|
filter: { slug: { in: $slugs } },
|
||||||
|
first: $limit
|
||||||
|
) {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
slug
|
slug
|
||||||
|
|
Loading…
Reference in New Issue