feat(plugins/habits): add plugin_habits_skipped (closes #1147)
This commit is contained in:
@@ -10,8 +10,9 @@ export default async function({login, data, rest, imports, q, account}, {enabled
|
|||||||
return null
|
return null
|
||||||
|
|
||||||
//Load inputs
|
//Load inputs
|
||||||
let {from, days, facts, charts, "charts.type": _charts, trim, "languages.limit": limit, "languages.threshold": threshold} = imports.metadata.plugins.habits.inputs({data, account, q}, defaults)
|
let {from, days, facts, charts, "charts.type": _charts, trim, "languages.limit": limit, "languages.threshold": threshold, skipped = []} = imports.metadata.plugins.habits.inputs({data, account, q}, defaults)
|
||||||
threshold = (Number(threshold.replace(/%$/, "")) || 0) / 100
|
threshold = (Number(threshold.replace(/%$/, "")) || 0) / 100
|
||||||
|
skipped.push(...data.shared["repositories.skipped"])
|
||||||
|
|
||||||
//Initialization
|
//Initialization
|
||||||
const habits = {facts, charts, trim, 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 habits = {facts, charts, trim, lines: {average: {chars: 0}}, commits: {fetched: 0, hour: NaN, hours: {}, day: NaN, days: {}}, indents: {style: "", spaces: 0, tabs: 0}, linguist: {available: false, ordered: [], languages: {}}}
|
||||||
@@ -36,6 +37,7 @@ export default async function({login, data, rest, imports, q, account}, {enabled
|
|||||||
const commits = events
|
const commits = events
|
||||||
.filter(({type}) => type === "PushEvent")
|
.filter(({type}) => type === "PushEvent")
|
||||||
.filter(({actor}) => account === "organization" ? true : actor.login?.toLocaleLowerCase() === login.toLocaleLowerCase())
|
.filter(({actor}) => account === "organization" ? true : actor.login?.toLocaleLowerCase() === login.toLocaleLowerCase())
|
||||||
|
.filter(({repo: {name: repo}}) => !((skipped.includes(repo.split("/").pop())) || (skipped.includes(repo))))
|
||||||
.filter(({created_at}) => new Date(created_at) > new Date(Date.now() - days * 24 * 60 * 60 * 1000))
|
.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`)
|
console.debug(`metrics/compute/${login}/plugins > habits > filtered out ${commits.length} push events over last ${days} days`)
|
||||||
habits.commits.fetched = commits.length
|
habits.commits.fetched = commits.length
|
||||||
|
|||||||
@@ -29,6 +29,15 @@ inputs:
|
|||||||
min: 1
|
min: 1
|
||||||
max: 1000
|
max: 1000
|
||||||
|
|
||||||
|
plugin_habits_skipped:
|
||||||
|
description: |
|
||||||
|
Skipped repositories
|
||||||
|
type: array
|
||||||
|
format: comma-separated
|
||||||
|
default: ""
|
||||||
|
example: my-repo-1, my-repo-2, owner/repo-3, ...
|
||||||
|
inherits: repositories_skipped
|
||||||
|
|
||||||
plugin_habits_days:
|
plugin_habits_days:
|
||||||
description: |
|
description: |
|
||||||
Event maximum age
|
Event maximum age
|
||||||
|
|||||||
Reference in New Issue
Block a user