Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugins/starlists): add ignored and aliases for starlists.languages and some fix #1224

Merged
merged 6 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Generate metrics that can be embedded everywhere, including your GitHub profile
</tr>
<tr>
<th colspan="2" align="center">
<h3><a href="/README.md#-plugins">🧩 Customizable with 42 plugins and 296 options!</a></h3>
<h3><a href="/README.md#-plugins">🧩 Customizable with 42 plugins and 298 options!</a></h3>
</th>
</tr>
<tr>
Expand Down
8 changes: 8 additions & 0 deletions action.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions source/plugins/base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ Only use this option when using a plugin that can be configured with <code>token
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>boolean</code>
<td nowrap="nowrap"><b>type:</b> <code>boolean</code>
<br>
<b>default:</b> no<br></td>
</tr>
Expand Down
11 changes: 3 additions & 8 deletions source/plugins/community/chess/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ All product and company names are trademarks™ or registered® trademarks of th
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>boolean</code>
<td nowrap="nowrap"><b>type:</b> <code>boolean</code>
<br>
<b>default:</b> no<br></td>
</tr>
Expand All @@ -52,7 +51,6 @@ All product and company names are trademarks™ or registered® trademarks of th
</tr>
<tr>
<td nowrap="nowrap">🔐 Token<br>
✨ On <code>master</code>/<code>main</code><br>
🌐 Web instances must configure <code>settings.json</code>:
<ul>
<li><i>metrics.api.chess.any</i></li>
Expand All @@ -67,7 +65,6 @@ All product and company names are trademarks™ or registered® trademarks of th
</tr>
<tr>
<td nowrap="nowrap">⏯️ Cannot be preset<br>
✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>string</code>
<br>
<b>default:</b> <code>→ User login</code><br></td>
Expand All @@ -78,8 +75,7 @@ All product and company names are trademarks™ or registered® trademarks of th
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>string</code>
<td nowrap="nowrap"><b>type:</b> <code>string</code>
<br>
<b>allowed values:</b><ul><li>lichess.org</li></ul></td>
</tr>
Expand All @@ -94,8 +90,7 @@ All product and company names are trademarks™ or registered® trademarks of th
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>json</code>
<td nowrap="nowrap"><b>type:</b> <code>json</code>
<br>
<b>default:</b> <details><summary>→ Click to expand</summary><pre language="json"><code>{
"size": 40,
Expand Down
1 change: 0 additions & 1 deletion source/plugins/habits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ All product and company names are trademarks™ or registered® trademarks of th
</tr>
<tr>
<td nowrap="nowrap">⏩ Inherits <code>repositories_skipped</code><br>
✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>array</code>
<i>(comma-separated)</i>
<br></td>
Expand Down
2 changes: 1 addition & 1 deletion source/plugins/languages/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ inputs:
Custom languages names
type: string
default: ""
example: javascript:JS typescript:TS
example: javascript:JS, typescript:TS

plugin_languages_sections:
description: |
Expand Down
13 changes: 4 additions & 9 deletions source/plugins/leetcode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ All product and company names are trademarks™ or registered® trademarks of th
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>boolean</code>
<td nowrap="nowrap"><b>type:</b> <code>boolean</code>
<br>
<b>default:</b> no<br></td>
</tr>
Expand All @@ -51,7 +50,6 @@ All product and company names are trademarks™ or registered® trademarks of th
</tr>
<tr>
<td nowrap="nowrap">⏯️ Cannot be preset<br>
✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>string</code>
<br>
<b>default:</b> <code>→ User login</code><br></td>
Expand All @@ -67,8 +65,7 @@ All product and company names are trademarks™ or registered® trademarks of th
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>array</code>
<td nowrap="nowrap"><b>type:</b> <code>array</code>
<i>(comma-separated)</i>
<br>
<b>default:</b> solved<br>
Expand All @@ -80,8 +77,7 @@ All product and company names are trademarks™ or registered® trademarks of th
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>number</code>
<td nowrap="nowrap"><b>type:</b> <code>number</code>
<i>(0 ≤
𝑥)</i>
<br>
Expand All @@ -94,8 +90,7 @@ All product and company names are trademarks™ or registered® trademarks of th
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>number</code>
<td nowrap="nowrap"><b>type:</b> <code>number</code>
<i>(1 ≤
𝑥
≤ 15)</i>
Expand Down
3 changes: 1 addition & 2 deletions source/plugins/notable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ Some repositories may not be able to reported advanced stats and in the case the
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>boolean</code>
<td nowrap="nowrap"><b>type:</b> <code>boolean</code>
<br>
<b>default:</b> no<br></td>
</tr>
Expand Down
3 changes: 1 addition & 2 deletions source/plugins/repositories/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ All product and company names are trademarks™ or registered® trademarks of th
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>boolean</code>
<td nowrap="nowrap"><b>type:</b> <code>boolean</code>
<br>
<b>default:</b> no<br></td>
</tr>
Expand Down
21 changes: 21 additions & 0 deletions source/plugins/starlists/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,27 @@ All product and company names are trademarks™ or registered® trademarks of th
<br>
<b>zero behaviour:</b> disable</br>
<b>default:</b> 8<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_starlists_languages_ignored</code></h4></td>
<td rowspan="2"><p>Ignored languages in star lists</p>
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>array</code>
<i>(comma-separated)</i>
<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_starlists_languages_aliases</code></h4></td>
<td rowspan="2"><p>Custom languages names in star lists</p>
<img width="900" height="1" alt=""></td>
</tr>
<tr>
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
<b>type:</b> <code>string</code>
<br></td>
</tr>
<tr>
<td nowrap="nowrap"><h4><code>plugin_starlists_shuffle_repositories</code></h4></td>
Expand Down
17 changes: 11 additions & 6 deletions source/plugins/starlists/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export default async function({login, q, imports, data, account}, {enabled = fal
return null

//Load inputs
let {limit, ignored, only, "limit.repositories": _limit, languages, "limit.languages": _limit_languages, "shuffle.repositories": _shuffle} = imports.metadata.plugins.starlists.inputs({data, account, q})
let {limit, ignored, only, "limit.repositories": _limit, languages, "limit.languages": _limit_languages, "languages.ignored": _languages_ignored, "languages.aliases": _languages_aliases, "shuffle.repositories": _shuffle} = imports.metadata.plugins.starlists.inputs({data, account, q})
ignored = ignored.map(imports.stripemojis)
only = only.map(imports.stripemojis)
_languages_aliases = Object.fromEntries(_languages_aliases.split(",").filter(alias => /^[\s\S]+:[\s\S]+$/.test(alias)).map(alias => alias.trim().split(":")).map(([key, value]) => [key.toLocaleLowerCase(), value]))

//Start puppeteer and navigate to star lists
console.debug(`metrics/compute/${login}/plugins > starlists > starting browser`)
Expand Down Expand Up @@ -63,7 +64,7 @@ export default async function({login, q, imports, data, account}, {enabled = fal
}))
),
)
if (await page.evaluate(() => document.querySelector(".next_page.disabled"))) {
if (!(await page.evaluate(() => document.querySelector(".next_page"))) || await page.evaluate(() => document.querySelector(".next_page.disabled"))) {
console.debug(`metrics/compute/${login}/plugins > starlists > reached last page`)
break
}
Expand All @@ -76,12 +77,16 @@ export default async function({login, q, imports, data, account}, {enabled = fal
if (languages) {
list.languages = {}
for (const {language: {name, color}} of repositories) {
if (name)
list.languages[name] = (list.languages[name] ?? 0) + 1
let lang = name
if (lang && lang.toLocaleLowerCase() in _languages_aliases) {
lang = _languages_aliases[name.toLocaleLowerCase()]
}
if (lang)
list.languages[lang] = (list.languages[lang] ?? 0) + 1
if (color)
colors[name] = color
colors[lang] = color
}
list.languages = Object.entries(list.languages).sort((a, b) => b[1] - a[1]).slice(0, _limit_languages || Infinity)
list.languages = Object.entries(list.languages).filter(([name]) => !_languages_ignored.includes(name.toLocaleLowerCase())).sort((a, b) => b[1] - a[1]).slice(0, _limit_languages || Infinity)
const visible = list.languages.map(([_, value]) => value).reduce((a, b) => a + b, 0)
list.languages = list.languages.map(([name, value]) => ({name, value, color: name in colors ? `#${colors[name]}` : null, x: 0, p: value / visible}))
for (let i = 1; i < list.languages.length; i++)
Expand Down
15 changes: 15 additions & 0 deletions source/plugins/starlists/metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ inputs:
default: 8
min: 0
zero: disable

plugin_starlists_languages_ignored:
description: |
Ignored languages in star lists
type: array
format: comma-separated
default: ""
example: html, css, ...

plugin_starlists_languages_aliases:
description: |
Custom languages names in star lists
type: string
default: ""
example: javascript:JS, typescript:TS

plugin_starlists_shuffle_repositories:
description: |
Expand Down