The great refactor (#82)

This commit is contained in:
Simon Lecoq
2021-01-30 12:31:09 +01:00
committed by GitHub
parent f8c6d19a4e
commit 682e43e10b
158 changed files with 6738 additions and 5022 deletions

View File

@@ -0,0 +1,21 @@
### 🎫 Gists
The *gists* plugin displays your [gists](https://gist.github.com) metrics.
<table>
<td align="center">
<img src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.gists.svg">
<img width="900" height="1" alt="">
</td>
</table>
#### Examples workflows
[➡️ Available options for this plugin](metadata.yml)
```yaml
- uses: lowlighter/metrics@latest
with:
# ... other options
plugin_gists: yes
```

View File

@@ -1,12 +1,14 @@
//Setup
export default async function ({login, graphql, q, queries, account}, {enabled = false} = {}) {
export default async function ({login, data, graphql, q, imports, queries, account}, {enabled = false} = {}) {
//Plugin execution
try {
//Check if plugin is enabled and requirements are met
if ((!enabled)||(!q.gists))
return null
if (account === "organization")
throw {error:{message:"Not available for organizations"}}
//Load inputs
imports.metadata.plugins.gists.inputs({data, account, q})
//Query gists from GitHub API
const gists = []
{
@@ -23,6 +25,7 @@
} while ((pushed)&&(cursor))
console.debug(`metrics/compute/${login}/plugins > gists > loaded ${gists.length} gists`)
}
//Iterate through gists
console.debug(`metrics/compute/${login}/plugins > gists > processing ${gists.length} gists`)
let stargazers = 0, forks = 0, comments = 0, files = 0
@@ -36,6 +39,7 @@
comments += gist.comments.totalCount
files += gist.files.length
}
//Results
return {totalCount:gists.totalCount, stargazers, forks, files, comments}
}

View File

@@ -0,0 +1,11 @@
name: "🎫 Gists"
cost: 1 GraphQL request per 100 gists
supports:
- user
inputs:
# Enable or disable plugin
plugin_gists:
description: Display gists metrics
type: boolean
default: no

View File

@@ -0,0 +1,23 @@
query GistsDefault {
user(login: "$login") {
gists($after first: 100, orderBy: {field: UPDATED_AT, direction: DESC}) {
edges {
cursor
}
totalCount
nodes {
stargazerCount
isFork
forks {
totalCount
}
files {
name
}
comments {
totalCount
}
}
}
}
}