|
21 | 21 | } |
22 | 22 |
|
23 | 23 | //Load inputs |
24 | | - let {limit, types, size, identicons, thanks, shuffle} = imports.metadata.plugins.people.inputs({data, account, q}, {types:context.default}) |
| 24 | + let {limit, types, size, identicons, thanks, shuffle, "sponsors.custom":_sponsors} = imports.metadata.plugins.people.inputs({data, account, q}, {types:context.default}) |
25 | 25 | //Filter types |
26 | 26 | types = [...new Set([...types].map(type => (context.alias[type] ?? type)).filter(type => context.types.includes(type)) ?? [])] |
| 27 | + if ((types.includes("sponsorshipsAsMaintainer"))&&(_sponsors?.length)) { |
| 28 | + types.unshift("sponsorshipsCustom") |
| 29 | + data.user.sponsorshipsAsMaintainer.totalCount += _sponsors.length |
| 30 | + } |
27 | 31 |
|
28 | 32 | //Retrieve followers from graphql api |
29 | 33 | console.debug(`metrics/compute/${login}/plugins > people > querying api`) |
|
37 | 41 | const {data:nodes} = await rest.repos.listContributors({owner, repo}) |
38 | 42 | result[type].push(...nodes.map(({login, avatar_url}) => ({login, avatarUrl:avatar_url}))) |
39 | 43 | } |
40 | | - else if (type === "thanks") { |
41 | | - const nodes = await Promise.all(thanks.map(async username => (await rest.users.getByUsername({username})).data)) |
42 | | - result[type].push(...nodes.map(({login, avatar_url}) => ({login, avatarUrl:avatar_url}))) |
| 44 | + else if ((type === "thanks")||(type === "sponsorshipsCustom")) { |
| 45 | + const users = {thanks, sponsorshipsCustom:_sponsors}[type] ?? [] |
| 46 | + const nodes = await Promise.all(users.map(async username => (await rest.users.getByUsername({username})).data)) |
| 47 | + result[{sponsorshipsCustom:"sponsorshipsAsMaintainer"}[type] ?? type].push(...nodes.map(({login, avatar_url}) => ({login, avatarUrl:avatar_url}))) |
43 | 48 | } |
44 | 49 | //GraphQL |
45 | 50 | else { |
|
77 | 82 | await Promise.all(result[type].map(async user => user.avatar = await imports.imgb64(user.avatarUrl))) |
78 | 83 | } |
79 | 84 |
|
| 85 | + //Special type handling |
| 86 | + if (types.includes("sponsorshipsCustom")) |
| 87 | + types.splice(types.indexOf("sponsorshipsCustom"), 1) |
| 88 | + |
80 | 89 | //Results |
81 | 90 | return {types, size, ...result} |
82 | 91 | } |
|
0 commit comments