Display number of commits used in habits plugin (#359)
This commit is contained in:
@@ -13,7 +13,7 @@ export default async function({login, data, rest, imports, q, account}, {enabled
|
||||
let {from, days, facts, charts} = imports.metadata.plugins.habits.inputs({data, account, q}, defaults)
|
||||
|
||||
//Initialization
|
||||
const habits = {facts, charts, lines:{average:{chars:0}}, commits:{hour:NaN, hours:{}, day:NaN, days:{}}, indents:{style:"", spaces:0, tabs:0}, linguist:{available:false, ordered:[], languages:{}}}
|
||||
const habits = {facts, charts, lines:{average:{chars:0}}, commits:{fetched:0, hour:NaN, hours:{}, day:NaN, days:{}}, indents:{style:"", spaces:0, tabs:0}, linguist:{available:false, ordered:[], languages:{}}}
|
||||
const pages = Math.ceil(from / 100)
|
||||
const offset = data.config.timezone?.offset ?? 0
|
||||
|
||||
@@ -37,6 +37,7 @@ export default async function({login, data, rest, imports, q, account}, {enabled
|
||||
.filter(({actor}) => account === "organization" ? true : actor.login === login)
|
||||
.filter(({created_at}) => new Date(created_at) > new Date(Date.now() - days * 24 * 60 * 60 * 1000))
|
||||
console.debug(`metrics/compute/${login}/plugins > habits > filtered out ${commits.length} push events over last ${days} days`)
|
||||
habits.commits.fetched = commits.length
|
||||
|
||||
//Retrieve edited files and filter edited lines (those starting with +/-) from patches
|
||||
console.debug(`metrics/compute/${login}/plugins > habits > loading patches`)
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
<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="M8 1.5c-2.363 0-4 1.69-4 3.75 0 .984.424 1.625.984 2.304l.214.253c.223.264.47.556.673.848.284.411.537.896.621 1.49a.75.75 0 01-1.484.211c-.04-.282-.163-.547-.37-.847a8.695 8.695 0 00-.542-.68c-.084-.1-.173-.205-.268-.32C3.201 7.75 2.5 6.766 2.5 5.25 2.5 2.31 4.863 0 8 0s5.5 2.31 5.5 5.25c0 1.516-.701 2.5-1.328 3.259-.095.115-.184.22-.268.319-.207.245-.383.453-.541.681-.208.3-.33.565-.37.847a.75.75 0 01-1.485-.212c.084-.593.337-1.078.621-1.489.203-.292.45-.584.673-.848.075-.088.147-.173.213-.253.561-.679.985-1.32.985-2.304 0-2.06-1.637-3.75-4-3.75zM6 15.25a.75.75 0 01.75-.75h2.5a.75.75 0 010 1.5h-2.5a.75.75 0 01-.75-.75zM5.75 12a.75.75 0 000 1.5h4.5a.75.75 0 000-1.5h-4.5z"></path></svg>
|
||||
Recent coding habits
|
||||
<% if (plugins.habits.commits?.fetched) { %>
|
||||
<small class="h-details">(computed from last <%= plugins.habits.commits.fetched %> commit<%= s(plugins.habits.commits.fetched) %>)</small>
|
||||
<% } %>
|
||||
</h2>
|
||||
<% if (plugins.habits.facts) { %>
|
||||
<div class="row">
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
h3 {
|
||||
font-size: 14px;
|
||||
}
|
||||
.h-details {
|
||||
margin: 0 4px;
|
||||
padding-top: 4px;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
/* Fields */
|
||||
section > .field {
|
||||
|
||||
Reference in New Issue
Block a user