diff --git a/source/plugins/base/queries/organization.graphql b/source/plugins/base/queries/organization.graphql index b9ce3679..3c3996a2 100644 --- a/source/plugins/base/queries/organization.graphql +++ b/source/plugins/base/queries/organization.graphql @@ -3,6 +3,7 @@ query BaseOrganization { databaseId name login + location createdAt avatarUrl websiteUrl diff --git a/source/plugins/base/queries/user.graphql b/source/plugins/base/queries/user.graphql index 667ee62d..f49b1e3e 100644 --- a/source/plugins/base/queries/user.graphql +++ b/source/plugins/base/queries/user.graphql @@ -3,6 +3,7 @@ query BaseUser { databaseId name login + location createdAt avatarUrl websiteUrl diff --git a/source/plugins/languages/index.mjs b/source/plugins/languages/index.mjs index 77fac98a..fcd946e0 100644 --- a/source/plugins/languages/index.mjs +++ b/source/plugins/languages/index.mjs @@ -22,8 +22,8 @@ const languages = {details, colors:{}, total:0, stats:{}} for (const repository of data.user.repositories.nodes) { //Skip repository if asked - if (skipped.includes(repository.name.toLocaleLowerCase())) { - console.debug(`metrics/compute/${login}/plugins > languages > skipped repository ${repository.name}`) + if ((skipped.includes(repository.name.toLocaleLowerCase()))||(skipped.includes(`${repository.owner.login}/${repository.name}`.toLocaleLowerCase()))) { + console.debug(`metrics/compute/${login}/plugins > languages > skipped repository ${repository.owner.login}/${repository.name}`) continue } //Process repository languages diff --git a/source/plugins/languages/metadata.yml b/source/plugins/languages/metadata.yml index ba2552e7..9b9ffada 100644 --- a/source/plugins/languages/metadata.yml +++ b/source/plugins/languages/metadata.yml @@ -27,7 +27,7 @@ inputs: type: array format: comma-separated default: "" - example: my-repo-1, my-repo-2, ... + example: my-repo-1, my-repo-2, owner/repo-3 ... # 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) diff --git a/source/plugins/people/README.md b/source/plugins/people/README.md index 7ab8cc8a..19b37832 100644 --- a/source/plugins/people/README.md +++ b/source/plugins/people/README.md @@ -31,6 +31,8 @@ The following types are supported: | `stargazers` | | ❌ | ✔️ | | `watchers` | | ❌ | ✔️ | | `thanks` | | ✔️ | ✔️ | +| `members` | | ✔️ (organization) | ❌ | + Sections will be ordered the same as specified in `plugin_people_types`. `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_identicons: no # Use avatars (do not use identicons) plugin_people_thanks: lowlighter, octocat # Users that will be displayed in "thanks" sections + plugin_people_shuffle: yes # Shuffle for varied output ``` diff --git a/source/plugins/people/index.mjs b/source/plugins/people/index.mjs index adb62c32..a7dd89af 100644 --- a/source/plugins/people/index.mjs +++ b/source/plugins/people/index.mjs @@ -9,9 +9,9 @@ //Context let context = { 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", - 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"}, } if (q.repo) { @@ -21,7 +21,7 @@ } //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 types = [...new Set([...types].map(type => (context.alias[type] ?? type)).filter(type => context.types.includes(type)) ?? [])] @@ -50,13 +50,18 @@ 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}"` : ""}))).user + (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)&&(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 if (limit > 0) { console.debug(`metrics/compute/${login}/plugins > people > keeping only ${limit} ${type}`) diff --git a/source/plugins/people/metadata.yml b/source/plugins/people/metadata.yml index 2d607ec6..1dda0795 100644 --- a/source/plugins/people/metadata.yml +++ b/source/plugins/people/metadata.yml @@ -41,6 +41,7 @@ inputs: - following # For user metrics - followed # For user metrics, alias for "following" - sponsoring # For user metrics + - members # For organization metrics - sponsored # Alias for "sponsored" - sponsors # For both user and repository metrics - contributors # For repository metrics @@ -60,4 +61,11 @@ inputs: plugin_people_identicons: description: Use identicons instead of avatars 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 \ No newline at end of file diff --git a/source/plugins/people/queries/people.graphql b/source/plugins/people/queries/people.graphql index 86a1c93a..8d2d0c83 100644 --- a/source/plugins/people/queries/people.graphql +++ b/source/plugins/people/queries/people.graphql @@ -1,5 +1,5 @@ query PeopleDefault { - user(login: "$login") { + $account(login: "$login") { login $type($after first: 100) { edges { diff --git a/source/plugins/projects/index.mjs b/source/plugins/projects/index.mjs index b2ffe005..c8b1f449 100644 --- a/source/plugins/projects/index.mjs +++ b/source/plugins/projects/index.mjs @@ -22,7 +22,17 @@ //Querying repository project console.debug(`metrics/compute/${login}/plugins > projects > querying api for ${identifier}`) const {user, repository, id} = identifier.match(/(?[-\w]+)[/](?[-\w]+)[/]projects[/](?\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 console.debug(`metrics/compute/${login}/plugins > projects > registering ${identifier}`) project.name = `${project.name} (${user}/${repository})` diff --git a/source/templates/classic/partials/base.header.ejs b/source/templates/classic/partials/base.header.ejs index 4ba5bb35..d855f69b 100644 --- a/source/templates/classic/partials/base.header.ejs +++ b/source/templates/classic/partials/base.header.ejs @@ -61,12 +61,24 @@ Joined GitHub <%= computed.registration %> <% } %> + <% if (user.location) { %> +
+ + <%= user.location %> +
+ <% } %>
<%= user.membersWithRole.totalCount %> member<%= s(user.membersWithRole.totalCount) %>
+ <% if (user.isVerified) { %> +
+ + Verified +
+ <% } %>
diff --git a/source/templates/classic/partials/people.ejs b/source/templates/classic/partials/people.ejs index 65bd2704..09f9969e 100644 --- a/source/templates/classic/partials/people.ejs +++ b/source/templates/classic/partials/people.ejs @@ -22,7 +22,7 @@ <% if (type === "thanks") { %> Special thanks <% } 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] %> <% } %>