diff --git a/source/app/action/index.mjs b/source/app/action/index.mjs index 10df0b73..3b42c638 100644 --- a/source/app/action/index.mjs +++ b/source/app/action/index.mjs @@ -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) } } diff --git a/source/app/metrics/utils.mjs b/source/app/metrics/utils.mjs index 74aa0441..3e111bfa 100644 --- a/source/app/metrics/utils.mjs +++ b/source/app/metrics/utils.mjs @@ -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(/(?[+-]?[\d.]+)%$/)?.groups ?? {} operands = operands.replace(relative, "").trim() let {absolute} = operands.match(/^(?[+-]?[\d.]+)/)?.groups ?? {} diff --git a/source/app/web/statics/insights/script.js b/source/app/web/statics/insights/script.js index b909352a..c389166d 100644 --- a/source/app/web/statics/insights/script.js +++ b/source/app/web/statics/insights/script.js @@ -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) diff --git a/source/plugins/anilist/index.mjs b/source/plugins/anilist/index.mjs index 5211493b..2b77d71e 100644 --- a/source/plugins/anilist/index.mjs +++ b/source/plugins/anilist/index.mjs @@ -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 diff --git a/source/plugins/base/index.mjs b/source/plugins/base/index.mjs index 83b1a9fe..fcd6c6ac 100644 --- a/source/plugins/base/index.mjs +++ b/source/plugins/base/index.mjs @@ -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) diff --git a/source/plugins/community/nightscout/index.mjs b/source/plugins/community/nightscout/index.mjs index d04b7cfa..abc283b0 100644 --- a/source/plugins/community/nightscout/index.mjs +++ b/source/plugins/community/nightscout/index.mjs @@ -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].timeUTCHumanReadable = `${addZero(date.getUTCHours())}:${addZero(date.getUTCMinutes())}` /* - * 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 - */ + * 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 + */ let color = "#40c463" let alertName = "Normal" if (sgv >= urgenthighalert || sgv <= urgentlowalert) { diff --git a/source/plugins/discussions/index.mjs b/source/plugins/discussions/index.mjs index 7cc7d14f..24fec1ff 100644 --- a/source/plugins/discussions/index.mjs +++ b/source/plugins/discussions/index.mjs @@ -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) diff --git a/source/plugins/gists/index.mjs b/source/plugins/gists/index.mjs index 63166757..fb6109fb 100644 --- a/source/plugins/gists/index.mjs +++ b/source/plugins/gists/index.mjs @@ -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`) } diff --git a/source/plugins/notable/index.mjs b/source/plugins/notable/index.mjs index 57fce2f7..c9adc3b7 100644 --- a/source/plugins/notable/index.mjs +++ b/source/plugins/notable/index.mjs @@ -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 diff --git a/source/plugins/people/index.mjs b/source/plugins/people/index.mjs index 6385772d..79920f9c 100644 --- a/source/plugins/people/index.mjs +++ b/source/plugins/people/index.mjs @@ -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 - ? (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] - ) + 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) { diff --git a/source/plugins/reactions/index.mjs b/source/plugins/reactions/index.mjs index 4c6d40d8..0995f277 100644 --- a/source/plugins/reactions/index.mjs +++ b/source/plugins/reactions/index.mjs @@ -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) { diff --git a/source/plugins/sponsors/index.mjs b/source/plugins/sponsors/index.mjs index b92a50b4..f9f75897 100644 --- a/source/plugins/sponsors/index.mjs +++ b/source/plugins/sponsors/index.mjs @@ -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) { diff --git a/source/plugins/sponsorships/index.mjs b/source/plugins/sponsorships/index.mjs index 26651aba..d12826b0 100644 --- a/source/plugins/sponsorships/index.mjs +++ b/source/plugins/sponsorships/index.mjs @@ -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))) diff --git a/source/plugins/stargazers/index.mjs b/source/plugins/stargazers/index.mjs index 5e035c3a..2316e4fd 100644 --- a/source/plugins/stargazers/index.mjs +++ b/source/plugins/stargazers/index.mjs @@ -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`) diff --git a/source/plugins/starlists/index.mjs b/source/plugins/starlists/index.mjs index 54056b1b..2ae74a21 100644 --- a/source/plugins/starlists/index.mjs +++ b/source/plugins/starlists/index.mjs @@ -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(/(?\d+)/)?.groups.count), repositories: [], - })), login)) + })), login) const count = lists.length console.debug(`metrics/compute/${login}/plugins > starlists > found [${lists.map(({name}) => name)}]`) lists = lists diff --git a/source/plugins/topics/index.mjs b/source/plugins/topics/index.mjs index 18661a9e..e6408354 100644 --- a/source/plugins/topics/index.mjs +++ b/source/plugins/topics/index.mjs @@ -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`)