chore: code formatting

This commit is contained in:
github-actions[bot]
2022-04-23 23:18:43 +00:00
parent 73cd43c18f
commit 4c98629bbc
130 changed files with 1839 additions and 1788 deletions

View File

@@ -7,23 +7,23 @@ export default async function({login, q, imports, data, graphql, queries, accoun
return null
//Load inputs
let {limit:_limit1, "limit.issues":_limit2, "limit.discussions":_limit3, "limit.discussions.comments":_limit4, days, details, display, ignored} = imports.metadata.plugins.reactions.inputs({data, account, q})
let {limit: _limit1, "limit.issues": _limit2, "limit.discussions": _limit3, "limit.discussions.comments": _limit4, days, details, display, ignored} = imports.metadata.plugins.reactions.inputs({data, account, q})
ignored.push(...data.shared["users.ignored"])
//Load issue comments
const comments = []
for (const {type, limit} of [{type:"issueComments", limit:_limit1}, {type:"issues", limit:_limit2}, {type:"repositoryDiscussionComments", limit:_limit3}, {type:"repositoryDiscussions", limit:_limit4}].filter(({limit}) => limit)) {
for (const {type, limit} of [{type: "issueComments", limit: _limit1}, {type: "issues", limit: _limit2}, {type: "repositoryDiscussionComments", limit: _limit3}, {type: "repositoryDiscussions", limit: _limit4}].filter(({limit}) => limit)) {
let cursor = null, pushed = 0
const fetched = []
try {
do {
//Load issue comments
console.debug(`metrics/compute/${login}/plugins > reactions > retrieving ${type} before ${cursor}`)
const {user:{[type]:{edges}}} = await graphql(queries.reactions({login, type, before:cursor ? `before: "${cursor}"` : ""}))
const {user: {[type]: {edges}}} = await graphql(queries.reactions({login, type, before: cursor ? `before: "${cursor}"` : ""}))
cursor = edges?.[0]?.cursor
//Save issue comments
const filtered = edges
.flatMap(({node:{createdAt:created, reactions:{nodes:reactions}}}) => ({created:new Date(created), reactions:reactions.filter(({user = {}}) => !ignored.includes(user.login)).map(({content}) => content)}))
.flatMap(({node: {createdAt: created, reactions: {nodes: reactions}}}) => ({created: new Date(created), reactions: reactions.filter(({user = {}}) => !ignored.includes(user.login)).map(({content}) => content)}))
.filter(comment => Number.isFinite(days) ? comment.created < new Date(Date.now() - days * 24 * 60 * 60 * 1000) : true)
pushed = filtered.length
fetched.push(...filtered)
@@ -50,13 +50,13 @@ export default async function({login, q, imports, data, graphql, queries, accoun
list[reaction] = (list[reaction] ?? 0) + 1
const max = Math.max(...Object.values(list))
for (const [key, value] of Object.entries(list))
list[key] = {value, percentage:value / reactions.length, score:value / (display === "relative" ? max : reactions.length)}
list[key] = {value, percentage: value / reactions.length, score: value / (display === "relative" ? max : reactions.length)}
//Results
return {list, comments:comments.length, details, days, twemoji:q["config.twemoji"]}
return {list, comments: comments.length, details, days, twemoji: q["config.twemoji"]}
}
//Handle errors
catch (error) {
throw {error:{message:"An error occured", instance:error}}
throw {error: {message: "An error occured", instance: error}}
}
}