From 20fddf932474852610a04bebe074ceeac2e1cc86 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Fri, 24 Jun 2022 22:15:25 -0400 Subject: [PATCH] fix(metrics/insights): output always erroring (close #1096) --- source/app/metrics/index.mjs | 5 +++-- source/app/web/statics/about/script.js | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/app/metrics/index.mjs b/source/app/metrics/index.mjs index 6aee5296..3d99181e 100644 --- a/source/app/metrics/index.mjs +++ b/source/app/metrics/index.mjs @@ -271,7 +271,8 @@ metrics.insights.output = async function({login, imports, conf}, {graphql, rest, const browser = await imports.puppeteer.launch() const page = await browser.newPage() console.debug(`metrics/compute/${login} > insights > generating data`) - const json = JSON.stringify(await metrics.insights({login}, {graphql, rest, conf}, {Plugins, Templates})) + const result = await metrics.insights({login}, {graphql, rest, conf}, {Plugins, Templates}) + const json = JSON.stringify(result) await page.goto(`${server}/about/${login}?embed=1&localstorage=1`) await page.evaluate(async json => localStorage.setItem("local.metrics", json), json) //eslint-disable-line no-undef await page.goto(`${server}/about/${login}?embed=1&localstorage=1`) @@ -292,5 +293,5 @@ metrics.insights.output = async function({login, imports, conf}, {graphql, rest, ` await browser.close() - return {mime: "text/html", rendered, errors: json.errors} + return {mime: "text/html", rendered, errors: result.errors} } diff --git a/source/app/web/statics/about/script.js b/source/app/web/statics/about/script.js index fae6d8f6..1c80a7a6 100644 --- a/source/app/web/statics/about/script.js +++ b/source/app/web/statics/about/script.js @@ -96,6 +96,7 @@ this.pending = true if (this.localstorage) { this.metrics = JSON.parse(localStorage.getItem("local.metrics") ?? "null") + this.loaded = ["base", ...Object.keys(this.metrics?.rendered?.plugins ?? {})] return } const {processing, ...data} = (await axios.get(`/about/query/${this.user}`)).data