290 lines
41 KiB
JavaScript
290 lines
41 KiB
JavaScript
//Setup
|
||
export default async function({login, q, imports, data, computed, graphql, queries, account}, {enabled = false} = {}) {
|
||
//Plugin execution
|
||
try {
|
||
//Check if plugin is enabled and requirements are met
|
||
if ((!enabled)||(!q.achievements))
|
||
return null
|
||
|
||
//Load inputs
|
||
let {threshold, secrets, only, ignored, limit} = imports.metadata.plugins.achievements.inputs({data, q, account})
|
||
|
||
//Initinalization
|
||
const list = []
|
||
const {user} = await graphql(queries.achievements({login}))
|
||
const ranks = await graphql(queries.achievements.ranking({followers:user.followers.totalCount, stars:user.popular.nodes?.[0]?.stargazers?.totalCount ?? 0}))
|
||
|
||
//Developer
|
||
{
|
||
const value = user.repositories.totalCount
|
||
const unlock = user.repositories.nodes?.shift()
|
||
list.push({
|
||
title:"Developer",
|
||
text:`Published ${value} public repositor${imports.s(value, "y")}`,
|
||
icon:"<g stroke-linecap=\"round\" stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><g stroke=\"#2088FF\"><path d=\"M20 24l-3.397 3.398a.85.85 0 000 1.203L20.002 32M37.015 24l3.399 3.398a.85.85 0 010 1.203L37.014 32\" stroke-linejoin=\"round\"/><path d=\"M31.029 21.044L25.976 35.06\"/></g><path stroke=\"#79B8FF\" stroke-linejoin=\"round\" d=\"M23.018 10h8.984M26 47h5M8 16h16m9 0h15.725M8 41h13\"/><path d=\"M5.027 34.998c.673 2.157 1.726 4.396 2.81 6.02m43.38-19.095C50.7 19.921 49.866 17.796 48.79 16\" stroke=\"#79B8FF\"/><path stroke=\"#2088FF\" stroke-linejoin=\"round\" d=\"M26 41h17\"/><path d=\"M7.183 16C5.186 19.582 4 23.619 4 28M42.608 47.02c2.647-1.87 5.642-5.448 7.295-9.18C51.52 34.191 52.071 30.323 52 28\" stroke=\"#2088FF\"/><path stroke=\"#2088FF\" stroke-linejoin=\"round\" d=\"M7.226 16H28M13.343 47H21\"/><path d=\"M13.337 47.01a24.364 24.364 0 006.19 3.45 24.527 24.527 0 007.217 1.505c2.145.108 4.672-.05 7.295-.738\" stroke=\"#2088FF\"/><path stroke=\"#2088FF\" stroke-linejoin=\"round\" d=\"M36 47h6.647M12 10h6M37 10h6.858\"/><path d=\"M43.852 10c-4.003-3.667-9.984-6.054-16.047-6-2.367.021-4.658.347-6.81 1.045\" stroke=\"#2088FF\"/><path stroke=\"#79B8FF\" stroke-linejoin=\"round\" d=\"M5.041 35h4.962M47 22h4.191\"/></g>",
|
||
...rank(value, [1, 20, 50, 100]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Forker
|
||
{
|
||
const value = user.forks.totalCount
|
||
const unlock = user.forks.nodes?.shift()
|
||
list.push({
|
||
title:"Forker",
|
||
text:`Forked ${value} public repositor${imports.s(value, "y")}`,
|
||
icon:"<g stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><path d=\"M37.303 21.591a5.84 5.84 0 00-1.877-1.177 6.138 6.138 0 00-4.432 0 5.822 5.822 0 00-1.879 1.177L28 22.638l-1.115-1.047c-1.086-1.018-2.559-1.59-4.094-1.59-1.536 0-3.008.572-4.094 1.59-1.086 1.02-1.696 2.4-1.696 3.84 0 1.441.61 2.823 1.696 3.841l1.115 1.046L28 38l8.189-7.682 1.115-1.046a5.422 5.422 0 001.256-1.761 5.126 5.126 0 000-4.157 5.426 5.426 0 00-1.256-1.763z\" stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M15.967 42.705A18.922 18.922 0 0028 47a18.92 18.92 0 0011.076-3.56m-.032-30.902A18.914 18.914 0 0028 9c-4.09 0-7.876 1.292-10.976 3.49\" stroke=\"#79B8FF\" stroke-linecap=\"round\"/><g transform=\"translate(7 10)\" stroke=\"#2088FF\"><path d=\"M6 0v7c0 2.21-1.343 3-3 3s-3-.79-3-3V0\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path stroke-linecap=\"round\" d=\"M3 0v19.675\"/><rect stroke-linejoin=\"round\" x=\"1\" y=\"20\" width=\"4\" height=\"16\" rx=\"2\"/></g><g transform=\"translate(43 10)\" stroke=\"#2088FF\"><path stroke-linecap=\"round\" d=\"M2 15.968v3.674\"/><path d=\"M4 15.642H0L.014 4.045A4.05 4.05 0 014.028 0L4 15.642z\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><rect stroke-linejoin=\"round\" y=\"19.968\" width=\"4\" height=\"16\" rx=\"2\"/></g><path d=\"M41.364 8.062A23.888 23.888 0 0028 4a23.89 23.89 0 00-11.95 3.182M4.75 22.021A24.045 24.045 0 004 28c0 1.723.182 3.404.527 5.024m10.195 14.971A23.888 23.888 0 0028 52c4.893 0 9.444-1.464 13.239-3.979m9-10.98A23.932 23.932 0 0052 28c0-2.792-.477-5.472-1.353-7.964\" stroke=\"#79B8FF\" stroke-linecap=\"round\"/></g>",
|
||
...rank(value, [1, 5, 10, 20]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Contributor
|
||
{
|
||
const value = user.pullRequests.totalCount
|
||
const unlock = user.pullRequests.nodes?.shift()
|
||
|
||
list.push({
|
||
title:"Contributor",
|
||
text:`Opened ${value} pull request${imports.s(value)}`,
|
||
icon:"<g stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><path stroke=\"#79B8FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M26.022 5.014h6M26.012 53.005h6M27.003 47.003h12M44.01 20.005h5M19.01 11.003h12\"/><path stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M38.005 11.008h6M41 14.013v-6M14.007 47.003h6M17.002 50.004v-6\"/><path d=\"M29.015 5.01l-5.003 5.992 5.003-5.992zM33.015 47.01l-5.003 5.992 5.003-5.992z\" stroke=\"#79B8FF\"/><path stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M8.01 19.002h6\"/><path stroke=\"#79B8FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M47.011 29h6\"/><path stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M44.012 39.003h6\"/><g stroke=\"#79B8FF\"><path d=\"M5.36 29c4.353 0 6.4 4.472 6.4 8\"/><path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M13.99 37.995h-5M10.989 29h-6\"/></g><path d=\"M24.503 22c1.109 0 2.007.895 2.007 2 0 1.104-.898 2-2.007 2a2.004 2.004 0 01-2.008-2c0-1.105.9-2 2.008-2zM24.5 32a2 2 0 110 4 2 2 0 010-4zm9.5 0a2 2 0 110 4 2 2 0 010-4z\" stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path stroke=\"#2088FF\" d=\"M24.5 26.004v6.001\"/><path d=\"M31.076 23.988l1.027-.023a1.998 1.998 0 011.932 2.01L34 31\" stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M31.588 26.222l-2.194-2.046 2.046-2.194\"/><path d=\"M29.023 43c7.732 0 14-6.268 14-14s-6.268-14-14-14-14 6.268-14 14 6.268 14 14 14z\" stroke=\"#2088FF\"/></g>",
|
||
...rank(value, [1, 200, 500, 1000]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Manager
|
||
{
|
||
const value = user.projects.totalCount
|
||
const unlock = user.projects.nodes?.shift()
|
||
|
||
list.push({
|
||
title:"Manager",
|
||
text:`Created ${value} user project${imports.s(value)}`,
|
||
icon:"<g stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><path d=\"M29 16V8.867C29 7.705 29.627 7 30.692 7h18.616C50.373 7 51 7.705 51 8.867v38.266C51 48.295 50.373 49 49.308 49H30.692C29.627 49 29 48.295 29 47.133V39m-4-23V9c0-1.253-.737-2-2-2H7c-1.263 0-2 .747-2 2v34c0 1.253.737 2 2 2h16c1.263 0 2-.747 2-2v-4\" stroke=\"#79B8FF\" stroke-linecap=\"round\"/><path stroke=\"#79B8FF\" d=\"M51.557 12.005h-22M5 12.005h21\"/><path d=\"M14 33V22c0-1.246.649-2 1.73-2h28.54c1.081 0 1.73.754 1.73 2v11c0 1.246-.649 2-1.73 2H15.73c-1.081 0-1.73-.754-1.73-2z\" stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M19 29v-3c0-.508.492-1 1-1h3c.508 0 1 .492 1 1v3c0 .508-.492 1-1 1h-3c-.508-.082-1-.492-1-1z\" stroke=\"#2088FF\"/><path stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M28.996 27.998h12M9.065 20.04a7.062 7.062 0 00-.023 1.728m.775 2.517c.264.495.584.954.954 1.369\"/></g>",
|
||
...rank(value, [1, 2, 3, 4]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Reviewer
|
||
{
|
||
const value = user.contributionsCollection.pullRequestReviewContributions.totalCount
|
||
const unlock = user.contributionsCollection.pullRequestReviewContributions.nodes?.shift()
|
||
|
||
list.push({
|
||
title:"Reviewer",
|
||
text:`Reviewed ${value} pull request${imports.s(value)}`,
|
||
icon:"<g stroke-linecap=\"round\" stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><g stroke=\"#79B8FF\"><path d=\"M26.009 34.01c.444-.004.9.141 1.228.414.473.394.766.959.76 1.54-.01.735-.333 1.413-.97 2.037.66.718.985 1.4.976 2.048-.012.828-.574 1.58-1.687 2.258.624.788.822 1.549.596 2.28-.225.733-.789 1.219-1.69 1.459.703.833.976 1.585.82 2.256-.178.763-.313 1.716-2.492 1.711\" stroke-linejoin=\"round\"/><g stroke-linejoin=\"round\"><path d=\"M18.548 28.422c1.184-4.303-2.132-5.292-2.132-5.292-.873 2.296-1.438 3.825-4.231 8.108-1.285 1.97-1.926 3.957-1.877 5.796M18.391 34.011L24.993 34c2.412-.009.211-.005-6.602.012zM5.004 37.017l5.234-.014-5.234.014z\"/></g><g stroke-linejoin=\"round\"><path d=\"M18.548 28.422c1.184-4.303-2.132-5.292-2.132-5.292-.873 2.296-1.438 3.825-4.231 8.108-1.285 1.97-1.926 3.957-1.877 5.796M5.004 37.017l5.234-.014-5.234.014zM7 48.012h4.01c1.352 1.333 2.672 2 3.961 2.001 0 0 .485-.005 5.46-.005h3.536\"/></g><path d=\"M18.793 27.022c-.062.933-.373 2.082-.933 3.446-.561 1.364-.433 2.547.383 3.547\"/></g><path d=\"M45 16.156V23a2 2 0 01-2 2H31l-6 4v-4h-1.934M12 23V8a2 2 0 012-2h29a2 2 0 012 2v10\" stroke=\"#2088FF\" stroke-linejoin=\"round\"/><path stroke=\"#2088FF\" stroke-linejoin=\"round\" d=\"M23 12.014l-3 3 3 3M34 12.014l3 3-3 3\"/><path stroke=\"#2088FF\" d=\"M30.029 10l-3.015 10.027\"/><path d=\"M32 39h3l6 4v-4h8a2 2 0 002-2V22a2 2 0 00-2-2h.138\" stroke=\"#79B8FF\" stroke-linejoin=\"round\"/><path stroke=\"#2088FF\" stroke-linejoin=\"round\" d=\"M33 29h12M33 34h6M43 34h2\"/></g>",
|
||
...rank(value, [1, 200, 500, 1000]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Packager
|
||
{
|
||
const value = user.packages.totalCount
|
||
const unlock = user.packages.nodes?.shift()
|
||
|
||
list.push({
|
||
title:"Packager",
|
||
text:`Created ${value} package${imports.s(value)}`,
|
||
icon:"<g fill=\"none\"><path fill=\"#79B8FF\" d=\"M28.53 27.64l-11.2 6.49V21.15l11.23-6.48z\"/><path d=\"M40.4 34.84c-.17 0-.34-.04-.5-.13l-11.24-6.44a.99.99 0 01-.37-1.36.99.99 0 011.36-.37l11.24 6.44c.48.27.65.89.37 1.36-.17.32-.51.5-.86.5z\" fill=\"#2088FF\"/><path d=\"M29.16 28.4c-.56 0-1-.45-1-1.01l.08-12.47c0-.55.49-1 1.01-.99.55 0 1 .45.99 1.01l-.08 12.47c0 .55-.45.99-1 .99z\" fill=\"#2088FF\"/><path d=\"M18.25 34.65a.996.996 0 01-.5-1.86l10.91-6.25a.997.997 0 11.99 1.73l-10.91 6.25c-.15.09-.32.13-.49.13z\" fill=\"#2088FF\"/><path d=\"M29.19 41.37c-.17 0-.35-.04-.5-.13l-11.23-6.49c-.31-.18-.5-.51-.5-.87V20.91c0-.36.19-.69.5-.87l11.23-6.49c.31-.18.69-.18 1 0l11.23 6.49c.31.18.5.51.5.87v12.97c0 .36-.19.69-.5.87l-11.23 6.49c-.15.08-.32.13-.5.13zm-10.23-8.06l10.23 5.91 10.23-5.91V21.49l-10.23-5.91-10.23 5.91v11.82zM40.5 11.02c-1.75 0-3.18-1.43-3.18-3.18 0-1.75 1.43-3.18 3.18-3.18 1.75 0 3.18 1.43 3.18 3.18 0 1.75-1.43 3.18-3.18 3.18zm0-4.36c-.65 0-1.18.53-1.18 1.18 0 .65.53 1.18 1.18 1.18.65 0 1.18-.53 1.18-1.18 0-.65-.53-1.18-1.18-1.18zm-23.19 4.36c-1.75 0-3.18-1.43-3.18-3.18 0-1.75 1.43-3.18 3.18-3.18 1.75 0 3.18 1.43 3.18 3.18 0 1.75-1.42 3.18-3.18 3.18zm0-4.36c-.65 0-1.18.53-1.18 1.18 0 .65.53 1.18 1.18 1.18.65 0 1.18-.53 1.18-1.18 0-.65-.53-1.18-1.18-1.18zm23.37 43.8c-1.75 0-3.18-1.43-3.18-3.18 0-1.75 1.43-3.18 3.18-3.18 1.75 0 3.18 1.43 3.18 3.18 0 1.75-1.42 3.18-3.18 3.18zm0-4.35c-.65 0-1.18.53-1.18 1.18 0 .65.53 1.18 1.18 1.18.65 0 1.18-.53 1.18-1.18 0-.65-.53-1.18-1.18-1.18zm-23.06 4.11c-1.75 0-3.18-1.43-3.18-3.18 0-1.75 1.43-3.18 3.18-3.18 1.75 0 3.18 1.43 3.18 3.18 0 1.75-1.43 3.18-3.18 3.18zm0-4.36c-.65 0-1.18.53-1.18 1.18 0 .65.53 1.18 1.18 1.18.65 0 1.18-.53 1.18-1.18 0-.65-.53-1.18-1.18-1.18zM6.18 30.72C4.43 30.72 3 29.29 3 27.54c0-1.75 1.43-3.18 3.18-3.18 1.75 0 3.18 1.43 3.18 3.18 0 1.75-1.43 3.18-3.18 3.18zm0-4.36c-.65 0-1.18.53-1.18 1.18 0 .65.53 1.18 1.18 1.18.65 0 1.18-.53 1.18-1.18 0-.65-.53-1.18-1.18-1.18zm45.64 4.36c-1.75 0-3.18-1.43-3.18-3.18 0-1.75 1.43-3.18 3.18-3.18 1.75 0 3.18 1.43 3.18 3.18 0 1.75-1.43 3.18-3.18 3.18zm0-4.36c-.65 0-1.18.53-1.18 1.18 0 .65.53 1.18 1.18 1.18.65 0 1.18-.53 1.18-1.18 0-.65-.53-1.18-1.18-1.18z\" fill=\"#2088FF\"/><path d=\"M29.1 10.21c-.55 0-1-.45-1-1V3.52c0-.55.45-1 1-1s1 .45 1 1v5.69c0 .56-.45 1-1 1zM7.44 20.95c-.73 0-1.32-.59-1.32-1.32v-5.38l4.66-2.69c.63-.37 1.44-.15 1.8.48.36.63.15 1.44-.48 1.8l-3.34 1.93v3.86c0 .73-.59 1.32-1.32 1.32zm4 22.68c-.22 0-.45-.06-.66-.18l-4.66-2.69v-5.38c0-.73.59-1.32 1.32-1.32.73 0 1.32.59 1.32 1.32v3.86l3.34 1.93c.63.36.85 1.17.48 1.8-.24.42-.68.66-1.14.66zm17.64 10.39l-4.66-2.69c-.63-.36-.85-1.17-.48-1.8.36-.63 1.17-.85 1.8-.48l3.34 1.93 3.34-1.93a1.32 1.32 0 011.8.48c.36.63.15 1.44-.48 1.8l-4.66 2.69zm17.64-10.39a1.32 1.32 0 01-.66-2.46l3.34-1.93v-3.86c0-.73.59-1.32 1.32-1.32.73 0 1.32.59 1.32 1.32v5.38l-4.66 2.69c-.21.12-.44.18-.66.18zm4-22.68c-.73 0-1.32-.59-1.32-1.32v-3.86l-3.34-1.93c-.63-.36-.85-1.17-.48-1.8.36-.63 1.17-.85 1.8-.48l4.66 2.69v5.38c0 .73-.59 1.32-1.32 1.32z\" fill=\"#79B8FF\"/><path d=\"M33.08 6.15c-.22 0-.45-.06-.66-.18l-3.34-1.93-3.34 1.93c-.63.36-1.44.15-1.8-.48a1.32 1.32 0 01.48-1.8L29.08 1l4.66 2.69c.63.36.85 1.17.48 1.8a1.3 1.3 0 01-1.14.66zm-3.99 47.3c-.55 0-1-.45-1-1v-7.13c0-.55.45-1 1-1s1 .45 1 1v7.13c0 .55-.44 1-1 1zM13.86 19.71c-.17 0-.34-.04-.5-.13L7.2 16a1 1 0 011-1.73l6.17 3.58c.48.28.64.89.36 1.37-.19.31-.52.49-.87.49zm36.63 21.23c-.17 0-.34-.04-.5-.13l-6.17-3.57a.998.998 0 01-.36-1.37c.28-.48.89-.64 1.37-.36L51 39.08c.48.28.64.89.36 1.37-.19.31-.52.49-.87.49zM44.06 19.8c-.35 0-.68-.18-.87-.5-.28-.48-.11-1.09.36-1.37l6.17-3.57c.48-.28 1.09-.11 1.37.36.28.48.11 1.09-.36 1.37l-6.17 3.57c-.16.1-.33.14-.5.14zM7.43 41.03c-.35 0-.68-.18-.87-.5-.28-.48-.11-1.09.36-1.37l6.17-3.57c.48-.28 1.09-.11 1.37.36.28.48.11 1.09-.36 1.37l-6.17 3.57c-.15.09-.33.14-.5.14z\" fill=\"#79B8FF\"/></g>",
|
||
...rank(value, [1, 5, 10, 20]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Scripter
|
||
{
|
||
const value = user.gists.totalCount
|
||
const unlock = user.gists.nodes?.shift()
|
||
|
||
list.push({
|
||
title:"Scripter",
|
||
text:`Published ${value} gist${imports.s(value)}`,
|
||
icon:"<g stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><path d=\"M20 48.875v-12.75c0-1.33.773-2.131 2.385-2.125h26.23c1.612-.006 2.385.795 2.385 2.125v12.75C51 50.198 50.227 51 48.615 51h-26.23C20.773 51 20 50.198 20 48.875zM37 40.505h9M37 44.492h6\" stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path stroke=\"#79B8FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M14 30h-4M16 35h-3M47 10H5M42 15H24M19 15h-9M16 25h-3M42 20h-2M42 20h-2M42 25h-2M16 20h-3\"/><path stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M31.974 25H24\"/><path d=\"M22 20h12a2 2 0 012 2v6a2 2 0 01-2 2H22a2 2 0 01-2-2v-6a2 2 0 012-2z\" stroke=\"#2088FF\"/><path d=\"M5 33V7a2 2 0 012-2h38a2 2 0 012 2v23\" stroke=\"#79B8FF\" stroke-linecap=\"round\"/><path d=\"M5 30v8c0 1.105.892 2 1.993 2H16\" stroke=\"#79B8FF\" stroke-linecap=\"round\"/><g stroke=\"#2088FF\" stroke-linecap=\"round\"><path d=\"M26.432 37.933v7.07M26.432 37.933v9.07M24.432 40.433h7.07M24.432 40.433h8.07M24.432 44.433h7.07M24.432 44.433h8.07M30.432 37.933v9.07\"/></g></g>",
|
||
...rank(value, [1, 20, 50, 100]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Worker
|
||
{
|
||
const value = user.organizations.totalCount
|
||
const unlock = user.organizations.nodes?.shift()
|
||
|
||
list.push({
|
||
title:"Worker",
|
||
text:`Joined ${value} organization${imports.s(value)}`,
|
||
icon:"<g stroke-linecap=\"round\" stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><g stroke=\"#79B8FF\" stroke-linejoin=\"round\"><path d=\"M30 51H16.543v-2.998h-4v2.976l-5.537.016a2 2 0 01-2.006-2v-8.032a2 2 0 01.75-1.562l9.261-7.406 5.984 5.143m29.992 3.864v10h-6v-3h-5v3h-6m-.987-33c.133-1.116.793-2.106 1.978-2.968.44-.32 5.776-3.664 16.01-10.032v36\"/><path d=\"M19 34.994v-8.982m16 0V49a2 2 0 01-2 2h-8.987l.011-6.957\"/></g><path stroke=\"#79B8FF\" d=\"M40 38h5M40 34h5\"/><path stroke=\"#2088FF\" d=\"M25 30h5M25 34h5M25 26h5\"/><path d=\"M35.012 22.003H9.855a4.843 4.843 0 010-9.686h1.479c1.473-4.268 4.277-6.674 8.41-7.219 6.493-.856 9.767 4.27 10.396 5.9.734-.83 2.137-2.208 4.194-1.964a4.394 4.394 0 011.685.533\" stroke=\"#2088FF\" stroke-linejoin=\"round\"/></g>",
|
||
...rank(value, [1, 2, 3, 4]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Stargazer
|
||
{
|
||
const value = user.starredRepositories.totalCount
|
||
const unlock = user.starredRepositories.nodes?.shift()
|
||
|
||
list.push({
|
||
title:"Stargazer",
|
||
text:`Starred ${value} repositor${imports.s(value, "y")}`,
|
||
icon:"<g stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><path stroke=\"#2088FF\" d=\"M28.017 5v3M36.006 7.013l-1.987 2.024M20.021 7.011l1.988 2.011M28.806 30.23c-2.206-3.88-5.25-2.234-5.25-2.234 1.007 2.24 1.688 3.72 2.742 8.724.957 4.551 3.785 7.409 7.687 7.293l5.028 6.003M29.03 34.057L29 20.007m4.012 9.004V17.005m4.006 11.99l-.003-9.353\"/><path d=\"M18.993 50.038l4.045-5.993s1.03-.262 1.954-.984m-6.983.96c-4.474-.016-6.986-5.558-6.986-9.979 0-1.764-.439-4.997-1.997-8.004 0 0 3.268-1.24 5.747 3.6.904 1.768.458 5.267.642 5.388.185.121 1.336.554 2.637 2.01m4.955-18.92a976.92 976.92 0 010 5.91m-7.995-4.986l-.003 10.97M10.031 48.021l2.369-3.003\" stroke=\"#79B8FF\"/><path d=\"M45.996 47.026l-1.99-2.497-1.993-2.5s2.995-1.485 2.995-6.46V24.033\" stroke=\"#2088FF\"/><path d=\"M41 29v-6a2 2 0 114 0v2m-8-4v-4a2 2 0 114 0v7m-8-7v-2a2 2 0 114 0v2m-8 4v-2a2 2 0 114 0v2\" stroke=\"#2088FF\"/><path d=\"M23 20v-2a2 2 0 013.043-1.707M19 19v-4a2 2 0 114 0v3m-8 3v-2a2 2 0 114 0v10\" stroke=\"#79B8FF\"/><path d=\"M6.7 12c.316 1.122.572 1.372 1.71 1.678-1.136.314-1.39.566-1.7 1.69-.316-1.121-.572-1.372-1.71-1.678 1.135-.314 1.389-.567 1.7-1.69zm42 0c.316 1.122.572 1.372 1.71 1.678-1.136.314-1.39.566-1.7 1.69-.317-1.121-.573-1.372-1.71-1.679 1.135-.313 1.389-.566 1.7-1.689zM28.021 47.627c.317 1.122.573 1.372 1.71 1.678-1.135.314-1.389.566-1.699 1.69-.318-1.121-.573-1.372-1.71-1.679 1.134-.313 1.389-.566 1.699-1.689z\" stroke=\"#2088FF\"/></g>",
|
||
...rank(value, [1, 200, 500, 1000]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Follower
|
||
{
|
||
const value = user.following.totalCount
|
||
const unlock = user.following.nodes?.shift()
|
||
|
||
list.push({
|
||
title:"Follower",
|
||
text:`Following ${value} user${imports.s(value)}`,
|
||
icon:"<g fill=\"none\" fill-rule=\"evenodd\"><path d=\"M35 31a7 7 0 1114 0 7 7 0 01-14 0zm12-13a3 3 0 116 0 3 3 0 01-6 0zM33 49a3 3 0 116 0 3 3 0 01-6 0zM4 15a3 3 0 116 0 3 3 0 01-6 0zm37-8.5a2.5 2.5 0 115 0 2.5 2.5 0 01-5 0zM10 14l4.029-.576M19.008 26.016L21 19M29.019 34.001l5.967-1.948M36.997 46.003l2.977-8.02M46.05 24.031L48 21M28.787 18.012l7.248 8.009\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M43.62 29.004c-1.157 0-1.437.676-1.62 1.173-.19-.498-.494-1.167-1.629-1.167-.909 0-1.355.777-1.371 1.632-.022 1.145 1.309 2.365 3 3.358 1.669-.983 3-2.23 3-3.358 0-.89-.54-1.638-1.38-1.638z\" fill=\"#2088FF\"/><path stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M48.043 15.003L45 9\"/><path d=\"M21 12a3 3 0 116 0 3 3 0 01-6 0zM27 12h3M18 12h3M21 43c-.267-1.727-1.973-3-4-3-2.08 0-3.787 1.318-4 3m4-9a3 3 0 100 6 3 3 0 000-6z\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M17 30a9 9 0 110 18 9 9 0 110-18z\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></g>",
|
||
...rank(value, [1, 200, 500, 1000]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Influencer
|
||
{
|
||
const value = user.followers.totalCount
|
||
const unlock = user.followers.nodes?.shift()
|
||
|
||
list.push({
|
||
title:"Influencer",
|
||
text:`Followed by ${value} user${imports.s(value)}`,
|
||
icon:"<g transform=\"translate(4 4)\" stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><path d=\"M33.432 1.924A23.922 23.922 0 0024 0c-3.945 0-7.668.952-10.95 2.638m-9.86 9.398A23.89 23.89 0 000 24a23.9 23.9 0 002.274 10.21m3.45 5.347a23.992 23.992 0 0012.929 7.845m13.048-.664c4.43-1.5 8.28-4.258 11.123-7.848m3.16-5.245A23.918 23.918 0 0048 24c0-1.87-.214-3.691-.619-5.439M40.416 6.493a24.139 24.139 0 00-1.574-1.355\" stroke=\"#79B8FF\" stroke-linecap=\"round\"/><path stroke=\"#79B8FF\" d=\"M4.582 33.859l1.613-7.946\"/><circle stroke=\"#79B8FF\" cx=\"6.832\" cy=\"23\" r=\"3\"/><path stroke=\"#2088FF\" d=\"M17.444 39.854l4.75 3.275\"/><path stroke=\"#79B8FF\" stroke-linecap=\"round\" d=\"M7.647 14.952l-.433 4.527\"/><circle stroke=\"#2088FF\" cx=\"15\" cy=\"38\" r=\"3\"/><path stroke=\"#2088FF\" d=\"M22.216 9.516l.455 4.342\"/><path stroke=\"#79B8FF\" stroke-linecap=\"round\" d=\"M34.272 6.952l-2.828 5.25\"/><path stroke=\"#2088FF\" stroke-linecap=\"square\" d=\"M11.873 7.235l6.424-.736\"/><path stroke=\"#79B8FF\" stroke-linecap=\"round\" d=\"M28.811 5.445l3.718-.671\"/><path stroke=\"#2088FF\" d=\"M42.392 22.006l.456-5.763M34.349 24.426l4.374.447\"/><path d=\"M20 28c.267-1.727 1.973-3 4-3 2.08 0 3.787 1.318 4 3m-4-9a3 3 0 110 6 3 3 0 010-6z\" stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M24 14c5.523 0 10 4.477 10 10s-4.477 10-10 10-10-4.477-10-10 4.477-10 10-10z\" stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><circle stroke=\"#79B8FF\" cx=\"35.832\" cy=\"4\" r=\"3\"/><circle stroke=\"#79B8FF\" cx=\"44\" cy=\"36\" r=\"3\"/><circle stroke=\"#79B8FF\" cx=\"34.832\" cy=\"37\" r=\"3\"/><circle stroke=\"#2088FF\" cx=\"21.654\" cy=\"6.437\" r=\"3\"/><path d=\"M25.083 48.102a3 3 0 100-6 3 3 0 000 6z\" stroke=\"#2088FF\"/><path d=\"M8.832 5a3 3 0 110 6 3 3 0 010-6z\" stroke=\"#2088FF\" stroke-linecap=\"round\"/><circle stroke=\"#79B8FF\" cx=\"4\" cy=\"37\" r=\"3\"/><path d=\"M42.832 10a3 3 0 110 6 3 3 0 010-6z\" stroke=\"#2088FF\" stroke-linecap=\"round\"/><path stroke=\"#79B8FF\" stroke-linecap=\"round\" d=\"M32.313 38.851l-1.786 1.661\"/><circle stroke=\"#2088FF\" cx=\"42\" cy=\"25\" r=\"3\"/><path stroke=\"#2088FF\" stroke-linecap=\"square\" d=\"M18.228 32.388l-1.562 2.66\"/><path stroke=\"#79B8FF\" d=\"M37.831 36.739l2.951-.112\"/></g>",
|
||
...rank(value, [1, 200, 500, 1000]), value, unlock:new Date(unlock?.createdAt),
|
||
gh:Number(`1${"0".repeat(Math.ceil(Math.log10(ranks.user_rank.userCount)))}`),
|
||
})
|
||
}
|
||
|
||
//Maintainer
|
||
{
|
||
const value = user.popular.nodes?.shift()?.stargazers?.totalCount ?? 0
|
||
const unlock = null
|
||
|
||
list.push({
|
||
title:"Maintainer",
|
||
text:`Maintaining a repository with ${value} star${imports.s(value)}`,
|
||
icon:"<g transform=\"translate(4 4)\" fill=\"none\" fill-rule=\"evenodd\"><path d=\"M39 15h.96l4.038 3-.02-3H45a2 2 0 002-2V3a2 2 0 00-2-2H31a2 2 0 00-2 2v4.035\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M36 5.014l-3 3 3 3M40 5.014l3 3-3 3\"/><path d=\"M6 37a1 1 0 110 2 1 1 0 010-2m7 0a1 1 0 110 2 1 1 0 010-2m-2.448 1a1 1 0 11-2 0 1 1 0 012 0z\" fill=\"#2088FF\"/><path d=\"M1.724 15.05A23.934 23.934 0 000 24c0 .686.029 1.366.085 2.037m19.92 21.632c1.3.218 2.634.331 3.995.331a23.92 23.92 0 009.036-1.76m13.207-13.21A23.932 23.932 0 0048 24c0-1.363-.114-2.7-.332-4M25.064.022a23.932 23.932 0 00-10.073 1.725\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\"/><path d=\"M19 42.062V43a2 2 0 01-2 2H9.04l-4.038 3 .02-3H3a2 2 0 01-2-2V33a2 2 0 012-2h4.045\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M6 0a6 6 0 110 12A6 6 0 016 0z\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" d=\"M6 3v6M3 6h6\"/><path d=\"M42 36a6 6 0 110 12 6 6 0 010-12z\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M44.338 40.663l-3.336 3.331-1.692-1.686M31 31c-.716-2.865-3.578-5-7-5-3.423 0-6.287 2.14-7 5\"/><path d=\"M24 16a5 5 0 110 10 5 5 0 010-10z\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\"/><circle stroke=\"#2088FF\" stroke-width=\"2\" cx=\"24\" cy=\"24\" r=\"14\"/></g>",
|
||
...rank(value, [1, 1000, 5000, 10000]), value, unlock:new Date(unlock?.createdAt),
|
||
gh:Number(`1${"0".repeat(Math.ceil(Math.log10(ranks.repo_rank.repositoryCount)))}`),
|
||
})
|
||
}
|
||
|
||
//Polyglot
|
||
{
|
||
const value = new Set(data.user.repositories.nodes.flatMap(repository => repository.languages.edges.map(({node:{name}}) => name))).size
|
||
const unlock = null
|
||
|
||
list.push({
|
||
title:"Polyglot",
|
||
text:`Using ${value} different programming language${imports.s(value)}`,
|
||
icon:"<g stroke-linecap=\"round\" stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><path d=\"M17.135 7.988l-3.303.669a2 2 0 00-1.586 2.223l4.708 35.392a1.498 1.498 0 01-1.162 1.66 1.523 1.523 0 01-1.775-1.01L4.951 19.497a2 2 0 011.215-2.507l2.946-1.072\" stroke=\"#79B8FF\" stroke-linejoin=\"round\"/><path d=\"M36.8 48H23a2 2 0 01-2-2V7a2 2 0 012-2h26a2 2 0 012 2v32.766\" stroke=\"#2088FF\"/><path d=\"M29 20.955l-3.399 3.399a.85.85 0 000 1.202l3.399 3.4M43.014 20.955l3.399 3.399a.85.85 0 010 1.202l-3.4 3.4\" stroke=\"#2088FF\" stroke-linejoin=\"round\"/><path stroke=\"#2088FF\" d=\"M38.526 18l-5.053 14.016\"/><path d=\"M44 36a8 8 0 110 16 8 8 0 010-16z\" stroke=\"#2088FF\" stroke-linejoin=\"round\"/><path d=\"M43.068 40.749l3.846 2.396a1 1 0 01-.006 1.7l-3.846 2.36a1 1 0 01-1.523-.853v-4.755a1 1 0 011.529-.848z\" stroke=\"#2088FF\" stroke-linejoin=\"round\"/></g>",
|
||
...rank(value, [1, 4, 8, 16]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Member
|
||
{
|
||
const value = computed.registered.diff
|
||
const unlock = null
|
||
|
||
list.push({
|
||
title:"Member",
|
||
text:`Registered ${Math.floor(value)} year${imports.s(Math.floor(value))} ago`,
|
||
icon:"<g xmlns=\"http://www.w3.org/2000/svg\" transform=\"translate(5 4)\" fill=\"none\" fill-rule=\"evenodd\"><path d=\"M46 44.557v1a2 2 0 01-2 2H2a2 2 0 01-2-2v-1\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M.75 40.993l.701.561a2.323 2.323 0 002.903 0l1.675-1.34a3 3 0 013.748 0l1.282 1.026a3 3 0 003.71.03l1.4-1.085a3 3 0 013.75.061l1.103.913a3 3 0 003.787.031l1.22-.976a3 3 0 013.748 0l1.282 1.026a3 3 0 003.71.03l1.4-1.085a3 3 0 013.75.061l1.429 1.182a2.427 2.427 0 003.103-.008l.832-.695A2 2 0 0046 39.191v-1.634a2 2 0 00-2-2H2a2 2 0 00-2 2v1.875a2 2 0 00.75 1.561z\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M42 31.609v.948m-38 0v-.992m25.04-15.008H35a2 2 0 012 2v1m-28 0v-1a2 2 0 012-2h6.007\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M22 8.557h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6a1 1 0 011-1z\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linejoin=\"round\"/><path d=\"M4.7 10.557c.316 1.122.572 1.372 1.71 1.678-1.136.314-1.39.566-1.7 1.69-.317-1.121-.573-1.372-1.71-1.679 1.135-.313 1.389-.566 1.7-1.689zm35-8c.316 1.122.572 1.372 1.71 1.678-1.136.314-1.39.566-1.7 1.69-.317-1.121-.573-1.372-1.71-1.679 1.135-.313 1.389-.566 1.7-1.689z\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M23 5.557a2 2 0 002-2C25 2.452 24.433 0 22.273 0c-.463 0 .21 1.424-.502 1.979A2 2 0 0023 5.557z\" stroke=\"#2088FF\" stroke-width=\"2\"/><path d=\"M4.78 27.982l1.346 1.076a3 3 0 003.748 0l1.252-1.002a3 3 0 013.748 0l1.282 1.026a3 3 0 003.711.03l1.4-1.085a3 3 0 013.75.061l1.102.913a3 3 0 003.787.031l1.22-.976a3 3 0 013.748 0l1.281 1.025a3 3 0 003.712.029l1.358-1.053a2 2 0 00.775-1.58v-.97a1.95 1.95 0 00-1.95-1.95H5.942a1.912 1.912 0 00-1.912 1.912v.951a2 2 0 00.75 1.562z\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><circle stroke=\"#79B8FF\" cx=\"16.5\" cy=\"2.057\" r=\"1\"/><circle stroke=\"#79B8FF\" cx=\"14.5\" cy=\"12.057\" r=\"1\"/><circle stroke=\"#79B8FF\" cx=\"31.5\" cy=\"9.057\" r=\"1\"/></g>",
|
||
...rank(value, [1, 3, 5, 10]), value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Verified
|
||
{
|
||
const value = !/This user hasn't uploaded any GPG keys/i.test((await imports.axios.get(`https://github.com/${login}.gpg`)).data)
|
||
const unlock = null
|
||
|
||
list.push({
|
||
title:"Verified",
|
||
text:"Registered a GPG key to sign commits",
|
||
icon:"<g stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><path d=\"M46 17.036v13.016c0 4.014-.587 8.94-4.751 13.67-5.787 5.911-12.816 8.279-13.243 8.283-.426.003-7.91-2.639-13.222-8.283C10.718 39.4 10 34.056 10 30.052V17.036a2 2 0 012-2h32a2 2 0 012 2zM16 15c0-6.616 5.384-12 12-12s12 5.384 12 12\" stroke=\"#79B8FF\"/><path d=\"M21 15c0-3.744 3.141-7 7-7 3.86 0 7 3.256 7 7m4.703 29.63l-3.672-3.647m-17.99-17.869l-7.127-7.081\" stroke=\"#79B8FF\"/><path d=\"M28 23a8 8 0 110 16 8 8 0 010-16z\" stroke=\"#2088FF\"/><path stroke=\"#2088FF\" d=\"M30.966 29.005l-4 3.994-2.002-1.995\"/></g>",
|
||
rank:value ? "$" : "X", progress:1, value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Explorer
|
||
{
|
||
const value = !/doesn’t have any starred topics yet/i.test((await imports.axios.get(`https://github.com/stars/${login}/topics`)).data)
|
||
const unlock = null
|
||
|
||
list.push({
|
||
title:"Explorer",
|
||
text:"Starred a topic on GitHub Explore",
|
||
icon:"<g transform=\"translate(3 4)\" fill=\"none\" fill-rule=\"evenodd\"><path d=\"M10 37.5l.049.073a2 2 0 002.506.705l24.391-11.324a2 2 0 00.854-2.874l-2.668-4.27a2 2 0 00-2.865-.562L10.463 34.947A1.869 1.869 0 0010 37.5zM33.028 28.592l-4.033-6.58\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path stroke=\"#2088FF\" stroke-width=\"2\" stroke-linejoin=\"round\" d=\"M15.52 37.004l-2.499-3.979\"/><path stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M25.008 48.011l.013-15.002M17.984 47.038l6.996-14.035M32.005 47.029l-6.987-14.016\"/><path d=\"M2.032 17.015A23.999 23.999 0 001 24c0 9.3 5.29 17.365 13.025 21.35m22-.027C43.734 41.33 49 33.28 49 24a24 24 0 00-1.025-6.96M34.022 1.754A23.932 23.932 0 0025 0c-2.429 0-4.774.36-6.983 1.032\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M40.64 8.472c-1.102-2.224-.935-4.764 1.382-6.465-.922-.087-2.209.326-3.004.784a6.024 6.024 0 00-2.674 7.229c.94 2.618 3.982 4.864 7.66 3.64 1.292-.429 2.615-1.508 2.996-2.665-1.8.625-5.258-.3-6.36-2.523zM21.013 6.015c-.22-.802-3.018-1.295-4.998-.919M4.998 8.006C2.25 9.22.808 11.146 1.011 12.009\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><circle stroke=\"#79B8FF\" stroke-width=\"2\" cx=\"11\" cy=\"9\" r=\"6\"/><path d=\"M.994 12.022c.351 1.38 5.069 1.25 10.713-.355 5.644-1.603 9.654-4.273 9.303-5.653\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M26.978 10.105c.318 1.123.573 1.373 1.71 1.679-1.135.314-1.388.566-1.698 1.69-.318-1.122-.573-1.373-1.711-1.679 1.135-.314 1.39-.566 1.7-1.69\" fill=\"#79B8FF\"/><path d=\"M26.978 10.105c.318 1.123.573 1.373 1.71 1.679-1.135.314-1.388.566-1.698 1.69-.318-1.122-.573-1.373-1.711-1.679 1.135-.314 1.39-.566 1.7-1.69z\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M9.929 22.737c.317 1.121.573 1.372 1.71 1.678-1.135.314-1.389.566-1.699 1.69-.318-1.121-.573-1.372-1.71-1.679 1.134-.313 1.389-.566 1.699-1.69\" fill=\"#79B8FF\"/><path d=\"M9.929 22.737c.317 1.121.573 1.372 1.71 1.678-1.135.314-1.389.566-1.699 1.69-.318-1.121-.573-1.372-1.71-1.679 1.134-.313 1.389-.566 1.699-1.69z\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M38.912 33.684c.318 1.122.573 1.373 1.711 1.679-1.136.313-1.39.565-1.7 1.69-.317-1.123-.573-1.372-1.71-1.68 1.136-.313 1.389-.565 1.7-1.689\" fill=\"#79B8FF\"/><path d=\"M38.912 33.684c.318 1.122.573 1.373 1.711 1.679-1.136.313-1.39.565-1.7 1.69-.317-1.123-.573-1.372-1.71-1.68 1.136-.313 1.389-.565 1.7-1.689z\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></g>",
|
||
rank:value ? "$" : "X", progress:1, value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Automater
|
||
{
|
||
const value = process.env.GITHUB_ACTIONS
|
||
const unlock = null
|
||
|
||
list.push({
|
||
title:"Automater",
|
||
text:"Use GitHub Actions to automate profile updates",
|
||
icon:"<g transform=\"translate(4 5)\" stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><g stroke-linecap=\"round\" stroke-linejoin=\"round\"><path stroke=\"#2088FF\" d=\"M26.478 22l.696 2.087 3.478.696v2.782l-3.478 1.392-.696 1.39 1.392 3.48-1.392 1.39L23 33.827l-1.391.695L20.217 38h-2.782l-1.392-3.478-1.39-.696-3.48 1.391-1.39-1.39 1.39-3.48-.695-1.39L7 27.565v-2.782l3.478-1.392.696-1.391-1.391-3.478 1.39-1.392 3.48 1.392 1.39-.696 1.392-3.478h2.782l1.392 3.478 1.391.696 3.478-1.392 1.392 1.392z\"/><path stroke=\"#79B8FF\" d=\"M24.779 12.899l-1.475-2.212 1.475-1.475 2.95 1.475 1.474-.738.737-2.934h2.212l.737 2.934 1.475.738 2.95-1.475 1.474 1.475-1.475 2.949.738 1.475 2.949.737v2.212l-2.95.737-.737 1.475 1.475 2.949-1.475 1.475-2.949-1.475\"/></g><path stroke=\"#2088FF\" stroke-linecap=\"round\" d=\"M5.932 5.546l7.082 6.931\"/><path stroke=\"#79B8FF\" stroke-linecap=\"round\" d=\"M32.959 31.99l8.728 8.532\"/><circle stroke=\"#79B8FF\" cx=\"44\" cy=\"43\" r=\"3\"/><circle stroke=\"#2088FF\" cx=\"13\" cy=\"2\" r=\"2\"/><circle stroke=\"#79B8FF\" cx=\"35\" cy=\"44\" r=\"2\"/><circle stroke=\"#79B8FF\" cx=\"3\" cy=\"12\" r=\"2\"/><circle stroke=\"#2088FF\" cx=\"45\" cy=\"34\" r=\"2\"/><path d=\"M3.832 0a3 3 0 110 6 3 3 0 010-6zM8.04 10.613l2.1-.613M10.334 9.758l1.914-5.669\" stroke=\"#2088FF\" stroke-linecap=\"round\"/><path stroke=\"#79B8FF\" stroke-linecap=\"round\" d=\"M40.026 35.91l-2.025.591M35.695 41.965l1.843-5.326\"/><path d=\"M16 2h23.038a6 6 0 016 6v24.033\" stroke=\"#2088FF\" stroke-linecap=\"round\"/><path d=\"M32.038 44.033H9a6 6 0 01-6-6V14\" stroke=\"#79B8FF\" stroke-linecap=\"round\"/><path d=\"M17.533 22.154l5.113 3.22a1 1 0 01-.006 1.697l-5.113 3.17a1 1 0 01-1.527-.85V23a1 1 0 011.533-.846zm11.58-7.134v-.504a1 1 0 011.53-.85l3.845 2.397a1 1 0 01-.006 1.701l-3.846 2.358\" stroke=\"#2088FF\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></g>",
|
||
rank:value ? "$" : "X", progress:1, value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Infographile
|
||
{
|
||
const {repository:{viewerHasStarred:value}, viewer:{login:_login}} = await graphql(queries.achievements.metrics())
|
||
const unlock = null
|
||
|
||
list.push({
|
||
title:"Infographile",
|
||
text:"Fervent supporter of metrics",
|
||
icon:"<g stroke-linejoin=\"round\" stroke-width=\"2\" fill=\"none\" fill-rule=\"evenodd\"><g stroke=\"#79B8FF\" stroke-linecap=\"round\"><path d=\"M22 31h20M22 36h10\"/></g><path d=\"M44.05 36.013a8 8 0 110 16 8 8 0 010-16z\" stroke=\"#2088FF\" stroke-linecap=\"round\"/><path d=\"M32 43H7c-1.228 0-2-.84-2-2V7c0-1.16.772-2 2-2h7.075M47 24.04V32\" stroke=\"#79B8FF\" stroke-linecap=\"round\"/><path stroke=\"#2088FF\" stroke-linecap=\"round\" d=\"M47.015 42.017l-4 3.994-2.001-1.995\"/><path stroke=\"#79B8FF\" d=\"M11 31h5v5h-5z\"/><path d=\"M11 14a2 2 0 012-2m28 12a2 2 0 01-2 2h-1m-5 0h-4m-6 0h-4m-5 0h-1a2 2 0 01-2-2m0-4v-2\" stroke=\"#79B8FF\" stroke-linecap=\"round\"/><path d=\"M18 18V7c0-1.246.649-2 1.73-2h28.54C49.351 5 50 5.754 50 7v11c0 1.246-.649 2-1.73 2H19.73c-1.081 0-1.73-.754-1.73-2z\" stroke=\"#2088FF\" stroke-linecap=\"round\"/><path stroke=\"#2088FF\" stroke-linecap=\"round\" d=\"M22 13h4l2-3 3 5 2-2h3.052l2.982-4 3.002 4H46\"/></g>",
|
||
rank:(value)&&(login === _login) ? "$" : "X", progress:1, value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Octonaut
|
||
{
|
||
const {user:{viewerIsFollowing:value}, viewer:{login:_login}} = await graphql(queries.achievements.octocat())
|
||
const unlock = null
|
||
|
||
list.push({
|
||
title:"Octonaut",
|
||
text:"Following octocat",
|
||
icon:"<g fill=\"none\" fill-rule=\"evenodd\"><path d=\"M14.7 8c.316 1.122.572 1.372 1.71 1.678-1.136.314-1.39.566-1.7 1.69-.317-1.121-.573-1.372-1.71-1.679 1.135-.313 1.389-.566 1.7-1.689zm26 0c.316 1.122.572 1.372 1.71 1.678-1.136.314-1.39.566-1.7 1.69-.317-1.121-.573-1.372-1.71-1.679 1.135-.313 1.389-.566 1.7-1.689zM28.021 5c.318 1.122.574 1.372 1.711 1.678-1.136.314-1.389.566-1.7 1.69-.317-1.121-.572-1.372-1.71-1.679 1.135-.313 1.39-.566 1.7-1.689z\" stroke=\"#2088FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><g transform=\"translate(4 9)\" fill-rule=\"nonzero\"><path d=\"M14.05 9.195C10.327 7.065 7.46 6 5.453 6 4.92 6 4 6.164 3.5 6.653s-.572.741-.711 1.14c-.734 2.1-1.562 6.317.078 9.286-8.767 25.38 15.513 24.92 21.207 24.92 5.695 0 29.746.456 21.037-24.908 1.112-2.2 1.404-5.119.121-9.284-.863-2.802-4.646-2.341-11.35 1.384a27.38 27.38 0 00-9.802-1.81c-3.358 0-6.701.605-10.03 1.814z\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><path d=\"M10.323 40.074c-2.442-1.02-2.93-3.308-2.93-4.834 0-1.527.488-2.45.976-3.92.489-1.47.391-2.281-.976-5.711-1.368-3.43.976-7.535 4.884-7.535 3.908 0 7.088 3.005 11.723 2.956m0 0c4.635.05 7.815-2.956 11.723-2.956 3.908 0 6.252 4.105 4.884 7.535-1.367 3.43-1.465 4.241-.976 5.71.488 1.47.976 2.394.976 3.92 0 1.527-.488 3.816-2.93 4.835\" stroke=\"#79B8FF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/><circle fill=\"#2088FF\" cx=\"12\" cy=\"30\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"13\" cy=\"28\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"15\" cy=\"28\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"23\" cy=\"35\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"25\" cy=\"35\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"17\" cy=\"28\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"31\" cy=\"28\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"33\" cy=\"28\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"35\" cy=\"28\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"12\" cy=\"32\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"19\" cy=\"30\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"19\" cy=\"32\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"29\" cy=\"30\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"29\" cy=\"32\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"36\" cy=\"30\" r=\"1\"/><circle fill=\"#2088FF\" cx=\"36\" cy=\"32\" r=\"1\"/></g></g>",
|
||
rank:(value)&&(login === _login) ? "$" : "X", progress:1, value, unlock:new Date(unlock?.createdAt),
|
||
})
|
||
}
|
||
|
||
//Results
|
||
const order = {S:5, A:4, B:3, C:2, $:1, X:0}
|
||
const achievements = list
|
||
.filter(a => (order[a.rank] >= order[threshold])||((a.rank === "$")&&(secrets)))
|
||
.filter(a => (!only.length)||((only.length)&&(only.includes(a.title.toLocaleLowerCase()))))
|
||
.filter(a => !ignored.includes(a.title.toLocaleLowerCase()))
|
||
.sort((a, b) => (order[b.rank]+b.progress*0.99) - (order[a.rank]+a.progress*0.99))
|
||
.map(({title, unlock, ...achievement}) => ({title:({S:`Master ${title.toLocaleLowerCase()}`, A:`Super ${title.toLocaleLowerCase()}`, B:`Great ${title.toLocaleLowerCase()}`}[achievement.rank] ?? title), unlock:!/invalid date/i.test(unlock) ? `${imports.date(unlock, {timeStyle:"short", timeZone:data.config.timezone?.name})} on ${imports.date(unlock, {dateStyle:"short", timeZone:data.config.timezone?.name})}` : null, ...achievement}))
|
||
.slice(0, limit || Infinity)
|
||
return {list:achievements}
|
||
}
|
||
//Handle errors
|
||
catch (error) {
|
||
throw {error:{message:"An error occured", instance:error}}
|
||
}
|
||
}
|
||
|
||
/**Rank */
|
||
function rank(x, [c, b, a, m]) {
|
||
if (x >= a)
|
||
return {rank:"A", progress:(x-a)/(m-a)}
|
||
else if (x >= b)
|
||
return {rank:"B", progress:(x-b)/(a-b)}
|
||
else if (x >= c)
|
||
return {rank:"C", progress:(x-c)/(b-c)}
|
||
return {rank:"X", progress:x/c}
|
||
} |