refactor(metrics/insights): new features (#1098)

This commit is contained in:
Simon Lecoq
2022-06-24 22:35:09 +02:00
committed by GitHub
parent 79b80b1900
commit 3c4402e4ba
10 changed files with 732 additions and 142 deletions

View File

@@ -52,8 +52,11 @@ export default async function({login, q, imports, data, graphql, queries, accoun
for (const [key, value] of Object.entries(list))
list[key] = {value, percentage: value / reactions.length, score: value / (display === "relative" ? max : reactions.length)}
//Compute total reactions
const total = Object.values(list).map(({value}) => value).reduce((a, b) => a + b, 0)
//Results
return {list, comments: comments.length, details, days, twemoji: q["config.twemoji"]}
return {list, total, comments: comments.length, details, days, twemoji: q["config.twemoji"]}
}
//Handle errors
catch (error) {