chore: code formatting
This commit is contained in:
@@ -212,7 +212,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
|
|||||||
|
|
||||||
//Metrics insights
|
//Metrics insights
|
||||||
metrics.insights = async function({login}, {graphql, rest, conf, callbacks}, {Plugins, Templates}) {
|
metrics.insights = async function({login}, {graphql, rest, conf, callbacks}, {Plugins, Templates}) {
|
||||||
return metrics({login, q:metrics.insights.q}, {graphql, rest, plugins:metrics.insights.plugins, conf, callbacks, convert: "json"}, {Plugins, Templates})
|
return metrics({login, q: metrics.insights.q}, {graphql, rest, plugins: metrics.insights.plugins, conf, callbacks, convert: "json"}, {Plugins, Templates})
|
||||||
}
|
}
|
||||||
metrics.insights.q = {
|
metrics.insights.q = {
|
||||||
template: "classic",
|
template: "classic",
|
||||||
@@ -292,5 +292,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: json.errors}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,9 +193,8 @@ export default async function({sandbox = false} = {}) {
|
|||||||
console.debug(`metrics/app/${login}/insights > 400 (invalid plugin name)`)
|
console.debug(`metrics/app/${login}/insights > 400 (invalid plugin name)`)
|
||||||
return res.status(400).send("Bad request: plugin name seems invalid")
|
return res.status(400).send("Bad request: plugin name seems invalid")
|
||||||
}
|
}
|
||||||
if (cache.get(`about.${login}.${plugin}`)) {
|
if (cache.get(`about.${login}.${plugin}`))
|
||||||
return res.send(cache.get(`about.${login}.${plugin}`))
|
return res.send(cache.get(`about.${login}.${plugin}`))
|
||||||
}
|
|
||||||
return res.status(204).send("No content: no data fetched yet")
|
return res.status(204).send("No content: no data fetched yet")
|
||||||
})
|
})
|
||||||
app.get("/about/query/:login/", ...middlewares, async (req, res) => {
|
app.get("/about/query/:login/", ...middlewares, async (req, res) => {
|
||||||
@@ -209,7 +208,7 @@ export default async function({sandbox = false} = {}) {
|
|||||||
let solve = null
|
let solve = null
|
||||||
try {
|
try {
|
||||||
//Prevent multiples requests
|
//Prevent multiples requests
|
||||||
if ((!debug) && (!mock) && (pending.has(`about.${login}`))) {
|
if ((!debug) && (!mock) && (pending.has(`about.${login}`))) {
|
||||||
console.debug(`metrics/app/${login}/insights > awaiting pending request`)
|
console.debug(`metrics/app/${login}/insights > awaiting pending request`)
|
||||||
await pending.get(`about.${login}`)
|
await pending.get(`about.${login}`)
|
||||||
}
|
}
|
||||||
@@ -227,7 +226,7 @@ export default async function({sandbox = false} = {}) {
|
|||||||
async plugin(login, plugin, success, result) {
|
async plugin(login, plugin, success, result) {
|
||||||
console.debug(`metrics/app/${login}/insights/plugins > ${plugin} > ${success ? "success" : "failure"}`)
|
console.debug(`metrics/app/${login}/insights/plugins > ${plugin} > ${success ? "success" : "failure"}`)
|
||||||
cache.put(`about.${login}.${plugin}`, result)
|
cache.put(`about.${login}.${plugin}`, result)
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
;(async () => {
|
;(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -244,7 +243,7 @@ export default async function({sandbox = false} = {}) {
|
|||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
console.debug(`metrics/app/${login}/insights > accepted request`)
|
console.debug(`metrics/app/${login}/insights > accepted request`)
|
||||||
return res.status(202).json({processing:true, plugins:Object.keys(metrics.insights.plugins)})
|
return res.status(202).json({processing: true, plugins: Object.keys(metrics.insights.plugins)})
|
||||||
}
|
}
|
||||||
//Internal error
|
//Internal error
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@
|
|||||||
const {processing, ...data} = (await axios.get(`/about/query/${this.user}`)).data
|
const {processing, ...data} = (await axios.get(`/about/query/${this.user}`)).data
|
||||||
if (processing) {
|
if (processing) {
|
||||||
let completed = 0
|
let completed = 0
|
||||||
this.progress = 1/(data.plugins.length+1)
|
this.progress = 1 / (data.plugins.length + 1)
|
||||||
this.loaded = []
|
this.loaded = []
|
||||||
const retry = async (plugin, attempts = 60, interval = 10) => {
|
const retry = async (plugin, attempts = 60, interval = 10) => {
|
||||||
if (this.loaded.includes(plugin))
|
if (this.loaded.includes(plugin))
|
||||||
@@ -112,18 +112,18 @@
|
|||||||
if (!data)
|
if (!data)
|
||||||
throw new Error(`${plugin}: no data`)
|
throw new Error(`${plugin}: no data`)
|
||||||
if (plugin === "base")
|
if (plugin === "base")
|
||||||
this.metrics = {rendered:data, mime:"application/json", errors:[]}
|
this.metrics = {rendered: data, mime: "application/json", errors: []}
|
||||||
else
|
else
|
||||||
Object.assign(this.metrics.rendered.plugins, {[plugin]:data})
|
Object.assign(this.metrics.rendered.plugins, {[plugin]: data})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
console.warn(`${plugin}: no data yet, retrying in ${interval} seconds`)
|
console.warn(`${plugin}: no data yet, retrying in ${interval} seconds`)
|
||||||
await new Promise(solve => setTimeout(solve, interval*1000))
|
await new Promise(solve => setTimeout(solve, interval * 1000))
|
||||||
}
|
}
|
||||||
} while (--attempts)
|
} while (--attempts)
|
||||||
completed++
|
completed++
|
||||||
this.progress = completed/(data.plugins.length+1)
|
this.progress = completed / (data.plugins.length + 1)
|
||||||
this.loaded.push(plugin)
|
this.loaded.push(plugin)
|
||||||
}
|
}
|
||||||
await retry("base", 30, 5)
|
await retry("base", 30, 5)
|
||||||
@@ -167,16 +167,19 @@
|
|||||||
return this.metrics?.rendered.plugins?.followup ?? null
|
return this.metrics?.rendered.plugins?.followup ?? null
|
||||||
},
|
},
|
||||||
calendar() {
|
calendar() {
|
||||||
if (this.metrics?.rendered.plugins?.calendar)
|
if (this.metrics?.rendered.plugins?.calendar) {
|
||||||
return Object.assign(this.metrics?.rendered.plugins?.calendar, {color(c) {
|
return Object.assign(this.metrics?.rendered.plugins?.calendar, {
|
||||||
return {
|
color(c) {
|
||||||
"#ebedf0":"var(--color-calendar-graph-day-bg)",
|
return {
|
||||||
"#9be9a8":"var(--color-calendar-graph-day-L1-bg)",
|
"#ebedf0": "var(--color-calendar-graph-day-bg)",
|
||||||
"#40c463":"var(--color-calendar-graph-day-L2-bg)",
|
"#9be9a8": "var(--color-calendar-graph-day-L1-bg)",
|
||||||
"#30a14e":"var(--color-calendar-graph-day-L3-bg)",
|
"#40c463": "var(--color-calendar-graph-day-L2-bg)",
|
||||||
"#216e39":"var(--color-calendar-graph-day-L4-bg)",
|
"#30a14e": "var(--color-calendar-graph-day-L3-bg)",
|
||||||
}[c] ?? c
|
"#216e39": "var(--color-calendar-graph-day-L4-bg)",
|
||||||
}})
|
}[c] ?? c
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
isocalendar() {
|
isocalendar() {
|
||||||
@@ -188,7 +191,7 @@
|
|||||||
.replace(/#216e39/gi, "var(--color-calendar-graph-day-L4-bg)")
|
.replace(/#216e39/gi, "var(--color-calendar-graph-day-L4-bg)")
|
||||||
},
|
},
|
||||||
languages() {
|
languages() {
|
||||||
return Object.assign(this.metrics?.rendered.plugins?.languages?.favorites ?? [], {total:this.metrics?.rendered.plugins?.languages.total})
|
return Object.assign(this.metrics?.rendered.plugins?.languages?.favorites ?? [], {total: this.metrics?.rendered.plugins?.languages.total})
|
||||||
},
|
},
|
||||||
reactions() {
|
reactions() {
|
||||||
return this.metrics?.rendered.plugins?.reactions ?? null
|
return this.metrics?.rendered.plugins?.reactions ?? null
|
||||||
@@ -197,7 +200,7 @@
|
|||||||
return this.metrics?.rendered.plugins?.repositories?.list ?? []
|
return this.metrics?.rendered.plugins?.repositories?.list ?? []
|
||||||
},
|
},
|
||||||
stars() {
|
stars() {
|
||||||
return {repositories:this.metrics?.rendered.plugins?.stars?.repositories.map(({node, starredAt}) => ({...node, starredAt})) ?? []}
|
return {repositories: this.metrics?.rendered.plugins?.stars?.repositories.map(({node, starredAt}) => ({...node, starredAt})) ?? []}
|
||||||
},
|
},
|
||||||
topics() {
|
topics() {
|
||||||
return this.metrics?.rendered.plugins?.topics?.list ?? []
|
return this.metrics?.rendered.plugins?.topics?.list ?? []
|
||||||
@@ -240,7 +243,7 @@
|
|||||||
error: null,
|
error: null,
|
||||||
config: {},
|
config: {},
|
||||||
progress: 0,
|
progress: 0,
|
||||||
loaded: []
|
loaded: [],
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})()
|
})()
|
||||||
|
|||||||
Reference in New Issue
Block a user