chore: code formatting

This commit is contained in:
github-actions[bot]
2023-03-13 04:39:48 +00:00
parent 522b7e74b1
commit 78709320de
16 changed files with 47 additions and 32 deletions

View File

@@ -455,7 +455,7 @@ function quit(reason) {
info("Previous hash", previous) info("Previous hash", previous)
const current = await svg.hash(rendered) const current = await svg.hash(rendered)
info("Current hash", current) info("Current hash", current)
const changed = (previous !== current) const changed = previous !== current
info("Content changed", changed) info("Content changed", changed)
if (!changed) if (!changed)
committer.commit = false committer.commit = false
@@ -632,7 +632,8 @@ function quit(reason) {
info(`Branch ${committer.head}`, "(deleted)") info(`Branch ${committer.head}`, "(deleted)")
}, {retries: retries_output_action, delay: retries_delay_output_action}) }, {retries: retries_output_action, delay: retries_delay_output_action})
break break
} while (--attempts) }
while (--attempts)
} }
} }

View File

@@ -524,7 +524,7 @@ export const svg = {
const padding = {width: 1, height: 1, absolute: {width: 0, height: 0}} const padding = {width: 1, height: 1, absolute: {width: 0, height: 0}}
paddings = Array.isArray(paddings) ? paddings : `${paddings}`.split(",").map(x => x.trim()) paddings = Array.isArray(paddings) ? paddings : `${paddings}`.split(",").map(x => x.trim())
for (const [i, dimension] of [[0, "width"], [1, "height"]]) { for (const [i, dimension] of [[0, "width"], [1, "height"]]) {
let operands = (paddings?.[i] ?? paddings[0]) let operands = paddings?.[i] ?? paddings[0]
let {relative} = operands.match(/(?<relative>[+-]?[\d.]+)%$/)?.groups ?? {} let {relative} = operands.match(/(?<relative>[+-]?[\d.]+)%$/)?.groups ?? {}
operands = operands.replace(relative, "").trim() operands = operands.replace(relative, "").trim()
let {absolute} = operands.match(/^(?<absolute>[+-]?[\d.]+)/)?.groups ?? {} let {absolute} = operands.match(/^(?<absolute>[+-]?[\d.]+)/)?.groups ?? {}

View File

@@ -138,7 +138,8 @@
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)

View File

@@ -74,7 +74,8 @@ export default async function({login, data, queries, imports, q, account}, {enab
if (await retry({login, imports, error})) if (await retry({login, imports, error}))
continue continue
} }
} while (next) }
while (next)
//Format and save results //Format and save results
result.lists[type].favorites = shuffle ? imports.shuffle(list) : list result.lists[type].favorites = shuffle ? imports.shuffle(list) : list
//Limit results //Limit results
@@ -107,7 +108,8 @@ export default async function({login, data, queries, imports, q, account}, {enab
if (await retry({login, imports, error})) if (await retry({login, imports, error}))
continue continue
} }
} while (next) }
while (next)
//Format and save results //Format and save results
result.characters = shuffle ? imports.shuffle(characters) : characters result.characters = shuffle ? imports.shuffle(characters) : characters
//Limit results //Limit results

View File

@@ -173,7 +173,8 @@ export default async function({login, graphql, rest, data, q, queries, imports,
console.debug(`metrics/compute/${login}/base > retrieved less repositories than expected, probably no more to fetch`) console.debug(`metrics/compute/${login}/base > retrieved less repositories than expected, probably no more to fetch`)
break break
} }
} while ((pushed) && (cursor) && ((data.user.repositories?.nodes?.length ?? 0) + (data.user.repositoriesContributedTo?.nodes?.length ?? 0) < repositories)) }
while ((pushed) && (cursor) && ((data.user.repositories?.nodes?.length ?? 0) + (data.user.repositoriesContributedTo?.nodes?.length ?? 0) < repositories))
//Limit repositories //Limit repositories
console.debug(`metrics/compute/${login}/base > keeping only ${repositories} ${type}`) console.debug(`metrics/compute/${login}/base > keeping only ${repositories} ${type}`)
data.user[type].nodes.splice(repositories) data.user[type].nodes.splice(repositories)

View File

@@ -28,9 +28,9 @@ export default async function({q, imports, data, account}, {enabled = false, ext
resp.data[i].arrowHumanReadable = directionArrow(resp.data[i].direction) resp.data[i].arrowHumanReadable = directionArrow(resp.data[i].direction)
resp.data[i].timeUTCHumanReadable = `${addZero(date.getUTCHours())}:${addZero(date.getUTCMinutes())}` resp.data[i].timeUTCHumanReadable = `${addZero(date.getUTCHours())}:${addZero(date.getUTCMinutes())}`
/* /*
* Add colors and alert names * Add colors and alert names
* TODO: Maybe make colors better themed instead of just the "github style" - red and yellow could fit better than darker shades of green * TODO: Maybe make colors better themed instead of just the "github style" - red and yellow could fit better than darker shades of green
*/ */
let color = "#40c463" let color = "#40c463"
let alertName = "Normal" let alertName = "Normal"
if (sgv >= urgenthighalert || sgv <= urgentlowalert) { if (sgv >= urgenthighalert || sgv <= urgentlowalert) {

View File

@@ -28,7 +28,8 @@ export default async function({login, q, imports, graphql, queries, data, accoun
fetched.push(...nodes) fetched.push(...nodes)
pushed = nodes.length pushed = nodes.length
console.debug(`metrics/compute/${login}/discussions > retrieved ${pushed} discussions after ${cursor}`) console.debug(`metrics/compute/${login}/discussions > retrieved ${pushed} discussions after ${cursor}`)
} while ((pushed) && (cursor)) }
while ((pushed) && (cursor))
//Compute upvotes //Compute upvotes
fetched.map(({upvoteCount}) => discussions.upvotes.discussions += upvoteCount) fetched.map(({upvoteCount}) => discussions.upvotes.discussions += upvoteCount)
@@ -53,7 +54,8 @@ export default async function({login, q, imports, graphql, queries, data, accoun
fetched.push(...nodes) fetched.push(...nodes)
pushed = nodes.length pushed = nodes.length
console.debug(`metrics/compute/${login}/discussions > retrieved ${pushed} comments after ${cursor}`) console.debug(`metrics/compute/${login}/discussions > retrieved ${pushed} comments after ${cursor}`)
} while ((pushed) && (cursor)) }
while ((pushed) && (cursor))
//Compute upvotes //Compute upvotes
fetched.map(({upvoteCount}) => discussions.upvotes.comments += upvoteCount) fetched.map(({upvoteCount}) => discussions.upvotes.comments += upvoteCount)

View File

@@ -22,7 +22,8 @@ export default async function({login, data, graphql, q, imports, queries, accoun
gists.push(...nodes) gists.push(...nodes)
gists.totalCount = totalCount gists.totalCount = totalCount
pushed = nodes.length pushed = nodes.length
} while ((pushed) && (cursor)) }
while ((pushed) && (cursor))
console.debug(`metrics/compute/${login}/plugins > gists > loaded ${gists.length} gists`) console.debug(`metrics/compute/${login}/plugins > gists > loaded ${gists.length} gists`)
} }

View File

@@ -25,7 +25,8 @@ export default async function({login, q, imports, rest, graphql, data, account,
.filter(({node}) => imports.filters.github(filter, {name: node.nameWithOwner, user: node.owner.login, stars: node.stargazers.totalCount, watchers: node.watchers.totalCount, forks: node.forks.totalCount})) .filter(({node}) => imports.filters.github(filter, {name: node.nameWithOwner, user: node.owner.login, stars: node.stargazers.totalCount, watchers: node.watchers.totalCount, forks: node.forks.totalCount}))
.map(({node}) => contributions.push({handle: node.nameWithOwner, stars: node.stargazers.totalCount, issues: node.issues.totalCount, pulls: node.pullRequests.totalCount, organization: node.isInOrganization, avatarUrl: node.owner.avatarUrl})) .map(({node}) => contributions.push({handle: node.nameWithOwner, stars: node.stargazers.totalCount, issues: node.issues.totalCount, pulls: node.pullRequests.totalCount, organization: node.isInOrganization, avatarUrl: node.owner.avatarUrl}))
pushed = edges.length pushed = edges.length
} while ((pushed) && (cursor)) }
while ((pushed) && (cursor))
} }
//Set contributions //Set contributions
@@ -47,7 +48,8 @@ export default async function({login, q, imports, rest, graphql, data, account,
cursor = edges?.[edges?.length - 1]?.cursor cursor = edges?.[edges?.length - 1]?.cursor
edges.map(({node: {repository: {nameWithOwner: repository}}}) => issues[repository] = (issues[repositories] ?? 0) + 1) edges.map(({node: {repository: {nameWithOwner: repository}}}) => issues[repository] = (issues[repositories] ?? 0) + 1)
pushed = edges.length pushed = edges.length
} while ((pushed) && (cursor)) }
while ((pushed) && (cursor))
} }
//Fetch pull requests //Fetch pull requests
@@ -61,7 +63,8 @@ export default async function({login, q, imports, rest, graphql, data, account,
cursor = edges?.[edges?.length - 1]?.cursor cursor = edges?.[edges?.length - 1]?.cursor
edges.map(({node: {repository: {nameWithOwner: repository}}}) => pulls[repository] = (pulls[repositories] ?? 0) + 1) edges.map(({node: {repository: {nameWithOwner: repository}}}) => pulls[repository] = (pulls[repositories] ?? 0) + 1)
pushed = edges.length pushed = edges.length
} while ((pushed) && (cursor)) }
while ((pushed) && (cursor))
} }
//Fetch commits //Fetch commits

View File

@@ -52,17 +52,16 @@ export default async function({login, data, graphql, rest, q, queries, imports,
let pushed = 0 let pushed = 0
do { do {
console.debug(`metrics/compute/${login}/plugins > people > retrieving ${type} after ${cursor}`) console.debug(`metrics/compute/${login}/plugins > people > retrieving ${type} after ${cursor}`)
const {[type]: {edges}} = ( const {[type]: {edges}} = type in context.sponsorships
type in context.sponsorships ? (await graphql(queries.people.sponsors({login: context.owner ?? login, type, size, after: cursor ? `after: "${cursor}"` : "", target: context.sponsorships[type], account})))[account]
? (await graphql(queries.people.sponsors({login: context.owner ?? login, type, size, after: cursor ? `after: "${cursor}"` : "", target: context.sponsorships[type], account})))[account] : context.mode === "repository"
: context.mode === "repository" ? (await graphql(queries.people.repository({login: context.owner, repository: context.repo, type, size, after: cursor ? `after: "${cursor}"` : "", account})))[account].repository
? (await graphql(queries.people.repository({login: context.owner, repository: context.repo, type, size, after: cursor ? `after: "${cursor}"` : "", account})))[account].repository : (await graphql(queries.people({login, type, size, after: cursor ? `after: "${cursor}"` : "", account})))[account]
: (await graphql(queries.people({login, type, size, after: cursor ? `after: "${cursor}"` : "", account})))[account]
)
cursor = edges?.[edges?.length - 1]?.cursor cursor = edges?.[edges?.length - 1]?.cursor
result[type].push(...edges.map(({node}) => node[context.sponsorships[type]] ?? node)) result[type].push(...edges.map(({node}) => node[context.sponsorships[type]] ?? node))
pushed = edges.length pushed = edges.length
} while ((pushed) && (cursor) && ((limit === 0) || (result[type].length <= (shuffle ? 10 * limit : limit)))) }
while ((pushed) && (cursor) && ((limit === 0) || (result[type].length <= (shuffle ? 10 * limit : limit))))
} }
//Shuffle //Shuffle
if (shuffle) { if (shuffle) {

View File

@@ -33,7 +33,8 @@ export default async function({login, q, imports, data, graphql, queries, accoun
fetched.splice(limit) fetched.splice(limit)
console.debug(`metrics/compute/${login}/plugins > reactions > keeping only ${fetched.length} ${type} comments`) console.debug(`metrics/compute/${login}/plugins > reactions > keeping only ${fetched.length} ${type} comments`)
} }
} while ((cursor) && (pushed) && (fetched.length < limit)) }
while ((cursor) && (pushed) && (fetched.length < limit))
comments.push(...fetched) comments.push(...fetched)
} }
catch (error) { catch (error) {

View File

@@ -31,7 +31,8 @@ export default async function({login, q, imports, data, graphql, queries, accoun
fetched.push(...nodes) fetched.push(...nodes)
pushed = nodes.length pushed = nodes.length
console.debug(`metrics/compute/${login}/sponsors > retrieved ${pushed} sponsors after ${cursor}`) console.debug(`metrics/compute/${login}/sponsors > retrieved ${pushed} sponsors after ${cursor}`)
} while ((pushed) && (cursor)) }
while ((pushed) && (cursor))
list.push(...fetched.map(({privacyLevel: privacy, sponsorEntity: {login, avatarUrl, url: organization = null}, tier}) => ({login, avatarUrl, type: organization ? "organization" : "user", amount: tier?.monthlyPriceInDollars ?? null, past: false, private: privacy === "PRIVATE"}))) list.push(...fetched.map(({privacyLevel: privacy, sponsorEntity: {login, avatarUrl, url: organization = null}, tier}) => ({login, avatarUrl, type: organization ? "organization" : "user", amount: tier?.monthlyPriceInDollars ?? null, past: false, private: privacy === "PRIVATE"})))
await Promise.all(list.map(async user => user.avatar = await imports.imgb64(user.avatarUrl))) await Promise.all(list.map(async user => user.avatar = await imports.imgb64(user.avatarUrl)))
count.active.total = list.length count.active.total = list.length
@@ -55,7 +56,8 @@ export default async function({login, q, imports, data, graphql, queries, accoun
fetched.push(...nodes) fetched.push(...nodes)
pushed = nodes.length pushed = nodes.length
console.debug(`metrics/compute/${login}/sponsors > retrieved ${pushed} sponsors events after ${cursor}`) console.debug(`metrics/compute/${login}/sponsors > retrieved ${pushed} sponsors events after ${cursor}`)
} while ((pushed) && (cursor)) }
while ((pushed) && (cursor))
users.push(...fetched.map(({sponsor: {login, avatarUrl, url: organization = null}, sponsorsTier}) => ({login, avatarUrl, type: organization ? "organization" : "user", amount: sponsorsTier?.monthlyPriceInDollars ?? null, past: true, private: false}))) users.push(...fetched.map(({sponsor: {login, avatarUrl, url: organization = null}, sponsorsTier}) => ({login, avatarUrl, type: organization ? "organization" : "user", amount: sponsorsTier?.monthlyPriceInDollars ?? null, past: true, private: false})))
} }
for (const user of users) { for (const user of users) {

View File

@@ -35,7 +35,8 @@ export default async function({login, q, imports, data, graphql, queries, accoun
fetched.push(...nodes) fetched.push(...nodes)
pushed = nodes.length pushed = nodes.length
console.debug(`metrics/compute/${login}/sponsorships > retrieved ${pushed} sponsorships events after ${cursor}`) console.debug(`metrics/compute/${login}/sponsorships > retrieved ${pushed} sponsorships events after ${cursor}`)
} while ((pushed) && (cursor)) }
while ((pushed) && (cursor))
list.push(...fetched.map(({sponsorable: {login, avatarUrl, url: organization = null}, tier: {name: tier}, privacyLevel: privacy, isActive: active}) => ({login, avatarUrl, type: organization ? "organization" : "user", tier, private: privacy !== "PUBLIC", past: !active}))) list.push(...fetched.map(({sponsorable: {login, avatarUrl, url: organization = null}, tier: {name: tier}, privacyLevel: privacy, isActive: active}) => ({login, avatarUrl, type: organization ? "organization" : "user", tier, private: privacy !== "PUBLIC", past: !active})))
} }
await Promise.all(list.map(async user => user.avatar = await imports.imgb64(user.avatarUrl))) await Promise.all(list.map(async user => user.avatar = await imports.imgb64(user.avatarUrl)))

View File

@@ -27,7 +27,8 @@ export default async function({login, graphql, data, imports, q, queries, accoun
if (_worldmap) if (_worldmap)
locations.push(...edges.map(({node: {location}}) => location)) locations.push(...edges.map(({node: {location}}) => location))
pushed = edges.length pushed = edges.length
} while ((pushed) && (cursor)) }
while ((pushed) && (cursor))
console.debug(`metrics/compute/${login}/plugins > stargazers > loaded ${dates.length} stargazers for ${repository}`) console.debug(`metrics/compute/${login}/plugins > stargazers > loaded ${dates.length} stargazers for ${repository}`)
} }
console.debug(`metrics/compute/${login}/plugins > stargazers > loaded ${dates.length} stargazers in total`) console.debug(`metrics/compute/${login}/plugins > stargazers > loaded ${dates.length} stargazers in total`)

View File

@@ -21,14 +21,14 @@ export default async function({login, q, imports, data, account}, {enabled = fal
//Fetch star lists //Fetch star lists
console.debug(`metrics/compute/${login}/plugins > starlists > fetching lists`) console.debug(`metrics/compute/${login}/plugins > starlists > fetching lists`)
await page.goto(`https://github.com/${login}?tab=stars`) await page.goto(`https://github.com/${login}?tab=stars`)
let lists = (await page.evaluate(login => let lists = await page.evaluate(login =>
[...document.querySelectorAll(`[href^='/stars/${login}/lists']`)].map(element => ({ [...document.querySelectorAll(`[href^='/stars/${login}/lists']`)].map(element => ({
link: element.href, link: element.href,
name: element.querySelector("h3")?.innerText ?? "", name: element.querySelector("h3")?.innerText ?? "",
description: element.querySelector("span")?.innerText ?? "", description: element.querySelector("span")?.innerText ?? "",
count: Number(element.querySelector("div")?.innerText.match(/(?<count>\d+)/)?.groups.count), count: Number(element.querySelector("div")?.innerText.match(/(?<count>\d+)/)?.groups.count),
repositories: [], repositories: [],
})), login)) })), login)
const count = lists.length const count = lists.length
console.debug(`metrics/compute/${login}/plugins > starlists > found [${lists.map(({name}) => name)}]`) console.debug(`metrics/compute/${login}/plugins > starlists > found [${lists.map(({name}) => name)}]`)
lists = lists lists = lists

View File

@@ -9,7 +9,7 @@ export default async function({login, data, imports, q, account}, {enabled = fal
//Load inputs //Load inputs
let {sort, mode, limit} = imports.metadata.plugins.topics.inputs({data, account, q}) let {sort, mode, limit} = imports.metadata.plugins.topics.inputs({data, account, q})
const type = {starred: "labels", labels: "labels", mastered: "icons", icons: "icons"}[mode] const type = {starred: "labels", labels: "labels", mastered: "icons", icons: "icons"}[mode]
const shuffle = (sort === "random") const shuffle = sort === "random"
//Start puppeteer and navigate to topics //Start puppeteer and navigate to topics
console.debug(`metrics/compute/${login}/plugins > topics > searching starred topics`) console.debug(`metrics/compute/${login}/plugins > topics > searching starred topics`)