fix: fix a couple of NaNs

This commit is contained in:
zyachel 2023-03-05 00:49:47 +05:30
parent f1efdf33e4
commit 71587d0db4
4 changed files with 34 additions and 37 deletions

View file

@ -21,7 +21,7 @@ const feedAnswerCleaner = answer => ({
numComments: answer.numDisplayComments,
numUpvotes: answer.numUpvotes,
numViews: answer.numViews,
numShares: answer.numSharers,
numShares: answer.numShares,
numAnswerRequests: answer.numRequesters,
isBusinessAnswer: answer.businessAnswer,
author: {
@ -55,7 +55,7 @@ const feedPostCleaner = post => ({
numComments: post.numDisplayComments,
numUpvotes: post.numUpvotes,
numViews: post.numViews,
numShares: post.numSharers,
numShares: post.numShares,
author: {
uid: post.author.uid,
isAnon: post.author.isAnon,

View file

@ -54,8 +54,7 @@ const answerCleaner = ({ question, previewAnswer: answer }) => ({
},
...(answer.originalQuestionIfDifferent && {
originalQuestion: {
text: JSON.parse(answer.originalQuestionIfDifferent.question.title)
.sections,
text: JSON.parse(answer.originalQuestionIfDifferent.question.title).sections,
url: quetrefy(answer.originalQuestionIfDifferent.question.url),
qid: answer.originalQuestionIfDifferent.question.qid,
},
@ -67,7 +66,7 @@ const answerCleaner = ({ question, previewAnswer: answer }) => ({
numComments: answer.numDisplayComments,
numUpvotes: answer.numUpvotes,
numViews: answer.numViews,
numShares: answer.numSharers,
numShares: answer.numShares,
numAnswerRequests: answer.numRequesters,
isBusinessAnswer: answer.businessAnswer,
url: quetrefy(answer.url),
@ -97,7 +96,7 @@ const postCleaner = post => ({
numComments: post.numDisplayComments,
numUpvotes: post.numUpvotes,
numViews: post.numViews,
numShares: post.numSharers,
numShares: post.numShares,
author: {
uid: post.author.uid,
isAnon: post.author.isAnon,

View file

@ -25,36 +25,35 @@ const getTopic = async (slug, lang) => {
404
);
const data = {
tid: rawData.tid,
name: rawData.name,
url: quetrefy(rawData.url),
image: rawData.photoUrl,
aliases: rawData.aliases,
numFollowers: rawData.numFollowers,
numQuestions: rawData.numQuestions,
// isLocked: rawData.isLocked,
isAdult: rawData.adult,
mostViewedAuthors: rawData.mostViewedAuthors.map(author => ({
uid: author.user.uid,
name: `${author.user.names[0].givenName} ${author.user.names[0].familyName}`,
profile: quetrefy(author.user.profileUrl),
image: author.user.profileImageUrl,
isAnon: author.user.isAnon,
isVerified: author.user.isVerified,
numFollowers: author.user.followerCount,
numViews: author.numViews,
numAnswers: author.numPublicMostViewedAnswers,
credential: author.user.bestCredential?.translatedString,
})),
relatedTopics: rawData.relatedTopics.map(topic => ({
tid: topic.tid,
name: topic.name,
url: quetrefy(topic.url),
image: topic.photoUrl,
numFollowers: topic.numFollowers,
})),
};
const data = {
tid: rawData.tid,
name: rawData.name,
url: quetrefy(rawData.url),
image: rawData.photoUrl,
aliases: rawData.aliases,
numFollowers: rawData.numFollowers,
// isLocked: rawData.isLocked,
isAdult: rawData.adult,
mostViewedAuthors: rawData.mostViewedAuthors.map(author => ({
uid: author.user.uid,
name: `${author.user.names[0].givenName} ${author.user.names[0].familyName}`,
profile: quetrefy(author.user.profileUrl),
image: author.user.profileImageUrl,
isAnon: author.user.isAnon,
isVerified: author.user.isVerified,
numFollowers: author.user.followerCount,
numViews: author.numViews,
numAnswers: author.numPublicMostViewedAnswers,
credential: author.user.bestCredential?.translatedString,
})),
relatedTopics: rawData.relatedTopics.map(topic => ({
tid: topic.tid,
name: topic.name,
url: quetrefy(topic.url),
image: topic.photoUrl,
numFollowers: topic.numFollowers,
})),
};
return data;
};

View file

@ -21,7 +21,6 @@ block content
span= data.aliases.join(', ')
.metadata-secondary
+addMetadataSecondary('user','Followers', data.numFollowers)
+addMetadataSecondary('question','Questions', data.numQuestions)
if data.isAdult
+addMetadataSecondary('danger', 'Adult Topic', '18+', true)
+quorafyUrl(meta.url)(class='link')