Fix habits and stargazers plugin, add repositories_affiliations options and metadata updates (#117)
This commit is contained in:
@@ -32,7 +32,8 @@ These are all enabled by default, but you can explicitely opt out from them.
|
||||
- uses: lowlighter/metrics@latest
|
||||
with:
|
||||
# ... other options
|
||||
base: header, repositories # Only display "header" and "repositories" sections
|
||||
repositories: 100 # Query only last 100 repositories
|
||||
repositories_forks: no # Don't include forks
|
||||
base: header, repositories # Only display "header" and "repositories" sections
|
||||
repositories: 100 # Query only last 100 repositories
|
||||
repositories_forks: no # Don't include forks
|
||||
repositories_affiliations: owner # Display only repositories where user is owner
|
||||
```
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
export default async function({login, graphql, data, q, queries, imports}, conf) {
|
||||
//Load inputs
|
||||
console.debug(`metrics/compute/${login}/base > started`)
|
||||
let {repositories, repositories_forks:forks} = 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})
|
||||
|
||||
//Skip initial data gathering if not needed
|
||||
if (conf.settings.notoken)
|
||||
@@ -23,7 +23,7 @@
|
||||
try {
|
||||
//Query data from GitHub API
|
||||
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"}))
|
||||
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()}` : ""}))
|
||||
Object.assign(data, {user:queried[account]})
|
||||
postprocess?.[account]({login, data})
|
||||
//Query repositories from GitHub API
|
||||
@@ -33,7 +33,7 @@
|
||||
let pushed = 0
|
||||
do {
|
||||
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"}))
|
||||
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()}` : ""}))
|
||||
cursor = edges?.[edges?.length-1]?.cursor
|
||||
data.user.repositories.nodes.push(...nodes)
|
||||
pushed = nodes.length
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
name: "🗃️ Base content"
|
||||
cost: 1 GraphQL request
|
||||
categorie: core
|
||||
supports:
|
||||
- user
|
||||
- organization
|
||||
@@ -32,3 +33,13 @@ inputs:
|
||||
description: Include forks in metrics
|
||||
type: boolean
|
||||
default: no
|
||||
|
||||
# Filter repositories by user affiliations
|
||||
repositories_affiliations:
|
||||
description: Repositories affiliations
|
||||
type: string
|
||||
default: ""
|
||||
values:
|
||||
- owner
|
||||
- collaborator
|
||||
- organization_member
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
query BaseRepositories {
|
||||
$account(login: "$login") {
|
||||
repositories($after first: $repositories $forks, orderBy: {field: UPDATED_AT, direction: DESC}) {
|
||||
repositories($after first: $repositories $forks $affiliations, orderBy: {field: UPDATED_AT, direction: DESC}) {
|
||||
edges {
|
||||
cursor
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ query BaseUser {
|
||||
websiteUrl
|
||||
isHireable
|
||||
twitterUsername
|
||||
repositories(last: 0 $forks) {
|
||||
repositories(last: 0 $forks $affiliations) {
|
||||
totalCount
|
||||
totalDiskUsage
|
||||
nodes {
|
||||
|
||||
Reference in New Issue
Block a user