feat(plugins/lines): add plugin_lines_sections and new features (#1151) [skip ci]

This commit is contained in:
Simon Lecoq
2022-07-26 01:19:34 +02:00
committed by GitHub
parent ae66ccbe6b
commit c2f0cbe2b1
11 changed files with 297 additions and 21 deletions

View File

@@ -30,10 +30,12 @@ import twemojis from "twemoji-parser"
import url from "url"
import util from "util"
import xmlformat from "xml-formatter"
import * as d3 from "d3"
import D3node from "d3-node"
prism_lang()
//Exports
export { axios, emoji, fetch, fs, git, minimatch, opengraph, os, paths, processes, rss, sharp, url, util }
export { axios, d3, D3node, emoji, fetch, fs, git, minimatch, opengraph, os, paths, processes, rss, sharp, url, util }
/**Returns module __dirname */
export function __module(module) {

View File

@@ -167,8 +167,17 @@
...(set.plugins.enabled.lines
? ({
lines: {
added: `${faker.datatype.number(100)}.${faker.datatype.number(9)}k`,
deleted: `${faker.datatype.number(100)}.${faker.datatype.number(9)}k`,
added: faker.datatype.number(1000000),
deleted: faker.datatype.number(1000000),
changed: faker.datatype.number(1000000),
sections: options["lines.sections"].split(",").map(x => x.trim()),
repos: new Array(options["lines.repositories.limit"] || 4).fill(null).map(_ => ({
handle: `${faker.random.word()}/${faker.random.word()}`,
added: faker.datatype.number(10000),
deleted: faker.datatype.number(10000),
changed: faker.datatype.number(10000),
})),
history: await staticPlaceholder(set.plugins.enabled.lines, "lines.history.svg"),
},
})
: null),

View File

@@ -0,0 +1,54 @@
<svg xmlns="http://www.w3.org/2000/svg" width="480" height="315" style="filter: grayscale(0.9)">
<g transform="translate(0,276)" fill="none" font-size="10" font-family="sans-serif" text-anchor="middle">
<path class="domain" stroke="currentColor" d="M39.5,6V0.5H441.5V6"/>
<g class="tick" opacity="1" transform="translate(102.00970017636685,0)">
<line stroke="currentColor" y2="6"/>
<text fill="currentColor" y="9" dy="0.71em" transform="translate(-5,5) rotate(-45)" style="text-anchor: end; font-size: 20;">April</text>
</g>
<g class="tick" opacity="1" transform="translate(166.52821869488537,0)">
<line stroke="currentColor" y2="6"/>
<text fill="currentColor" y="9" dy="0.71em" transform="translate(-5,5) rotate(-45)" style="text-anchor: end; font-size: 20;">July</text>
</g>
<g class="tick" opacity="1" transform="translate(231.7557319223986,0)">
<line stroke="currentColor" y2="6"/>
<text fill="currentColor" y="9" dy="0.71em" transform="translate(-5,5) rotate(-45)" style="text-anchor: end; font-size: 20;">October</text>
</g>
<g class="tick" opacity="1" transform="translate(297.0127865961199,0)">
<line stroke="currentColor" y2="6"/>
<text fill="currentColor" y="9" dy="0.71em" transform="translate(-5,5) rotate(-45)" style="text-anchor: end; font-size: 20;">2022</text>
</g>
<g class="tick" opacity="1" transform="translate(360.79276895943565,0)">
<line stroke="currentColor" y2="6"/>
<text fill="currentColor" y="9" dy="0.71em" transform="translate(-5,5) rotate(-45)" style="text-anchor: end; font-size: 20;">April</text>
</g>
<g class="tick" opacity="1" transform="translate(425.3112874779542,0)">
<line stroke="currentColor" y2="6"/>
<text fill="currentColor" y="9" dy="0.71em" transform="translate(-5,5) rotate(-45)" style="text-anchor: end; font-size: 20;">July</text>
</g>
</g>
<g transform="translate(39,0)" fill="none" font-size="10" font-family="sans-serif" text-anchor="end">
<path class="domain" stroke="currentColor" d="M-6,5.5H0.5V276.5H-6"/>
<g class="tick" opacity="1" transform="translate(0,37.16858237547892)">
<line stroke="currentColor" x2="-6"/>
<text fill="currentColor" x="-9" dy="0.32em" style="font-size: 20;">400</text>
</g>
<g class="tick" opacity="1" transform="translate(0,89.08429118773948)">
<line stroke="currentColor" x2="-6"/>
<text fill="currentColor" x="-9" dy="0.32em" style="font-size: 20;">200</text>
</g>
<g class="tick" opacity="1" transform="translate(0,141)">
<line stroke="currentColor" x2="-6"/>
<text fill="currentColor" x="-9" dy="0.32em" style="font-size: 20;">0.0</text>
</g>
<g class="tick" opacity="1" transform="translate(0,192.91570881226053)">
<line stroke="currentColor" x2="-6"/>
<text fill="currentColor" x="-9" dy="0.32em" style="font-size: 20;">200</text>
</g>
<g class="tick" opacity="1" transform="translate(0,244.83141762452107)">
<line stroke="currentColor" x2="-6"/>
<text fill="currentColor" x="-9" dy="0.32em" style="font-size: 20;">400</text>
</g>
</g>
<path d="M39,140.5L43.96296296296296,140.5L48.925925925925924,140.5L53.888888888888886,140.5L58.85185185185185,140.5L63.81481481481481,140.5L68.77777777777777,140.5L73.74074074074073,140.5L78.7037037037037,140.5L83.66666666666666,140.5L88.62962962962962,140.5L93.5925925925926,140.5L98.55555555555554,140.5L103.5185185185185,140.5L108.48148148148147,140.5L113.44444444444443,140.5L118.40740740740739,140.5L123.37037037037037,140.5L128.33333333333334,140.5L133.2962962962963,140.5L138.25925925925927,140.5L143.22222222222223,140.5L148.1851851851852,140.5L153.14814814814815,140.5L158.11111111111111,140.5L163.07407407407408,140.5L168.037037037037,140.5L173,140.5L177.96296296296293,140.5L182.92592592592592,140.5L187.88888888888886,140.5L192.85185185185185,140.5L197.81481481481478,140.5L202.77777777777777,140.5L207.74074074074073,140.5L212.7037037037037,140.5L217.66666666666666,140.5L222.62962962962962,140.5L227.59259259259258,140.5L232.55555555555554,140.5L237.5185185185185,140.5L242.4814814814815,140.5L247.44444444444443,140.5L252.40740740740742,140.5L257.3703703703704,140.5L262.3333333333333,140.5L267.2962962962963,140.5L272.25925925925924,140.5L277.22222222222223,140.5L282.18518518518516,140.5L287.14814814814815,140.5L292.11111111111114,140.5L297.0740740740741,140.5L302.037037037037,140.5L307,140.5L311.962962962963,140.5L316.92592592592587,140.5L321.88888888888886,140.5L326.85185185185185,140.5L331.81481481481484,140.5L336.7777777777777,140.5L341.74074074074076,140.5L346.7037037037037,140.5L351.6666666666667,140.5L356.62962962962956,140.5L361.5925925925926,140.5L366.55555555555554,140.5L371.51851851851853,140.5L376.48148148148147,140.5L381.44444444444446,140.5L386.4074074074074,140.5L391.3703703703704,140.5L396.3333333333333,140.5L401.2962962962963,140.5L406.25925925925924,140.5L411.22222222222223,140.5L416.18518518518516,140.5L421.14814814814815,140.5L426.1111111111111,140.5L431.0740740740741,140.5L436.037037037037,140.5L441,140.5L441,139.98084291187737L436.037037037037,129.338122605364L431.0740740740741,138.16379310344828L426.1111111111111,138.4233716475096L421.14814814814815,138.4233716475096L416.18518518518516,139.98084291187737L411.22222222222223,139.46168582375478L406.25925925925924,112.46551724137932L401.2962962962963,139.98084291187737L396.3333333333333,137.904214559387L391.3703703703704,139.98084291187737L386.4074074074074,139.98084291187737L381.44444444444446,137.3850574712644L376.48148148148147,139.20210727969348L371.51851851851853,135.82758620689654L366.55555555555554,139.98084291187737L361.5925925925926,139.72126436781608L356.62962962962956,129.5977011494253L351.6666666666667,118.43582375478925L346.7037037037037,139.20210727969348L341.74074074074076,134.78927203065138L336.7777777777777,139.98084291187737L331.81481481481484,139.98084291187737L326.85185185185185,138.4233716475096L321.88888888888886,139.98084291187737L316.92592592592587,139.98084291187737L311.962962962963,139.20210727969348L307,139.98084291187737L302.037037037037,135.5680076628352L297.0740740740741,139.98084291187737L292.11111111111114,139.98084291187737L287.14814814814815,139.98084291187737L282.18518518518516,139.98084291187737L277.22222222222223,125.18486590038314L272.25925925925924,138.6829501915709L267.2962962962963,139.98084291187737L262.3333333333333,139.72126436781608L257.3703703703704,137.12547892720306L252.40740740740742,138.16379310344828L247.44444444444443,138.16379310344828L242.4814814814815,139.98084291187737L237.5185185185185,139.98084291187737L232.55555555555554,137.3850574712644L227.59259259259258,138.4233716475096L222.62962962962962,111.68678160919539L217.66666666666666,72.75L212.7037037037037,88.58429118773948L207.74074074074073,138.16379310344828L202.77777777777777,6.297892720306525L197.81481481481478,139.98084291187737L192.85185185185185,139.98084291187737L187.88888888888886,136.86590038314176L182.92592592592592,137.904214559387L177.96296296296293,134.78927203065138L173,111.9463601532567L168.037037037037,140.2404214559387L163.07407407407408,137.6446360153257L158.11111111111111,139.72126436781608L153.14814814814815,138.94252873563215L148.1851851851852,139.98084291187737L143.22222222222223,139.98084291187737L138.25925925925927,139.98084291187737L133.2962962962963,126.74233716475096L128.33333333333334,139.20210727969348L123.37037037037037,127.52107279693487L118.40740740740739,138.16379310344828L113.44444444444443,138.94252873563215L108.48148148148147,138.16379310344828L103.5185185185185,139.98084291187737L98.55555555555554,135.30842911877392L93.5925925925926,139.98084291187737L88.62962962962962,139.98084291187737L83.66666666666666,139.98084291187737L78.7037037037037,138.94252873563215L73.74074074074073,139.20210727969348L68.77777777777777,138.4233716475096L63.81481481481481,139.98084291187737L58.85185185185185,139.98084291187737L53.888888888888886,126.22318007662835L48.925925925925924,54.319923371647505L43.96296296296296,139.20210727969348L39,128.04022988505744Z" fill="rgb(63, 185, 80)"/>
<path d="M39,140.5L43.96296296296296,140.5L48.925925925925924,140.5L53.888888888888886,140.5L58.85185185185185,140.5L63.81481481481481,140.5L68.77777777777777,140.5L73.74074074074073,140.5L78.7037037037037,140.5L83.66666666666666,140.5L88.62962962962962,140.5L93.5925925925926,140.5L98.55555555555554,140.5L103.5185185185185,140.5L108.48148148148147,140.5L113.44444444444443,140.5L118.40740740740739,140.5L123.37037037037037,140.5L128.33333333333334,140.5L133.2962962962963,140.5L138.25925925925927,140.5L143.22222222222223,140.5L148.1851851851852,140.5L153.14814814814815,140.5L158.11111111111111,140.5L163.07407407407408,140.5L168.037037037037,140.5L173,140.5L177.96296296296293,140.5L182.92592592592592,140.5L187.88888888888886,140.5L192.85185185185185,140.5L197.81481481481478,140.5L202.77777777777777,140.5L207.74074074074073,140.5L212.7037037037037,140.5L217.66666666666666,140.5L222.62962962962962,140.5L227.59259259259258,140.5L232.55555555555554,140.5L237.5185185185185,140.5L242.4814814814815,140.5L247.44444444444443,140.5L252.40740740740742,140.5L257.3703703703704,140.5L262.3333333333333,140.5L267.2962962962963,140.5L272.25925925925924,140.5L277.22222222222223,140.5L282.18518518518516,140.5L287.14814814814815,140.5L292.11111111111114,140.5L297.0740740740741,140.5L302.037037037037,140.5L307,140.5L311.962962962963,140.5L316.92592592592587,140.5L321.88888888888886,140.5L326.85185185185185,140.5L331.81481481481484,140.5L336.7777777777777,140.5L341.74074074074076,140.5L346.7037037037037,140.5L351.6666666666667,140.5L356.62962962962956,140.5L361.5925925925926,140.5L366.55555555555554,140.5L371.51851851851853,140.5L376.48148148148147,140.5L381.44444444444446,140.5L386.4074074074074,140.5L391.3703703703704,140.5L396.3333333333333,140.5L401.2962962962963,140.5L406.25925925925924,140.5L411.22222222222223,140.5L416.18518518518516,140.5L421.14814814814815,140.5L426.1111111111111,140.5L431.0740740740741,140.5L436.037037037037,140.5L441,140.5L441,141.01915708812263L436.037037037037,146.98946360153255L431.0740740740741,142.57662835249042L426.1111111111111,149.32567049808432L421.14814814814815,142.05747126436785L416.18518518518516,141.01915708812263L411.22222222222223,141.53831417624522L406.25925925925924,164.90038314176243L401.2962962962963,140.7595785440613L396.3333333333333,142.3170498084291L391.3703703703704,141.01915708812263L386.4074074074074,141.01915708812263L381.44444444444446,143.87452107279694L376.48148148148147,141.27873563218392L371.51851851851853,143.09578544061304L366.55555555555554,141.01915708812263L361.5925925925926,141.27873563218392L356.62962962962956,146.98946360153255L351.6666666666667,150.3639846743295L346.7037037037037,141.7978927203065L341.74074074074076,151.1427203065134L336.7777777777777,141.01915708812263L331.81481481481484,141.01915708812263L326.85185185185185,143.09578544061304L321.88888888888886,141.01915708812263L316.92592592592587,141.01915708812263L311.962962962963,144.65325670498086L307,141.01915708812263L302.037037037037,167.2365900383142L297.0740740740741,141.01915708812263L292.11111111111114,141.01915708812263L287.14814814814815,141.01915708812263L282.18518518518516,141.01915708812263L277.22222222222223,145.4319923371648L272.25925925925924,141.27873563218392L267.2962962962963,141.01915708812263L262.3333333333333,141.27873563218392L257.3703703703704,154.77681992337165L252.40740740740742,142.57662835249042L247.44444444444443,143.09578544061304L242.4814814814815,141.01915708812263L237.5185185185185,141.01915708812263L232.55555555555554,142.83620689655172L227.59259259259258,146.72988505747125L222.62962962962962,168.01532567049807L217.66666666666666,205.3946360153257L212.7037037037037,156.59386973180077L207.74074074074073,142.3170498084291L202.77777777777777,276L197.81481481481478,141.01915708812263L192.85185185185185,141.01915708812263L187.88888888888886,142.83620689655172L182.92592592592592,143.09578544061304L177.96296296296293,141.7978927203065L173,163.86206896551724L168.037037037037,141.01915708812263L163.07407407407408,159.7088122605364L158.11111111111111,141.27873563218392L153.14814814814815,141.53831417624522L148.1851851851852,141.01915708812263L143.22222222222223,141.01915708812263L138.25925925925927,141.01915708812263L133.2962962962963,147.24904214559388L128.33333333333334,141.7978927203065L123.37037037037037,146.47030651340998L118.40740740740739,142.57662835249042L113.44444444444443,142.3170498084291L108.48148148148147,141.27873563218392L103.5185185185185,141.01915708812263L98.55555555555554,145.95114942528735L93.5925925925926,141.01915708812263L88.62962962962962,141.01915708812263L83.66666666666666,141.01915708812263L78.7037037037037,142.05747126436785L73.74074074074073,141.53831417624522L68.77777777777777,141.7978927203065L63.81481481481481,141.01915708812263L58.85185185185185,141.01915708812263L53.888888888888886,155.29597701149427L48.925925925925924,194.75191570881228L43.96296296296296,141.27873563218392L39,149.066091954023Z" fill="rgb(218, 54, 51)"/>
</svg>

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,7 +1,18 @@
- name: Lines of code changed
- name: Compact display in base plugin
uses: lowlighter/metrics@latest
with:
filename: metrics.plugin.lines.svg
token: ${{ secrets.METRICS_TOKEN }}
base: repositories
plugin_lines: yes
- name: Repositories and diff history
uses: lowlighter/metrics@latest
with:
filename: metrics.plugin.lines.history.svg
token: ${{ secrets.METRICS_TOKEN }}
base: ""
plugin_lines: yes
plugin_lines_sections: repositories, history
plugin_lines_repositories_limit: 2
plugin_lines_history_limit: 1

View File

@@ -7,7 +7,7 @@ export default async function({login, data, imports, rest, q, account}, {enabled
return null
//Load inputs
let {skipped} = imports.metadata.plugins.lines.inputs({data, account, q})
let {skipped, sections, "repositories.limit":_repositories_limit, "history.limit":_history_limit} = imports.metadata.plugins.lines.inputs({data, account, q})
skipped.push(...data.shared["repositories.skipped"])
//Context
@@ -22,23 +22,101 @@ export default async function({login, data, imports, rest, q, account}, {enabled
//Get contributors stats from repositories
console.debug(`metrics/compute/${login}/plugins > lines > querying api`)
const lines = {added: 0, deleted: 0, changed: 0}
const response = [...await Promise.allSettled(repositories.map(({repo, owner}) => (skipped.includes(repo.toLocaleLowerCase())) || (skipped.includes(`${owner}/${repo}`.toLocaleLowerCase())) ? {} : rest.repos.getContributorsStats({owner, repo})))].filter(({status}) => status === "fulfilled").map(({value}) => value)
const repos = {}, weeks = {}
const response = [...await Promise.allSettled(repositories.map(async ({repo, owner}) => (skipped.includes(repo.toLocaleLowerCase())) || (skipped.includes(`${owner}/${repo}`.toLocaleLowerCase())) ? {} : {handle:`${owner}/${repo}`, stats:(await rest.repos.getContributorsStats({owner, repo})).data}))].filter(({status}) => status === "fulfilled").map(({value}) => value)
//Compute changed lines
console.debug(`metrics/compute/${login}/plugins > lines > computing total diff`)
response.map(({data: repository}) => {
response.map(({handle, stats}) => {
//Check if data are available
if (!Array.isArray(repository))
if (!Array.isArray(stats))
return
//Compute editions
const contributors = repository.filter(({author}) => context.mode === "repository" ? true : author?.login?.toLocaleLowerCase() === login.toLocaleLowerCase())
for (const contributor of contributors)
contributor.weeks.forEach(({a = 0, d = 0, c = 0}) => (lines.added += a, lines.deleted += d, lines.changed += c))
repos[handle] = {added:0, deleted:0, changed:0}
const contributors = stats.filter(({author}) => context.mode === "repository" ? true : author?.login?.toLocaleLowerCase() === login.toLocaleLowerCase())
for (const contributor of contributors) {
let added = 0, changed = 0, deleted = 0
contributor.weeks.forEach(({a = 0, d = 0, c = 0, w}) => {
added += a
deleted += d
changed += c
//Compute editions per week
const date = new Date(w * 1000).toISOString().substring(0, 10)
if (!weeks[date])
weeks[date] = {added:0, deleted:0, changed:0}
weeks[date].added += a
weeks[date].deleted += d
weeks[date].changed += c
})
console.debug(`metrics/compute/${login}/plugins > lines > ${handle}: @${contributor.author.login} +${added} -${deleted} ~${changed}`)
repos[handle].added += added
repos[handle].deleted += deleted
repos[handle].changed += changed
}
})
//Results
return lines
const result = {
sections,
added: Object.entries(repos).map(([_, {added}]) => added).reduce((a, b) => a + b, 0),
deleted: Object.entries(repos).map(([_, {deleted}]) => deleted).reduce((a, b) => a + b, 0),
changed: Object.entries(repos).map(([_, {changed}]) => changed).reduce((a, b) => a + b, 0),
repos:Object.entries(repos).map(([handle, stats]) => ({handle, ...stats})).sort((a, b) => (b.added + b.deleted + b.changed) - (a.added + a.deleted + a.changed)).slice(0, _repositories_limit),
weeks:Object.entries(weeks).map(([date, stats]) => ({date, ...stats})).filter(({added, deleted, changed}) => added + deleted + changed).sort((a, b) => new Date(a.date) - new Date(b.date)),
}
//Diff graphs
if (sections.includes("history")) {
//Generate SVG
const height = 315, width = 480
const margin = 5, offset = 34
const {d3} = imports
const weeks = result.weeks.filter(({date}) => !_history_limit ? true : new Date(date) > new Date(new Date().getFullYear() - _history_limit, 0, 0))
const d3n = new imports.D3node()
const svg = d3n.createSVG(width, height)
//Time range
const start = new Date(weeks.at(0).date)
const end = new Date(weeks.at(-1).date)
const x = d3.scaleTime()
.domain([start, end])
.range([margin+offset, width-(offset+margin)])
svg.append("g")
.attr("transform", `translate(0,${height-(offset+margin)})`)
.call(d3.axisBottom(x))
.selectAll("text")
.attr("transform", "translate(-5,5) rotate(-45)")
.style("text-anchor", "end")
.style("font-size", 20)
//Diff range
const points = weeks.flatMap(({added, deleted, changed}) => [added+changed, deleted+changed])
const extremum = Math.max(...points)
const y = d3.scaleLinear()
.domain([extremum, -extremum])
.range([margin, height-(offset+margin)])
svg.append("g")
.attr("transform", `translate(${margin+offset},0)`)
.call(d3.axisLeft(y).ticks(7).tickFormat(d3.format(".2s")))
.selectAll("text")
.style("font-size", 20)
//Generate history
for (const {type, sign, fill} of [{type:"added", sign:+1, fill:"rgb(63, 185, 80)"}, {type:"deleted", sign:-1, fill:"rgb(218, 54, 51)"}]) {
svg.append("path")
.datum(weeks.map(({date, ...diff}) => [new Date(date), sign*(diff[type]+diff.changed)]))
.attr("d", d3.area()
.x(d => x(d[0]))
.y0(d => y(d[1]))
.y1(() => y(0))
)
.attr("fill", fill)
}
result.history = d3n.svgString()
}
//Results
return result
}
//Handle errors
catch (error) {

View File

@@ -3,7 +3,8 @@ category: github
description: |
This plugin displays the number of lines of code added and removed across repositories.
examples:
default: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.lines.svg
+Repositories and diff history: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.lines.history.svg
Compact display in base plugin: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.lines.svg
index: 18
supports:
- user
@@ -27,3 +28,35 @@ inputs:
default: ""
example: my-repo-1, my-repo-2, owner/repo-3, ...
inherits: repositories_skipped
plugin_lines_sections:
description: |
Displayed sections
- `base` will display the total lines added and removed in `base.repositories` section
- `repositories` will display repositories with the most lines added and removed
- `history` will display a graph displaying lines added and removed over time
type: array
format: comma-separated
default: base
example: repositories, history
values:
- base
- repositories
- history
plugin_lines_repositories_limit:
description: |
Display limit
type: number
default: 4
min: 0
plugin_lines_history_limit:
description: |
Years to display
Will display the last `n` years, relative to current year
type: number
default: 1
zero: disable

View File

@@ -3,6 +3,7 @@
"introduction",
"base.activity+community",
"base.repositories",
"lines",
"followup",
"discussions",
"languages",

View File

@@ -28,7 +28,7 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" d="M2.5 3.5c0-.133.058-.318.282-.55.227-.237.592-.484 1.1-.708C4.899 1.795 6.354 1.5 8 1.5c1.647 0 3.102.295 4.117.742.51.224.874.47 1.101.707.224.233.282.418.282.551 0 .133-.058.318-.282.55-.227.237-.592.484-1.1.708C11.101 5.205 9.646 5.5 8 5.5c-1.647 0-3.102-.295-4.117-.742-.51-.224-.874-.47-1.101-.707-.224-.233-.282-.418-.282-.551zM1 3.5c0-.626.292-1.165.7-1.59.406-.422.956-.767 1.579-1.041C4.525.32 6.195 0 8 0c1.805 0 3.475.32 4.722.869.622.274 1.172.62 1.578 1.04.408.426.7.965.7 1.591v9c0 .626-.292 1.165-.7 1.59-.406.422-.956.767-1.579 1.041C11.476 15.68 9.806 16 8 16c-1.805 0-3.475-.32-4.721-.869-.623-.274-1.173-.62-1.579-1.04-.408-.426-.7-.965-.7-1.591v-9zM2.5 8V5.724c.241.15.503.286.779.407C4.525 6.68 6.195 7 8 7c1.805 0 3.475-.32 4.722-.869.275-.121.537-.257.778-.407V8c0 .133-.058.318-.282.55-.227.237-.592.484-1.1.708C11.101 9.705 9.646 10 8 10c-1.647 0-3.102-.295-4.117-.742-.51-.224-.874-.47-1.101-.707C2.558 8.318 2.5 8.133 2.5 8zm0 2.225V12.5c0 .133.058.318.282.55.227.237.592.484 1.1.708 1.016.447 2.471.742 4.118.742 1.647 0 3.102-.295 4.117-.742.51-.224.874-.47 1.101-.707.224-.233.282-.418.282-.551v-2.275c-.241.15-.503.285-.778.406-1.247.549-2.917.869-4.722.869-1.805 0-3.475-.32-4.721-.869a6.236 6.236 0 01-.779-.406z"></path></svg>
<%= computed.diskUsage %> used
</div>
<% if (plugins.lines) { %>
<% if ((plugins.lines)&&(plugins.lines.sections?.includes("base"))) { %>
<div class="field <%= plugins.lines.error ? 'error' : '' %>">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.75 1.5a.25.25 0 00-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 00.25-.25V4.664a.25.25 0 00-.073-.177l-2.914-2.914a.25.25 0 00-.177-.073H2.75zM1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0113.25 16H2.75A1.75 1.75 0 011 14.25V1.75zm7 1.5a.75.75 0 01.75.75v1.5h1.5a.75.75 0 010 1.5h-1.5v1.5a.75.75 0 01-1.5 0V7h-1.5a.75.75 0 010-1.5h1.5V4A.75.75 0 018 3.25zm-3 8a.75.75 0 01.75-.75h4.5a.75.75 0 010 1.5h-4.5a.75.75 0 01-.75-.75z"></path></svg>
<% if (plugins.lines.error) { %>

View File

@@ -1 +1,48 @@
<%# Included in base.repositories.ejs %>
<% if ((plugins.lines)&&((plugins.lines.sections.includes("history"))||(plugins.lines.sections.includes("repositories")))) { %>
<section>
<h2 class="field">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.75 1.5a.25.25 0 00-.25.25v12.5c0 .138.112.25.25.25h10.5a.25.25 0 00.25-.25V4.664a.25.25 0 00-.073-.177l-2.914-2.914a.25.25 0 00-.177-.073H2.75zM1 1.75C1 .784 1.784 0 2.75 0h7.586c.464 0 .909.184 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v9.586A1.75 1.75 0 0113.25 16H2.75A1.75 1.75 0 011 14.25V1.75zm7 1.5a.75.75 0 01.75.75v1.5h1.5a.75.75 0 010 1.5h-1.5v1.5a.75.75 0 01-1.5 0V7h-1.5a.75.75 0 010-1.5h1.5V4A.75.75 0 018 3.25zm-3 8a.75.75 0 01.75-.75h4.5a.75.75 0 010 1.5h-4.5a.75.75 0 01-.75-.75z"></path></svg>
Lines of code pushed
</h2>
<% if (plugins.lines.error) { %>
<div class="row">
<section>
<div class="field error">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.343 13.657A8 8 0 1113.657 2.343 8 8 0 012.343 13.657zM6.03 4.97a.75.75 0 00-1.06 1.06L6.94 8 4.97 9.97a.75.75 0 101.06 1.06L8 9.06l1.97 1.97a.75.75 0 101.06-1.06L9.06 8l1.97-1.97a.75.75 0 10-1.06-1.06L8 6.94 6.03 4.97z"></path></svg>
<%= plugins.lines.error.message %>
</div>
</section>
</div>
<% } else { %>
<% if (plugins.lines.sections?.includes("repositories")) { %>
<div class="row">
<section>
<% for (const {handle, added, deleted, changed} of plugins.lines.repos) { %>
<div class="field">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8 5.5a2.5 2.5 0 100 5 2.5 2.5 0 000-5zM4 8a4 4 0 118 0 4 4 0 01-8 0z"></path></svg>
<span class="diff-handle"><%= handle %></span>
</div>
<% } %>
</section>
<section>
<% for (const {handle, added, deleted, changed} of plugins.lines.repos) { %>
<div class="field">
<% for (let i = 1; i <= 5; i++) { %>
<div class="diff-box <%= (added+changed+deleted) ? (added+changed)/(added+deleted+2*changed) >= (i === 3 ? 0.5 : i*0.2) ? 'added' : 'deleted' : '' %>"></div>
<% } %>
<div class="diff-stats"><span class="added"><%= `+${f(added+changed)}`.padStart(7) %></span> <span class="deleted"><%= `-${f(deleted+changed)}`.padStart(7) %></span></div>
<span>&nbsp;</span>
</div>
<% } %>
</section>
</div>
<% } %>
<% if ((plugins.lines.sections?.includes("history"))&&(plugins.lines.history)) { %>
<div class="row margin-bottom">
<h3 class="margin-lr-auto">Diff history</h3>
<%- plugins.lines.history %>
</div>
<% } %>
<% } %>
</section>
<% } %>

View File

@@ -853,6 +853,47 @@
fill: currentColor;
}
/* Diff stats */
.diff-handle {
color: #58a6ff;
max-width: 200px;
text-overflow: ellipsis;
overflow: hidden;
}
.large .diff-handle {
max-width: 400px;
}
.diff-box {
display: inline-block;
width: 8px;
height: 8px;
margin-left: 1px;
background-color: rgba(110, 118, 129, 0.4);
border: 1px solid rgba(246, 240, 251, 0.1);
}
.diff-box:first-child {
margin-left: 9px;
}
.diff-box.added {
background-color: rgb(63, 185, 80);
}
.diff-box.deleted {
background-color: rgb(218, 54, 51);
}
.diff-stats {
margin-left: 4px;
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
font-weight: bold;
font-size: 12px;
white-space: pre;
}
.added {
color: rgb(63, 185, 80);
}
.deleted {
color: rgb(218, 54, 51);
}
/* People */
.people {
padding: 0 10px;

View File

@@ -13,11 +13,11 @@ export default async function({faker}, target, that, [{owner, repo}]) {
{
total: faker.datatype.number(10000),
weeks: [
{w: 1, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
{w: 2, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
{w: 3, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
{w: 4, a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
],
{w: faker.date.recent(), a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
{w: faker.date.recent(), a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
{w: faker.date.recent(), a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
{w: faker.date.recent(), a: faker.datatype.number(10000), d: faker.datatype.number(10000), c: faker.datatype.number(10000)},
].sort((a, b) => new Date(a.w) - new Date(b.w)),
author: {
login: owner,
},