fix(metrics/insights): output always erroring (close #1096)
This commit is contained in:
@@ -271,7 +271,8 @@ metrics.insights.output = async function({login, imports, conf}, {graphql, rest,
|
|||||||
const browser = await imports.puppeteer.launch()
|
const browser = await imports.puppeteer.launch()
|
||||||
const page = await browser.newPage()
|
const page = await browser.newPage()
|
||||||
console.debug(`metrics/compute/${login} > insights > generating data`)
|
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.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.evaluate(async json => localStorage.setItem("local.metrics", json), json) //eslint-disable-line no-undef
|
||||||
await page.goto(`${server}/about/${login}?embed=1&localstorage=1`)
|
await page.goto(`${server}/about/${login}?embed=1&localstorage=1`)
|
||||||
@@ -292,5 +293,5 @@ metrics.insights.output = async function({login, imports, conf}, {graphql, rest,
|
|||||||
</body>
|
</body>
|
||||||
</html>`
|
</html>`
|
||||||
await browser.close()
|
await browser.close()
|
||||||
return {mime: "text/html", rendered, errors: json.errors}
|
return {mime: "text/html", rendered, errors: result.errors}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
this.pending = true
|
this.pending = true
|
||||||
if (this.localstorage) {
|
if (this.localstorage) {
|
||||||
this.metrics = JSON.parse(localStorage.getItem("local.metrics") ?? "null")
|
this.metrics = JSON.parse(localStorage.getItem("local.metrics") ?? "null")
|
||||||
|
this.loaded = ["base", ...Object.keys(this.metrics?.rendered?.plugins ?? {})]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const {processing, ...data} = (await axios.get(`/about/query/${this.user}`)).data
|
const {processing, ...data} = (await axios.get(`/about/query/${this.user}`)).data
|
||||||
|
|||||||
Reference in New Issue
Block a user