Version 2.4
- Add new plugin "Gists" - Fix sponsorships - Minor icons changes - Add new repositories metrics "sponsors" and and "releases"
This commit is contained in:
51
src/plugins/gists/index.mjs
Normal file
51
src/plugins/gists/index.mjs
Normal file
@@ -0,0 +1,51 @@
|
||||
//Setup
|
||||
export default async function ({login, graphql, q}, {enabled = false} = {}) {
|
||||
//Plugin execution
|
||||
try {
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if ((!enabled)||(!q.gists))
|
||||
return null
|
||||
|
||||
//Retrieve contribution calendar from graphql api
|
||||
const {user:{gists}} = await graphql(`
|
||||
query Gists {
|
||||
user(login: "${login}") {
|
||||
gists(last: 100) {
|
||||
totalCount
|
||||
nodes {
|
||||
stargazerCount
|
||||
isFork
|
||||
forks {
|
||||
totalCount
|
||||
}
|
||||
comments {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
)
|
||||
|
||||
//Iterate through gists
|
||||
let stargazers = 0, forks = 0, comments = 0
|
||||
for (const gist of gists.nodes) {
|
||||
//Skip forks
|
||||
if (gist.isFork)
|
||||
continue
|
||||
//Compute stars, forks and comments
|
||||
stargazers += gist.stargazerCount
|
||||
forks += gist.forks.totalCount
|
||||
comments += gist.comments.totalCount
|
||||
}
|
||||
|
||||
//Results
|
||||
return {totalCount:gists.totalCount, stargazers, forks, comments}
|
||||
}
|
||||
//Handle errors
|
||||
catch (error) {
|
||||
console.debug(error)
|
||||
throw {error:{message:`An error occured`}}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
//Imports
|
||||
import followup from "./followup/index.mjs"
|
||||
import gists from "./gists/index.mjs"
|
||||
import habits from "./habits/index.mjs"
|
||||
import isocalendar from "./isocalendar/index.mjs"
|
||||
import languages from "./languages/index.mjs"
|
||||
@@ -15,6 +16,7 @@
|
||||
//Exports
|
||||
export default {
|
||||
followup,
|
||||
gists,
|
||||
habits,
|
||||
isocalendar,
|
||||
languages,
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
if (Array.isArray(posts)) {
|
||||
//Limit tracklist
|
||||
if (limit > 0) {
|
||||
console.debug(`metrics/compute/${login}/plugins > music > keeping only ${limit} posts`)
|
||||
console.debug(`metrics/compute/${login}/plugins > posts > keeping only ${limit} posts`)
|
||||
posts = posts.slice(0, limit)
|
||||
}
|
||||
//Results
|
||||
|
||||
Reference in New Issue
Block a user