fix(name): fix name route crash

this commit fixes a crash in name route caused by upstream

closes https://github.com/zyachel/libremdb/issues/51
This commit is contained in:
zyachel 2023-06-18 14:31:40 +05:30
parent c610ef4d1b
commit 38ed0c6217
3 changed files with 228 additions and 218 deletions

View file

@ -39,10 +39,12 @@ const Basic = ({ data, className }: Props) => {
{data.bio.short}...
</p>
}
{data.knownFor.title && (
<p className={styles.genres}>
<span className={styles.heading}>Known for: </span>
{data.knownFor.title} ({data.knownFor.role})
</p>
)}
</CardBasic>
);
};

View file

@ -6,13 +6,13 @@ export default interface Name {
nameText: {
text: string;
};
disambiguator?: {
text: string;
};
/*
searchIndexing: {
disableIndexing: boolean
}*/
disambiguator?: {
text: string;
};
knownFor: {
edges: Array<{
node: {
@ -49,18 +49,17 @@ export default interface Name {
publicationStatus: string
}
*/
primaryProfessions: Array<{
category: {
text: string;
};
}>;
bio: {
text: {
plainText: string;
plaidHtml: string;
};
};
primaryProfessions: Array<{
category: {
text: string;
};
}>;
birthDate: {
displayableProperty: {
value: {
@ -105,6 +104,9 @@ export default interface Name {
subNavAwardNominations: {
total: number;
};
subNavFaqs: {
total: number;
};
// videos: {
// total: number;
// };
@ -222,185 +224,21 @@ export default interface Name {
};
}>;
};
// primaryImage: {
// id: string;
// caption: {
// plainText: string;
// };
// height: number;
// width: number;
// url: string;
// };
// imageUploadLink: null;
// nameText: {
// text: string;
// };
knownFor: {
edges: Array<{
node: {
summary: {
attributes?: Array<{
text: string;
}>;
episodeCount?: number;
principalCategory: {
text: string;
id: string;
};
principalCharacters?: Array<{
name: string;
}>;
principalJobs?: Array<{
id: string;
text: string;
}>;
yearRange: {
year: number;
endYear?: number;
};
};
credit: {
attributes?: Array<{
text: string;
}>;
category: {
id: string;
text: string;
};
characters?: Array<{
name: string;
}>;
episodeCredits: {
total: number;
yearRange?: {
year: number;
endYear: number;
};
displayableYears: {
total: number;
edges: Array<{
node: {
year: string;
displayableProperty: {
value: {
plainText: string;
};
};
};
}>;
};
displayableSeasons: {
total: number;
edges: Array<{
node: {
season: string;
displayableProperty: {
value: {
plainText: string;
};
};
};
}>;
};
};
jobs?: Array<{
id: string;
text: string;
}>;
};
title: {
id: string;
canRate: {
isRatable: boolean;
};
certificate?: {
rating: string;
};
originalTitleText: {
text: string;
};
titleText: {
text: string;
};
titleType: {
canHaveEpisodes: boolean;
displayableProperty: {
value: {
plainText: string;
};
};
text: string;
id: 'movie' | 'tvSeries' | 'tvEpisode' | 'videoGame';
};
/*
primaryImage: {
id: string;
url: string;
height: number;
width: number;
caption: {
plainText: string;
};
height: number;
width: number;
url: string;
};
ratingsSummary: {
aggregateRating?: number;
voteCount: number;
};
latestTrailer?: {
id: string;
};
releaseYear: {
year: number;
endYear?: number;
};
runtime?: {
seconds: number;
};
series: null;
episodes?: {
displayableSeasons: {
total: number;
edges: Array<{
node: {
season: string;
displayableProperty: {
value: {
plainText: string;
};
};
};
}>;
};
displayableYears: {
total: number;
edges: Array<{
node: {
year: string;
displayableProperty: {
value: {
plainText: string;
};
};
};
}>;
};
};
titleGenres: {
genres: Array<{
genre: {
imageUploadLink: null;
nameText: {
text: string;
};
}>;
};
productionStatus: {
currentProductionStage: {
id: string;
text: string;
};
};
};
};
}>;
};
*/
primaryProfessions: Array<{
category: {
text: string;
@ -753,6 +591,172 @@ export default interface Name {
};
}>;
};
knownForFeature: {
edges: Array<{
node: {
summary: {
attributes?: Array<{
text: string;
}>;
episodeCount?: number;
principalCategory: {
text: string;
id: string;
};
principalCharacters?: Array<{
name: string;
}>;
principalJobs?: Array<{
id: string;
text: string;
}>;
yearRange: {
year: number;
endYear?: number;
};
};
credit: {
attributes?: Array<{
text: string;
}>;
category: {
id: string;
text: string;
};
characters?: Array<{
name: string;
}>;
episodeCredits: {
total: number;
yearRange?: {
year: number;
endYear: number;
};
displayableYears: {
total: number;
edges: Array<{
node: {
year: string;
displayableProperty: {
value: {
plainText: string;
};
};
};
}>;
};
displayableSeasons: {
total: number;
edges: Array<{
node: {
season: string;
displayableProperty: {
value: {
plainText: string;
};
};
};
}>;
};
};
jobs?: Array<{
id: string;
text: string;
}>;
};
title: {
id: string;
canRate: {
isRatable: boolean;
};
certificate?: {
rating: string;
};
originalTitleText: {
text: string;
};
titleText: {
text: string;
};
titleType: {
canHaveEpisodes: boolean;
displayableProperty: {
value: {
plainText: string;
};
};
text: string;
id: 'movie' | 'tvSeries' | 'tvEpisode' | 'videoGame';
};
primaryImage: {
id: string;
url: string;
height: number;
width: number;
caption: {
plainText: string;
};
};
ratingsSummary: {
aggregateRating?: number;
voteCount: number;
};
latestTrailer?: {
id: string;
};
releaseYear: {
year: number;
endYear?: number;
};
runtime?: {
seconds: number;
};
series: null;
episodes?: {
displayableSeasons: {
total: number;
edges: Array<{
node: {
season: string;
displayableProperty: {
value: {
plainText: string;
};
};
};
}>;
};
displayableYears: {
total: number;
edges: Array<{
node: {
year: string;
displayableProperty: {
value: {
plainText: string;
};
};
};
}>;
};
};
titleGenres: {
genres: Array<{
genre: {
text: string;
};
}>;
};
productionStatus: {
currentProductionStage: {
id: string;
text: string;
};
};
};
};
}>;
};
videos: {
total: number;
edges: Array<{
@ -799,18 +803,20 @@ export default interface Name {
};
};
};
// birthDate: {
// dateComponents: {
// day?: number;
// month?: number;
// year: number;
// };
// displayableProperty: {
// value: {
// plainText: string;
// };
// };
// };
/*
birthDate: {
dateComponents: {
day?: number;
month?: number;
year: number;
};
displayableProperty: {
value: {
plainText: string;
};
};
};
*/
birthLocation: {
text: string;
displayableProperty: {
@ -819,18 +825,20 @@ export default interface Name {
};
};
};
// deathDate?: {
// dateComponents: {
// day?: number;
// month?: number;
// year: number;
// };
// displayableProperty: {
// value: {
// plainText: string;
// };
// };
// };
/*
deathDate?: {
dateComponents: {
day?: number;
month?: number;
year: number;
};
displayableProperty: {
value: {
plainText: string;
};
};
};
*/
deathLocation?: {
text: string;
displayableProperty: {

View file

@ -14,8 +14,8 @@ const cleanName = (rawData: RawName) => {
name: main.nameText.text,
nameSuffix: main.disambiguator?.text ?? null,
knownFor: {
title: main.knownFor.edges[0].node.title.titleText.text,
role: main.knownFor.edges[0].node.summary.principalCategory.text,
title: main.knownFor.edges[0]?.node.title.titleText.text ?? null,
role: main.knownFor.edges[0]?.node.summary.principalCategory.text ?? null,
},
...(main.primaryImage && {
poster: {
@ -87,7 +87,7 @@ const cleanName = (rawData: RawName) => {
},
}),
},
knownFor: misc.knownFor.edges.map(item => ({
knownFor: misc.knownForFeature.edges.map(item => ({
id: item.node.title.id,
title: item.node.title.titleText.text,
...(item.node.title.primaryImage && {