|
7 | 7 | return null |
8 | 8 |
|
9 | 9 | //Load inputs |
10 | | - let {ignored, skipped, colors} = imports.metadata.plugins.languages.inputs({data, account, q}) |
| 10 | + let {ignored, skipped, colors, details} = imports.metadata.plugins.languages.inputs({data, account, q}) |
11 | 11 |
|
12 | 12 | //Custom colors |
13 | 13 | const colorsets = JSON.parse(`${await imports.fs.readFile(`${imports.__module(import.meta.url)}/colorsets.json`)}`) |
|
18 | 18 |
|
19 | 19 | //Iterate through user's repositories and retrieve languages data |
20 | 20 | console.debug(`metrics/compute/${login}/plugins > languages > processing ${data.user.repositories.nodes.length} repositories`) |
21 | | - const languages = {colors:{}, total:0, stats:{}} |
| 21 | + const languages = {details, colors:{}, total:0, stats:{}} |
22 | 22 | for (const repository of data.user.repositories.nodes) { |
23 | 23 | //Skip repository if asked |
24 | 24 | if (skipped.includes(repository.name.toLocaleLowerCase())) { |
|
41 | 41 |
|
42 | 42 | //Compute languages stats |
43 | 43 | console.debug(`metrics/compute/${login}/plugins > languages > computing stats`) |
44 | | - Object.keys(languages.stats).map(name => languages.stats[name] /= languages.total) |
45 | | - languages.favorites = Object.entries(languages.stats).sort(([an, a], [bn, b]) => b - a).slice(0, 8).map(([name, value]) => ({name, value, color:languages.colors[name], x:0})) |
| 44 | + languages.favorites = Object.entries(languages.stats).sort(([an, a], [bn, b]) => b - a).slice(0, 8).map(([name, value]) => ({name, value, size:value, color:languages.colors[name], x:0})) |
| 45 | + const visible = {total:Object.values(languages.favorites).map(({size}) => size).reduce((a, b) => a + b, 0)} |
46 | 46 | for (let i = 0; i < languages.favorites.length; i++) { |
| 47 | + languages.favorites[i].value /= visible.total |
47 | 48 | languages.favorites[i].x = (languages.favorites[i-1]?.x ?? 0) + (languages.favorites[i-1]?.value ?? 0) |
48 | 49 | if ((colors[i])&&(!colors[languages.favorites[i].name.toLocaleLowerCase()])) |
49 | 50 | languages.favorites[i].color = colors[i] |
|
0 commit comments