chore: code formatting
This commit is contained in:
@@ -455,7 +455,7 @@ function quit(reason) {
|
||||
info("Previous hash", previous)
|
||||
const current = await svg.hash(rendered)
|
||||
info("Current hash", current)
|
||||
const changed = (previous !== current)
|
||||
const changed = previous !== current
|
||||
info("Content changed", changed)
|
||||
if (!changed)
|
||||
committer.commit = false
|
||||
@@ -632,7 +632,8 @@ function quit(reason) {
|
||||
info(`Branch ${committer.head}`, "(deleted)")
|
||||
}, {retries: retries_output_action, delay: retries_delay_output_action})
|
||||
break
|
||||
} while (--attempts)
|
||||
}
|
||||
while (--attempts)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -524,7 +524,7 @@ export const svg = {
|
||||
const padding = {width: 1, height: 1, absolute: {width: 0, height: 0}}
|
||||
paddings = Array.isArray(paddings) ? paddings : `${paddings}`.split(",").map(x => x.trim())
|
||||
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 ?? {}
|
||||
operands = operands.replace(relative, "").trim()
|
||||
let {absolute} = operands.match(/^(?<absolute>[+-]?[\d.]+)/)?.groups ?? {}
|
||||
|
||||
@@ -138,7 +138,8 @@
|
||||
console.warn(`${plugin}: no data yet, retrying in ${interval} seconds`)
|
||||
await new Promise(solve => setTimeout(solve, interval * 1000))
|
||||
}
|
||||
} while (--attempts)
|
||||
}
|
||||
while (--attempts)
|
||||
completed++
|
||||
this.progress = completed / (data.plugins.length + 1)
|
||||
this.loaded.push(plugin)
|
||||
|
||||
@@ -74,7 +74,8 @@ export default async function({login, data, queries, imports, q, account}, {enab
|
||||
if (await retry({login, imports, error}))
|
||||
continue
|
||||
}
|
||||
} while (next)
|
||||
}
|
||||
while (next)
|
||||
//Format and save results
|
||||
result.lists[type].favorites = shuffle ? imports.shuffle(list) : list
|
||||
//Limit results
|
||||
@@ -107,7 +108,8 @@ export default async function({login, data, queries, imports, q, account}, {enab
|
||||
if (await retry({login, imports, error}))
|
||||
continue
|
||||
}
|
||||
} while (next)
|
||||
}
|
||||
while (next)
|
||||
//Format and save results
|
||||
result.characters = shuffle ? imports.shuffle(characters) : characters
|
||||
//Limit results
|
||||
|
||||
@@ -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`)
|
||||
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
|
||||
console.debug(`metrics/compute/${login}/base > keeping only ${repositories} ${type}`)
|
||||
data.user[type].nodes.splice(repositories)
|
||||
|
||||
@@ -28,7 +28,8 @@ export default async function({login, q, imports, graphql, queries, data, accoun
|
||||
fetched.push(...nodes)
|
||||
pushed = nodes.length
|
||||
console.debug(`metrics/compute/${login}/discussions > retrieved ${pushed} discussions after ${cursor}`)
|
||||
} while ((pushed) && (cursor))
|
||||
}
|
||||
while ((pushed) && (cursor))
|
||||
|
||||
//Compute upvotes
|
||||
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)
|
||||
pushed = nodes.length
|
||||
console.debug(`metrics/compute/${login}/discussions > retrieved ${pushed} comments after ${cursor}`)
|
||||
} while ((pushed) && (cursor))
|
||||
}
|
||||
while ((pushed) && (cursor))
|
||||
|
||||
//Compute upvotes
|
||||
fetched.map(({upvoteCount}) => discussions.upvotes.comments += upvoteCount)
|
||||
|
||||
@@ -22,7 +22,8 @@ export default async function({login, data, graphql, q, imports, queries, accoun
|
||||
gists.push(...nodes)
|
||||
gists.totalCount = totalCount
|
||||
pushed = nodes.length
|
||||
} while ((pushed) && (cursor))
|
||||
}
|
||||
while ((pushed) && (cursor))
|
||||
console.debug(`metrics/compute/${login}/plugins > gists > loaded ${gists.length} gists`)
|
||||
}
|
||||
|
||||
|
||||
@@ -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}))
|
||||
.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
|
||||
} while ((pushed) && (cursor))
|
||||
}
|
||||
while ((pushed) && (cursor))
|
||||
}
|
||||
|
||||
//Set contributions
|
||||
@@ -47,7 +48,8 @@ export default async function({login, q, imports, rest, graphql, data, account,
|
||||
cursor = edges?.[edges?.length - 1]?.cursor
|
||||
edges.map(({node: {repository: {nameWithOwner: repository}}}) => issues[repository] = (issues[repositories] ?? 0) + 1)
|
||||
pushed = edges.length
|
||||
} while ((pushed) && (cursor))
|
||||
}
|
||||
while ((pushed) && (cursor))
|
||||
}
|
||||
|
||||
//Fetch pull requests
|
||||
@@ -61,7 +63,8 @@ export default async function({login, q, imports, rest, graphql, data, account,
|
||||
cursor = edges?.[edges?.length - 1]?.cursor
|
||||
edges.map(({node: {repository: {nameWithOwner: repository}}}) => pulls[repository] = (pulls[repositories] ?? 0) + 1)
|
||||
pushed = edges.length
|
||||
} while ((pushed) && (cursor))
|
||||
}
|
||||
while ((pushed) && (cursor))
|
||||
}
|
||||
|
||||
//Fetch commits
|
||||
|
||||
@@ -52,17 +52,16 @@ export default async function({login, data, graphql, rest, q, queries, imports,
|
||||
let pushed = 0
|
||||
do {
|
||||
console.debug(`metrics/compute/${login}/plugins > people > retrieving ${type} after ${cursor}`)
|
||||
const {[type]: {edges}} = (
|
||||
type in context.sponsorships
|
||||
const {[type]: {edges}} = 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]
|
||||
: 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({login, type, size, after: cursor ? `after: "${cursor}"` : "", account})))[account]
|
||||
)
|
||||
cursor = edges?.[edges?.length - 1]?.cursor
|
||||
result[type].push(...edges.map(({node}) => node[context.sponsorships[type]] ?? node))
|
||||
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
|
||||
if (shuffle) {
|
||||
|
||||
@@ -33,7 +33,8 @@ export default async function({login, q, imports, data, graphql, queries, accoun
|
||||
fetched.splice(limit)
|
||||
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)
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@@ -31,7 +31,8 @@ export default async function({login, q, imports, data, graphql, queries, accoun
|
||||
fetched.push(...nodes)
|
||||
pushed = nodes.length
|
||||
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"})))
|
||||
await Promise.all(list.map(async user => user.avatar = await imports.imgb64(user.avatarUrl)))
|
||||
count.active.total = list.length
|
||||
@@ -55,7 +56,8 @@ export default async function({login, q, imports, data, graphql, queries, accoun
|
||||
fetched.push(...nodes)
|
||||
pushed = nodes.length
|
||||
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})))
|
||||
}
|
||||
for (const user of users) {
|
||||
|
||||
@@ -35,7 +35,8 @@ export default async function({login, q, imports, data, graphql, queries, accoun
|
||||
fetched.push(...nodes)
|
||||
pushed = nodes.length
|
||||
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})))
|
||||
}
|
||||
await Promise.all(list.map(async user => user.avatar = await imports.imgb64(user.avatarUrl)))
|
||||
|
||||
@@ -27,7 +27,8 @@ export default async function({login, graphql, data, imports, q, queries, accoun
|
||||
if (_worldmap)
|
||||
locations.push(...edges.map(({node: {location}}) => location))
|
||||
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 in total`)
|
||||
|
||||
@@ -21,14 +21,14 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
||||
//Fetch star lists
|
||||
console.debug(`metrics/compute/${login}/plugins > starlists > fetching lists`)
|
||||
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 => ({
|
||||
link: element.href,
|
||||
name: element.querySelector("h3")?.innerText ?? "",
|
||||
description: element.querySelector("span")?.innerText ?? "",
|
||||
count: Number(element.querySelector("div")?.innerText.match(/(?<count>\d+)/)?.groups.count),
|
||||
repositories: [],
|
||||
})), login))
|
||||
})), login)
|
||||
const count = lists.length
|
||||
console.debug(`metrics/compute/${login}/plugins > starlists > found [${lists.map(({name}) => name)}]`)
|
||||
lists = lists
|
||||
|
||||
@@ -9,7 +9,7 @@ export default async function({login, data, imports, q, account}, {enabled = fal
|
||||
//Load inputs
|
||||
let {sort, mode, limit} = imports.metadata.plugins.topics.inputs({data, account, q})
|
||||
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
|
||||
console.debug(`metrics/compute/${login}/plugins > topics > searching starred topics`)
|
||||
|
||||
Reference in New Issue
Block a user