fix(plugins/lines): handle no history data

This commit is contained in:
Simon Lecoq
2023-03-15 20:38:04 -04:00
parent 6de9c47ec4
commit b4908d81a3
4 changed files with 49 additions and 46 deletions

View File

@@ -289,7 +289,6 @@ jobs:
@use.patterns
*/*
+lowlighter/metrics
+lowlighter/brain
output_action: none
delay: 120
user: lowlighter

View File

@@ -20,4 +20,3 @@
@use.patterns
*/*
+lowlighter/metrics
+lowlighter/brain

View File

@@ -71,11 +71,12 @@ export default async function({login, data, imports, rest, q, account}, {enabled
//Diff graphs
if (sections.includes("history")) {
const weeks = result.weeks.filter(({date}) => !_history_limit ? true : new Date(date) > new Date(new Date().getFullYear() - _history_limit, 0, 0))
if (weeks.length) {
//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)
@@ -120,6 +121,11 @@ export default async function({login, data, imports, rest, q, account}, {enabled
}
result.history = d3n.svgString()
}
else {
console.debug(`metrics/compute/${login}/plugins > lines > no history data`)
result.history = null
}
}
//Results
return result

View File

@@ -18,6 +18,5 @@
@use.patterns
*/*
+lowlighter/metrics
+lowlighter/brain
use_mocked_data: 'yes'
verify: 'yes'