feat(plugins/stargazers): add plugin_stargazers_charts

This commit is contained in:
lowlighter
2022-07-21 13:42:31 -04:00
parent b2093edc08
commit 1ce01ff74c
3 changed files with 52 additions and 42 deletions

View File

@@ -7,7 +7,7 @@ export default async function({login, graphql, data, imports, q, queries, accoun
return null
//Load inputs
let {"charts.type": _charts, worldmap: _worldmap, "worldmap.sample": _worldmap_sample} = imports.metadata.plugins.stargazers.inputs({data, account, q})
let {charts: _charts, "charts.type": _charts_type, worldmap: _worldmap, "worldmap.sample": _worldmap_sample} = imports.metadata.plugins.stargazers.inputs({data, account, q})
//Retrieve stargazers from graphql api
console.debug(`metrics/compute/${login}/plugins > stargazers > querying api`)
@@ -60,8 +60,8 @@ export default async function({login, graphql, data, imports, q, queries, accoun
const months = ["", "Jan.", "Feb.", "Mar.", "Apr.", "May", "June", "July", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."]
//Generating charts
let charts = null
if ((_charts === "chartist") && (imports.metadata.plugins.stargazers.extras("charts.type", {extras}))) {
let charts = _charts ? true : null
if ((_charts_type === "chartist") && (imports.metadata.plugins.stargazers.extras("charts.type", {extras}))) {
console.debug(`metrics/compute/${login}/plugins > stargazers > generating charts`)
charts = await Promise.all([{data: total, low: total.min, high: total.max}, {data: increments, ref: 0, low: increments.min, high: increments.max, sign: true}].map(({data: {dates: set}, high, low, ref, sign = false}) =>
imports.chartist("line", {

View File

@@ -21,6 +21,14 @@ inputs:
type: boolean
default: no
plugin_stargazers_charts:
description: |
Charts
It includes total number of stargazers evolution, along with the number of new stars per day over the last two weeks.
type: boolean
default: yes
plugin_stargazers_charts_type:
description: |
Charts display type

View File

@@ -10,10 +10,11 @@
<%= plugins.stargazers.error.message %>
</div>
<% } else { %>
<% if (plugins.stargazers.charts) { %>
<div class="row margin-bottom">
<section class="column chart chartist">
<h3>Total stargazers</h3>
<% if (plugins.stargazers.charts) { %>
<% if (Array.isArray(plugins.stargazers.charts)) { %>
<%- plugins.stargazers.charts[0] %>
<% } else { %>
<div class="chart-bars">
@@ -32,7 +33,7 @@
</section>
<section class="column chart chartist">
<h3>New stargazers per day</h3>
<% if (plugins.stargazers.charts) { %>
<% if (Array.isArray(plugins.stargazers.charts)) { %>
<%- plugins.stargazers.charts[1] %>
<% } else { %>
<div class="chart-bars">
@@ -50,6 +51,7 @@
<% } %>
</section>
</div>
<% } %>
<% if (plugins.stargazers.worldmap) { %>
<div class="row margin-bottom">
<h3 class="margin-lr-auto">Stargazers origins</h3>