feat(plugins/notable): add plugin_notable_self (closes #1143)
This commit is contained in:
@@ -7,7 +7,7 @@ export default async function({login, q, imports, rest, graphql, data, account,
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//Load inputs
|
||||||
let {filter, skipped, repositories, types, from, indepth} = imports.metadata.plugins.notable.inputs({data, account, q})
|
let {filter, skipped, repositories, types, from, indepth, self} = imports.metadata.plugins.notable.inputs({data, account, q})
|
||||||
skipped.push(...data.shared["repositories.skipped"])
|
skipped.push(...data.shared["repositories.skipped"])
|
||||||
|
|
||||||
//Iterate through contributed repositories
|
//Iterate through contributed repositories
|
||||||
@@ -17,7 +17,7 @@ export default async function({login, q, imports, rest, graphql, data, account,
|
|||||||
let pushed = 0
|
let pushed = 0
|
||||||
do {
|
do {
|
||||||
console.debug(`metrics/compute/${login}/plugins > notable > retrieving contributed repositories after ${cursor}`)
|
console.debug(`metrics/compute/${login}/plugins > notable > retrieving contributed repositories after ${cursor}`)
|
||||||
const {user: {repositoriesContributedTo: {edges}}} = await graphql(queries.notable.contributions({login, types: types.map(x => x.toLocaleUpperCase()).join(", "), after: cursor ? `after: "${cursor}"` : "", repositories: data.shared["repositories.batch"] || 100}))
|
const {user: {repositoriesContributedTo: {edges}}} = await graphql(queries.notable.contributions({login, types: types.map(x => x.toLocaleUpperCase()).join(", "), after: cursor ? `after: "${cursor}"` : "", self, repositories: data.shared["repositories.batch"] || 100}))
|
||||||
cursor = edges?.[edges?.length - 1]?.cursor
|
cursor = edges?.[edges?.length - 1]?.cursor
|
||||||
edges
|
edges
|
||||||
.filter(({node}) => !((skipped.includes(node.nameWithOwner.toLocaleLowerCase())) || (skipped.includes(node.nameWithOwner.split("/")[1].toLocaleLowerCase()))))
|
.filter(({node}) => !((skipped.includes(node.nameWithOwner.toLocaleLowerCase())) || (skipped.includes(node.nameWithOwner.split("/")[1].toLocaleLowerCase()))))
|
||||||
@@ -80,7 +80,7 @@ export default async function({login, q, imports, rest, graphql, data, account,
|
|||||||
|
|
||||||
//Count total commits of user
|
//Count total commits of user
|
||||||
const {data: contributions = []} = await rest.repos.getContributorsStats({owner, repo})
|
const {data: contributions = []} = await rest.repos.getContributorsStats({owner, repo})
|
||||||
const commits = contributions.filter(({author}) => author.login.toLocaleLowerCase() === login.toLocaleLowerCase()).reduce((a, {total: b}) => a + b, 0)
|
const commits = contributions?.filter(({author}) => author.login.toLocaleLowerCase() === login.toLocaleLowerCase()).reduce((a, {total: b}) => a + b, 0) ?? NaN
|
||||||
|
|
||||||
//Save user data
|
//Save user data
|
||||||
contribution.user = {
|
contribution.user = {
|
||||||
|
|||||||
@@ -86,3 +86,9 @@ inputs:
|
|||||||
- commit
|
- commit
|
||||||
- pull_request
|
- pull_request
|
||||||
- issue
|
- issue
|
||||||
|
|
||||||
|
plugin_notable_self:
|
||||||
|
description: |
|
||||||
|
Include own repositories
|
||||||
|
type: boolean
|
||||||
|
default: no
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
query NotableContributions {
|
query NotableContributions {
|
||||||
user(login: "$login") {
|
user(login: "$login") {
|
||||||
repositoriesContributedTo($after first: $repositories, contributionTypes: [$types], orderBy: { field: STARGAZERS, direction: DESC }) {
|
repositoriesContributedTo($after first: $repositories, contributionTypes: [$types], includeUserRepositories: $self, orderBy: { field: STARGAZERS, direction: DESC }) {
|
||||||
edges {
|
edges {
|
||||||
cursor
|
cursor
|
||||||
node {
|
node {
|
||||||
|
|||||||
Reference in New Issue
Block a user