Make repositories_affiliations support arrays, and use both affiliations and affiliationsOwner in queries #232
This commit is contained in:
@@ -32,8 +32,8 @@ These are all enabled by default, but you can explicitely opt out from them.
|
|||||||
- uses: lowlighter/metrics@latest
|
- uses: lowlighter/metrics@latest
|
||||||
with:
|
with:
|
||||||
# ... other options
|
# ... other options
|
||||||
base: header, repositories # Only display "header" and "repositories" sections
|
base: header, repositories # Only display "header" and "repositories" sections
|
||||||
repositories: 100 # Query only last 100 repositories
|
repositories: 100 # Query only last 100 repositories
|
||||||
repositories_forks: no # Don't include forks
|
repositories_forks: no # Don't include forks
|
||||||
repositories_affiliations: owner # Display only repositories where user is owner
|
repositories_affiliations: owner, collaborator # Display only repositories where user is owner or collaborator
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -7,7 +7,9 @@
|
|||||||
export default async function({login, graphql, data, q, queries, imports}, conf) {
|
export default async function({login, graphql, data, q, queries, imports}, conf) {
|
||||||
//Load inputs
|
//Load inputs
|
||||||
console.debug(`metrics/compute/${login}/base > started`)
|
console.debug(`metrics/compute/${login}/base > started`)
|
||||||
let {repositories, "repositories.forks":forks, "repositories.affiliations":affiliations} = imports.metadata.plugins.base.inputs({data, q, account:"bypass"}, {repositories:conf.settings.repositories ?? 100})
|
let {repositories, "repositories.forks":_forks, "repositories.affiliations":_affiliations} = imports.metadata.plugins.base.inputs({data, q, account:"bypass"}, {repositories:conf.settings.repositories ?? 100})
|
||||||
|
const forks = _forks ? "" : ", isFork: false"
|
||||||
|
const affiliations = _affiliations?.length ? `, ownerAffiliations: [${_affiliations.map(x => x.toLocaleUpperCase()).join(", ")}], affiliations: [${_affiliations.map(x => x.toLocaleUpperCase()).join(", ")}]` : ""
|
||||||
|
|
||||||
//Skip initial data gathering if not needed
|
//Skip initial data gathering if not needed
|
||||||
if (conf.settings.notoken)
|
if (conf.settings.notoken)
|
||||||
@@ -23,7 +25,7 @@
|
|||||||
try {
|
try {
|
||||||
//Query data from GitHub API
|
//Query data from GitHub API
|
||||||
console.debug(`metrics/compute/${login}/base > account ${account}`)
|
console.debug(`metrics/compute/${login}/base > account ${account}`)
|
||||||
const queried = await graphql(queries.base[account]({login, "calendar.from":new Date(Date.now()-14*24*60*60*1000).toISOString(), "calendar.to":(new Date()).toISOString(), forks:forks ? "" : ", isFork: false", affiliations:affiliations ? `, ownerAffiliations: ${affiliations.toLocaleUpperCase()}` : ""}))
|
const queried = await graphql(queries.base[account]({login, "calendar.from":new Date(Date.now()-14*24*60*60*1000).toISOString(), "calendar.to":(new Date()).toISOString(), forks, affiliations}))
|
||||||
Object.assign(data, {user:queried[account]})
|
Object.assign(data, {user:queried[account]})
|
||||||
postprocess?.[account]({login, data})
|
postprocess?.[account]({login, data})
|
||||||
//Query repositories from GitHub API
|
//Query repositories from GitHub API
|
||||||
@@ -33,7 +35,7 @@
|
|||||||
let pushed = 0
|
let pushed = 0
|
||||||
do {
|
do {
|
||||||
console.debug(`metrics/compute/${login}/base > retrieving repositories after ${cursor}`)
|
console.debug(`metrics/compute/${login}/base > retrieving repositories after ${cursor}`)
|
||||||
const {[account]:{repositories:{edges, nodes}}} = await graphql(queries.base.repositories({login, account, after:cursor ? `after: "${cursor}"` : "", repositories:Math.min(repositories, {user:100, organization:25}[account]), forks:forks ? "" : ", isFork: false", affiliations:affiliations ? `, ownerAffiliations: ${affiliations.toLocaleUpperCase()}` : ""}))
|
const {[account]:{repositories:{edges, nodes}}} = await graphql(queries.base.repositories({login, account, after:cursor ? `after: "${cursor}"` : "", repositories:Math.min(repositories, {user:100, organization:25}[account]), forks, affiliations}))
|
||||||
cursor = edges?.[edges?.length-1]?.cursor
|
cursor = edges?.[edges?.length-1]?.cursor
|
||||||
data.user.repositories.nodes.push(...nodes)
|
data.user.repositories.nodes.push(...nodes)
|
||||||
pushed = nodes.length
|
pushed = nodes.length
|
||||||
|
|||||||
@@ -34,14 +34,15 @@ inputs:
|
|||||||
type: boolean
|
type: boolean
|
||||||
default: no
|
default: no
|
||||||
|
|
||||||
# Filter repositories by user affiliations
|
# Filter repositories by user affiliations (you can specify multiple affiliations constraints)
|
||||||
|
# Set to "" to use all repositories related to you
|
||||||
# Note that it may affect some plugin outputs (broad affiliations will result in less representative metrics)
|
# Note that it may affect some plugin outputs (broad affiliations will result in less representative metrics)
|
||||||
repositories_affiliations:
|
repositories_affiliations:
|
||||||
description: Repositories affiliations
|
description: Repositories affiliations
|
||||||
type: string
|
type: array
|
||||||
|
format: comma-separated
|
||||||
default: owner
|
default: owner
|
||||||
values:
|
values:
|
||||||
- "" # Use all repositories related to you
|
|
||||||
- owner # Use repositories you own
|
- owner # Use repositories you own
|
||||||
- collaborator # Use repositories you have contributed too
|
- collaborator # Use repositories you have contributed too
|
||||||
- organization_member # Use repositories where you're an organization member
|
- organization_member # Use repositories where you're an organization member
|
||||||
|
|||||||
Reference in New Issue
Block a user