chore: code formatting
This commit is contained in:
@@ -11,10 +11,10 @@ export default async function({login, q, imports, data, graphql, queries, accoun
|
||||
|
||||
//Query description and goal
|
||||
console.debug(`metrics/compute/${login}/plugins > sponsors > querying sponsors and goal`)
|
||||
const {[account]:{sponsorsListing:{fullDescription, activeGoal}}} = await graphql(queries.sponsors.description({login, account}))
|
||||
const about = await imports.markdown(fullDescription, {mode:"multiline"})
|
||||
const goal = activeGoal ? {progress:activeGoal.percentComplete, title:activeGoal.title, description:await imports.markdown(activeGoal.description)} : null
|
||||
const count = {total:{count:0, user:0, organization:0}, active:{total:0, user:0, organization:0}, past:{total:0, user:0, organization:0}}
|
||||
const {[account]: {sponsorsListing: {fullDescription, activeGoal}}} = await graphql(queries.sponsors.description({login, account}))
|
||||
const about = await imports.markdown(fullDescription, {mode: "multiline"})
|
||||
const goal = activeGoal ? {progress: activeGoal.percentComplete, title: activeGoal.title, description: await imports.markdown(activeGoal.description)} : null
|
||||
const count = {total: {count: 0, user: 0, organization: 0}, active: {total: 0, user: 0, organization: 0}, past: {total: 0, user: 0, organization: 0}}
|
||||
|
||||
//Query active sponsors
|
||||
let list = []
|
||||
@@ -24,13 +24,13 @@ export default async function({login, q, imports, data, graphql, queries, accoun
|
||||
let pushed = 0
|
||||
do {
|
||||
console.debug(`metrics/compute/${login}/sponsors > retrieving sponsors after ${cursor}`)
|
||||
const {[account]:{sponsorshipsAsMaintainer:{edges, nodes}}} = await graphql(queries.sponsors.active({login, account, after:cursor ? `after: "${cursor}"` : "", size:Math.round(size*1.5)}))
|
||||
const {[account]: {sponsorshipsAsMaintainer: {edges, nodes}}} = await graphql(queries.sponsors.active({login, account, after: cursor ? `after: "${cursor}"` : "", size: Math.round(size * 1.5)}))
|
||||
cursor = edges?.[edges?.length - 1]?.cursor
|
||||
fetched.push(...nodes)
|
||||
pushed = nodes.length
|
||||
console.debug(`metrics/compute/${login}/sponsors > retrieved ${pushed} sponsors after ${cursor}`)
|
||||
} while ((pushed) && (cursor))
|
||||
list.push(...fetched.map(({sponsorEntity:{login, avatarUrl, url:organization = null}, tier}) => ({login, avatarUrl, type:organization ? "organization" : "user", amount:tier?.monthlyPriceInDollars ?? null, past:false})))
|
||||
list.push(...fetched.map(({sponsorEntity: {login, avatarUrl, url: organization = null}, tier}) => ({login, avatarUrl, type: organization ? "organization" : "user", amount: tier?.monthlyPriceInDollars ?? null, past: false})))
|
||||
await Promise.all(list.map(async user => user.avatar = await imports.imgb64(user.avatarUrl)))
|
||||
count.active.total = list.length
|
||||
count.active.user = list.filter(user => user.type === "user").length
|
||||
@@ -48,18 +48,18 @@ export default async function({login, q, imports, data, graphql, queries, accoun
|
||||
let pushed = 0
|
||||
do {
|
||||
console.debug(`metrics/compute/${login}/sponsors > retrieving sponsors events after ${cursor}`)
|
||||
const {[account]:{sponsorsActivities:{edges, nodes}}} = await graphql(queries.sponsors.all({login, account, after:cursor ? `after: "${cursor}"` : "", size:Math.round(size*1.5)}))
|
||||
const {[account]: {sponsorsActivities: {edges, nodes}}} = await graphql(queries.sponsors.all({login, account, after: cursor ? `after: "${cursor}"` : "", size: Math.round(size * 1.5)}))
|
||||
cursor = edges?.[edges?.length - 1]?.cursor
|
||||
fetched.push(...nodes)
|
||||
pushed = nodes.length
|
||||
console.debug(`metrics/compute/${login}/sponsors > retrieved ${pushed} sponsors events after ${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})))
|
||||
users.push(...fetched.map(({sponsor: {login, avatarUrl, url: organization = null}, sponsorsTier}) => ({login, avatarUrl, type: organization ? "organization" : "user", amount: sponsorsTier?.monthlyPriceInDollars ?? null, past: true})))
|
||||
}
|
||||
for (const user of users) {
|
||||
if (!active.has(user.login)) {
|
||||
active.add(user.login)
|
||||
list.push({...user, avatar:await imports.imgb64(user.avatarUrl)})
|
||||
list.push({...user, avatar: await imports.imgb64(user.avatarUrl)})
|
||||
count.past.total++
|
||||
count.past[user.type]++
|
||||
}
|
||||
@@ -77,6 +77,6 @@ export default async function({login, q, imports, data, graphql, queries, accoun
|
||||
}
|
||||
//Handle errors
|
||||
catch (error) {
|
||||
throw {error:{message:"An error occured", instance:error}}
|
||||
throw {error: {message: "An error occured", instance: error}}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user