Organization metrics improvements (#124)
This commit is contained in:
@@ -3,6 +3,7 @@ query BaseOrganization {
|
|||||||
databaseId
|
databaseId
|
||||||
name
|
name
|
||||||
login
|
login
|
||||||
|
location
|
||||||
createdAt
|
createdAt
|
||||||
avatarUrl
|
avatarUrl
|
||||||
websiteUrl
|
websiteUrl
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ query BaseUser {
|
|||||||
databaseId
|
databaseId
|
||||||
name
|
name
|
||||||
login
|
login
|
||||||
|
location
|
||||||
createdAt
|
createdAt
|
||||||
avatarUrl
|
avatarUrl
|
||||||
websiteUrl
|
websiteUrl
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
const languages = {details, colors:{}, total:0, stats:{}}
|
const languages = {details, colors:{}, total:0, stats:{}}
|
||||||
for (const repository of data.user.repositories.nodes) {
|
for (const repository of data.user.repositories.nodes) {
|
||||||
//Skip repository if asked
|
//Skip repository if asked
|
||||||
if (skipped.includes(repository.name.toLocaleLowerCase())) {
|
if ((skipped.includes(repository.name.toLocaleLowerCase()))||(skipped.includes(`${repository.owner.login}/${repository.name}`.toLocaleLowerCase()))) {
|
||||||
console.debug(`metrics/compute/${login}/plugins > languages > skipped repository ${repository.name}`)
|
console.debug(`metrics/compute/${login}/plugins > languages > skipped repository ${repository.owner.login}/${repository.name}`)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//Process repository languages
|
//Process repository languages
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ inputs:
|
|||||||
type: array
|
type: array
|
||||||
format: comma-separated
|
format: comma-separated
|
||||||
default: ""
|
default: ""
|
||||||
example: my-repo-1, my-repo-2, ...
|
example: my-repo-1, my-repo-2, owner/repo-3 ...
|
||||||
|
|
||||||
# Overrides default languages colors
|
# Overrides default languages colors
|
||||||
# Use `${n}:${color}` to change the color of the n-th most used language (e.g. "0:red" to make your most used language red)
|
# Use `${n}:${color}` to change the color of the n-th most used language (e.g. "0:red" to make your most used language red)
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ The following types are supported:
|
|||||||
| `stargazers` | | ❌ | ✔️ |
|
| `stargazers` | | ❌ | ✔️ |
|
||||||
| `watchers` | | ❌ | ✔️ |
|
| `watchers` | | ❌ | ✔️ |
|
||||||
| `thanks` | | ✔️ | ✔️ |
|
| `thanks` | | ✔️ | ✔️ |
|
||||||
|
| `members` | | ✔️ (organization) | ❌ |
|
||||||
|
|
||||||
|
|
||||||
Sections will be ordered the same as specified in `plugin_people_types`.
|
Sections will be ordered the same as specified in `plugin_people_types`.
|
||||||
`sponsors` for repositories will output the same as the owner's sponsors.
|
`sponsors` for repositories will output the same as the owner's sponsors.
|
||||||
@@ -49,4 +51,5 @@ Sections will be ordered the same as specified in `plugin_people_types`.
|
|||||||
plugin_people_size: 28 # Size in pixels of displayed avatars
|
plugin_people_size: 28 # Size in pixels of displayed avatars
|
||||||
plugin_people_identicons: no # Use avatars (do not use identicons)
|
plugin_people_identicons: no # Use avatars (do not use identicons)
|
||||||
plugin_people_thanks: lowlighter, octocat # Users that will be displayed in "thanks" sections
|
plugin_people_thanks: lowlighter, octocat # Users that will be displayed in "thanks" sections
|
||||||
|
plugin_people_shuffle: yes # Shuffle for varied output
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
//Context
|
//Context
|
||||||
let context = {
|
let context = {
|
||||||
mode:"user",
|
mode:"user",
|
||||||
types:account === "organization" ? ["sponsorshipsAsMaintainer", "sponsorshipsAsSponsor", "thanks"] : ["followers", "following", "sponsorshipsAsMaintainer", "sponsorshipsAsSponsor", "thanks"],
|
types:account === "organization" ? ["sponsorshipsAsMaintainer", "sponsorshipsAsSponsor", "membersWithRole", "thanks"] : ["followers", "following", "sponsorshipsAsMaintainer", "sponsorshipsAsSponsor", "thanks"],
|
||||||
default:"followers, following",
|
default:"followers, following",
|
||||||
alias:{followed:"following", sponsors:"sponsorshipsAsMaintainer", sponsored:"sponsorshipsAsSponsor", sponsoring:"sponsorshipsAsSponsor"},
|
alias:{followed:"following", sponsors:"sponsorshipsAsMaintainer", sponsored:"sponsorshipsAsSponsor", sponsoring:"sponsorshipsAsSponsor", members:"membersWithRole"},
|
||||||
sponsorships:{sponsorshipsAsMaintainer:"sponsorEntity", sponsorshipsAsSponsor:"sponsorable"},
|
sponsorships:{sponsorshipsAsMaintainer:"sponsorEntity", sponsorshipsAsSponsor:"sponsorable"},
|
||||||
}
|
}
|
||||||
if (q.repo) {
|
if (q.repo) {
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Load inputs
|
//Load inputs
|
||||||
let {limit, types, size, identicons, thanks} = imports.metadata.plugins.people.inputs({data, account, q}, {types:context.default})
|
let {limit, types, size, identicons, thanks, shuffle} = imports.metadata.plugins.people.inputs({data, account, q}, {types:context.default})
|
||||||
//Filter types
|
//Filter types
|
||||||
types = [...new Set([...types].map(type => (context.alias[type] ?? type)).filter(type => context.types.includes(type)) ?? [])]
|
types = [...new Set([...types].map(type => (context.alias[type] ?? type)).filter(type => context.types.includes(type)) ?? [])]
|
||||||
|
|
||||||
@@ -50,13 +50,18 @@
|
|||||||
const {[type]:{edges}} = (
|
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] :
|
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 :
|
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}"` : ""}))).user
|
(await graphql(queries.people({login, type, size, after:cursor ? `after: "${cursor}"` : "", account})))[account]
|
||||||
)
|
)
|
||||||
cursor = edges?.[edges?.length-1]?.cursor
|
cursor = edges?.[edges?.length-1]?.cursor
|
||||||
result[type].push(...edges.map(({node}) => node[context.sponsorships[type]] ?? node))
|
result[type].push(...edges.map(({node}) => node[context.sponsorships[type]] ?? node))
|
||||||
pushed = edges.length
|
pushed = edges.length
|
||||||
} while ((pushed)&&(cursor)&&(result[type].length <= limit))
|
} while ((pushed)&&(cursor)&&((limit === 0)||(result[type].length <= (shuffle ? 10*limit : limit))))
|
||||||
}
|
}
|
||||||
|
//Shuffle
|
||||||
|
if (shuffle) {
|
||||||
|
console.debug(`metrics/compute/${login}/plugins > people > shuffling`)
|
||||||
|
imports.shuffle(result[type])
|
||||||
|
}
|
||||||
//Limit people
|
//Limit people
|
||||||
if (limit > 0) {
|
if (limit > 0) {
|
||||||
console.debug(`metrics/compute/${login}/plugins > people > keeping only ${limit} ${type}`)
|
console.debug(`metrics/compute/${login}/plugins > people > keeping only ${limit} ${type}`)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ inputs:
|
|||||||
- following # For user metrics
|
- following # For user metrics
|
||||||
- followed # For user metrics, alias for "following"
|
- followed # For user metrics, alias for "following"
|
||||||
- sponsoring # For user metrics
|
- sponsoring # For user metrics
|
||||||
|
- members # For organization metrics
|
||||||
- sponsored # Alias for "sponsored"
|
- sponsored # Alias for "sponsored"
|
||||||
- sponsors # For both user and repository metrics
|
- sponsors # For both user and repository metrics
|
||||||
- contributors # For repository metrics
|
- contributors # For repository metrics
|
||||||
@@ -60,4 +61,11 @@ inputs:
|
|||||||
plugin_people_identicons:
|
plugin_people_identicons:
|
||||||
description: Use identicons instead of avatars
|
description: Use identicons instead of avatars
|
||||||
type: boolean
|
type: boolean
|
||||||
|
default: no
|
||||||
|
|
||||||
|
# Shuffle users for varied outputs
|
||||||
|
# If "plugin_people_limit" is set, plugin will fetch up to 10 ten times limit to ensure output is different each time
|
||||||
|
plugin_people_shuffle:
|
||||||
|
description: Shuffle users
|
||||||
|
type: boolean
|
||||||
default: no
|
default: no
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
query PeopleDefault {
|
query PeopleDefault {
|
||||||
user(login: "$login") {
|
$account(login: "$login") {
|
||||||
login
|
login
|
||||||
$type($after first: 100) {
|
$type($after first: 100) {
|
||||||
edges {
|
edges {
|
||||||
|
|||||||
@@ -22,7 +22,17 @@
|
|||||||
//Querying repository project
|
//Querying repository project
|
||||||
console.debug(`metrics/compute/${login}/plugins > projects > querying api for ${identifier}`)
|
console.debug(`metrics/compute/${login}/plugins > projects > querying api for ${identifier}`)
|
||||||
const {user, repository, id} = identifier.match(/(?<user>[-\w]+)[/](?<repository>[-\w]+)[/]projects[/](?<id>\d+)/)?.groups ?? {}
|
const {user, repository, id} = identifier.match(/(?<user>[-\w]+)[/](?<repository>[-\w]+)[/]projects[/](?<id>\d+)/)?.groups ?? {}
|
||||||
const {[account]:{repository:{project}}} = await graphql(queries.projects.repository({user, repository, id, account}))
|
let project = null
|
||||||
|
for (const account of ["user", "organization"]) {
|
||||||
|
try {
|
||||||
|
({project} = (await graphql(queries.projects.repository({user, repository, id, account})))[account].repository)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!project)
|
||||||
|
throw new Error(`Could not load project ${user}/${repository}`)
|
||||||
//Adding it to projects list
|
//Adding it to projects list
|
||||||
console.debug(`metrics/compute/${login}/plugins > projects > registering ${identifier}`)
|
console.debug(`metrics/compute/${login}/plugins > projects > registering ${identifier}`)
|
||||||
project.name = `${project.name} (${user}/${repository})`
|
project.name = `${project.name} (${user}/${repository})`
|
||||||
|
|||||||
@@ -61,12 +61,24 @@
|
|||||||
Joined GitHub <%= computed.registration %>
|
Joined GitHub <%= computed.registration %>
|
||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
|
<% if (user.location) { %>
|
||||||
|
<div class="field">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M11.536 3.464a5 5 0 010 7.072L8 14.07l-3.536-3.535a5 5 0 117.072-7.072v.001zm1.06 8.132a6.5 6.5 0 10-9.192 0l3.535 3.536a1.5 1.5 0 002.122 0l3.535-3.536zM8 9a2 2 0 100-4 2 2 0 000 4z"></path></svg>
|
||||||
|
<%= user.location %>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"></path></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"></path></svg>
|
||||||
<%= user.membersWithRole.totalCount %> member<%= s(user.membersWithRole.totalCount) %>
|
<%= user.membersWithRole.totalCount %> member<%= s(user.membersWithRole.totalCount) %>
|
||||||
</div>
|
</div>
|
||||||
|
<% if (user.isVerified) { %>
|
||||||
|
<div class="field">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M9.585.52a2.678 2.678 0 00-3.17 0l-.928.68a1.178 1.178 0 01-.518.215L3.83 1.59a2.678 2.678 0 00-2.24 2.24l-.175 1.14a1.178 1.178 0 01-.215.518l-.68.928a2.678 2.678 0 000 3.17l.68.928c.113.153.186.33.215.518l.175 1.138a2.678 2.678 0 002.24 2.24l1.138.175c.187.029.365.102.518.215l.928.68a2.678 2.678 0 003.17 0l.928-.68a1.17 1.17 0 01.518-.215l1.138-.175a2.678 2.678 0 002.241-2.241l.175-1.138c.029-.187.102-.365.215-.518l.68-.928a2.678 2.678 0 000-3.17l-.68-.928a1.179 1.179 0 01-.215-.518L14.41 3.83a2.678 2.678 0 00-2.24-2.24l-1.138-.175a1.179 1.179 0 01-.518-.215L9.585.52zM7.303 1.728c.415-.305.98-.305 1.394 0l.928.68c.348.256.752.423 1.18.489l1.136.174c.51.078.909.478.987.987l.174 1.137c.066.427.233.831.489 1.18l.68.927c.305.415.305.98 0 1.394l-.68.928a2.678 2.678 0 00-.489 1.18l-.174 1.136a1.178 1.178 0 01-.987.987l-1.137.174a2.678 2.678 0 00-1.18.489l-.927.68c-.415.305-.98.305-1.394 0l-.928-.68a2.678 2.678 0 00-1.18-.489l-1.136-.174a1.178 1.178 0 01-.987-.987l-.174-1.137a2.678 2.678 0 00-.489-1.18l-.68-.927a1.178 1.178 0 010-1.394l.68-.928c.256-.348.423-.752.489-1.18l.174-1.136c.078-.51.478-.909.987-.987l1.137-.174a2.678 2.678 0 001.18-.489l.927-.68zM11.28 6.78a.75.75 0 00-1.06-1.06L7 8.94 5.78 7.72a.75.75 0 00-1.06 1.06l1.75 1.75a.75.75 0 001.06 0l3.75-3.75z"></path></svg>
|
||||||
|
Verified
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<% if (type === "thanks") { %>
|
<% if (type === "thanks") { %>
|
||||||
Special thanks
|
Special thanks
|
||||||
<% } else { %>
|
<% } else { %>
|
||||||
<%= user[type].totalCount %> <%= {followers:`follower${s(user[type].totalCount)}`, following:"followed", sponsorshipsAsSponsor:"sponsored", sponsorshipsAsMaintainer:`sponsor${s(user[type].totalCount)}`}[type] %>
|
<%= user[type].totalCount %> <%= {followers:`follower${s(user[type].totalCount)}`, following:"followed", membersWithRole:`member${s(user[type].totalCount)}`, sponsorshipsAsSponsor:"sponsored", sponsorshipsAsMaintainer:`sponsor${s(user[type].totalCount)}`}[type] %>
|
||||||
<% } %>
|
<% } %>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
Reference in New Issue
Block a user