-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add plugin projects * Add images for readme
- Loading branch information
1 parent
4a31248
commit 1d11145
Showing
11 changed files
with
165 additions
and
24 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//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.projects)) | ||
return null | ||
//Parameters override | ||
let {"projects.limit":limit = 4} = q | ||
//Limit | ||
limit = Math.max(1, Math.min(100, Number(limit))) | ||
//Retrieve contribution calendar from graphql api | ||
const {user:{projects}} = await graphql(` | ||
query Projects { | ||
user(login: "${login}") { | ||
projects(last: ${limit}, states: OPEN, orderBy: {field: UPDATED_AT, direction: DESC}) { | ||
totalCount | ||
nodes { | ||
name | ||
updatedAt | ||
progress { | ||
doneCount | ||
inProgressCount | ||
todoCount | ||
enabled | ||
} | ||
} | ||
} | ||
} | ||
} | ||
` | ||
) | ||
//Iterate through projects and format them | ||
const list = [] | ||
for (const project of projects.nodes) { | ||
//Format date | ||
const time = (Date.now()-new Date(project.updatedAt).getTime())/(24*60*60*1000) | ||
let updated = project.updatedAt | ||
if (time < 1) | ||
updated = "less than 1 day ago" | ||
else if (time < 30) | ||
updated = `${Math.floor(time)} day${time >= 2 ? "s" : ""} ago` | ||
else | ||
updated = new Date(project.updatedAt).toDateString().substring(4) | ||
//Format progress | ||
const {enabled, todoCount:todo, inProgressCount:doing, doneCount:done} = project.progress | ||
//Append | ||
list.push({name:project.name, updated, progress:{enabled, todo, doing, done, total:todo+doing+done}}) | ||
} | ||
//Results | ||
return {list, totalCount:projects.totalCount} | ||
} | ||
//Handle errors | ||
catch (error) { | ||
console.debug(error) | ||
throw {error:{message:`An error occured`}} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.