chore: code formatting

This commit is contained in:
github-actions[bot]
2023-03-16 01:21:21 +00:00
parent b4908d81a3
commit ff1008392f
4 changed files with 50 additions and 50 deletions

View File

@@ -31,7 +31,7 @@ export default async function({login, q, imports, data, account}, {enabled = fal
//Generating chart
console.debug(`metrics/compute/${login}/plugins > stock > generating chart`)
const chart = imports.Graph.timeline(close.map((y, i) => ({x:new Date(timestamp[i]*1000), y})), {low:Math.min(...close), high:Math.max(...close), points:false, text:false, width: 480 * (1 + data.large), height:200})
const chart = imports.Graph.timeline(close.map((y, i) => ({x: new Date(timestamp[i] * 1000), y})), {low: Math.min(...close), high: Math.max(...close), points: false, text: false, width: 480 * (1 + data.large), height: 200})
//Results
return {chart, currency, price, previous, delta: price - previous, symbol, company, interval, duration}

View File

@@ -120,14 +120,14 @@ export default async function({login, data, rest, imports, q, account}, {enabled
if ((["graph", "chartist"].includes(_charts)) && (imports.metadata.plugins.habits.extras("charts.type", {extras}))) {
console.debug(`metrics/compute/${login}/plugins > habits > generating charts`)
habits.charts = await Promise.all([
{type: "line", data: {...empty(24), ...Object.fromEntries(Object.entries(habits.commits.hours).filter(([k]) => !Number.isNaN(+k)))}, ticks:24, low: 0, high: habits.commits.hours.max},
{type: "line", data: {...empty(7), ...Object.fromEntries(Object.entries(habits.commits.days).filter(([k]) => !Number.isNaN(+k)))}, ticks:7, low: 0, high: habits.commits.days.max, labels:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], half: true},
{type: "pie", data: Object.fromEntries(Object.entries(habits.linguist.languages).map(([k, v]) => [k, (100*v).toFixed(2)])), colors:habits.linguist.colors, half: true},
{type: "line", data: {...empty(24), ...Object.fromEntries(Object.entries(habits.commits.hours).filter(([k]) => !Number.isNaN(+k)))}, ticks: 24, low: 0, high: habits.commits.hours.max},
{type: "line", data: {...empty(7), ...Object.fromEntries(Object.entries(habits.commits.days).filter(([k]) => !Number.isNaN(+k)))}, ticks: 7, low: 0, high: habits.commits.days.max, labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], half: true},
{type: "pie", data: Object.fromEntries(Object.entries(habits.linguist.languages).map(([k, v]) => [k, (100 * v).toFixed(2)])), colors: habits.linguist.colors, half: true},
].map(({type, data, high, low, ticks, colors = null, labels = null, half = false}) => {
const width = 480 * (half ? 0.45 : 1)
const height = 160
if (type === "line")
return imports.Graph.line(Object.entries(data).map(([x, y]) => ({x:+x, y})), {low, high, ticks, labels, width, height})
return imports.Graph.line(Object.entries(data).map(([x, y]) => ({x: +x, y})), {low, high, ticks, labels, width, height})
console.log(data)
if (type === "pie")
return imports.Graph.pie(data, {colors, width, height})

View File

@@ -9,7 +9,7 @@ export default async function({login, graphql, data, imports, q, queries, accoun
//Load inputs
let {days, charts: _charts, "charts.type": _charts_type, worldmap: _worldmap, "worldmap.sample": _worldmap_sample} = imports.metadata.plugins.stargazers.inputs({data, account, q})
if (!days) {
days = Math.abs(parseInt((new Date() - new Date(data.user.createdAt))/1000/60/60/24))
days = Math.abs(parseInt((new Date() - new Date(data.user.createdAt)) / 1000 / 60 / 60 / 24))
console.debug(`metrics/compute/${login}/plugins > stargazers > set days to ${days}`)
}
@@ -65,13 +65,13 @@ export default async function({login, graphql, data, imports, q, queries, accoun
//Generating charts
let charts = _charts ? true : null
if ((["graph", "chartist"].includes(_charts_type)) && (imports.metadata.plugins.stargazers.extras("charts.type", {extras}))) {
if ((["graph", "chartist"].includes(_charts_type)) && (imports.metadata.plugins.stargazers.extras("charts.type", {extras}))) {
console.debug(`metrics/compute/${login}/plugins > stargazers > generating charts`)
charts = await Promise.all([{data: total, low: total.min, high: total.max}, {data: increments, low: 0, high: increments.max, sign: true}].map(({data: {dates: set}, low, high, sign = false}) =>
imports.Graph.timeline(Object.entries(set).map(([x, y]) => ({x:new Date(x), y, text:imports.format(y, {sign})})), {low, high,
match:(data, ticks) => data.filter(([x]) => ticks.map(t => t.toISOString().slice(0, 10)).includes(x.toISOString().slice(0, 10))),
})
))
charts = await Promise.all(
[{data: total, low: total.min, high: total.max}, {data: increments, low: 0, high: increments.max, sign: true}].map(({data: {dates: set}, low, high, sign = false}) =>
imports.Graph.timeline(Object.entries(set).map(([x, y]) => ({x: new Date(x), y, text: imports.format(y, {sign})})), {low, high, match: (data, ticks) => data.filter(([x]) => ticks.map(t => t.toISOString().slice(0, 10)).includes(x.toISOString().slice(0, 10)))})
),
)
}
//Generating worldmap