Update comments and improve isocalendar plugin
This commit is contained in:
34
action/dist/index.js
vendored
34
action/dist/index.js
vendored
@@ -223,16 +223,16 @@ var E_Users_lecoq_Documents_GitHub_gitstats_node_modules_axios_index_default = /
|
|||||||
//Check if plugin is enabled and requirements are met
|
//Check if plugin is enabled and requirements are met
|
||||||
if ((!enabled)||(!q.isocalendar))
|
if ((!enabled)||(!q.isocalendar))
|
||||||
return null
|
return null
|
||||||
//Compute start day (need to )
|
//Compute start day (need to start on monday to ensure last row is complete)
|
||||||
const from = new Date(Date.now()-180*24*60*60*1000)
|
const from = new Date(Date.now()-180*24*60*60*1000)
|
||||||
const day = from.getDay()||7
|
const day = from.getDay()||7
|
||||||
if (day !== 1)
|
if (day !== 1)
|
||||||
from.setHours(-24*(day-1))
|
from.setHours(-24*(day-1))
|
||||||
//Retrieve more data from contribution calendar
|
//Retrieve contribution calendar from graphql api
|
||||||
const {user:{calendar:{contributionCalendar:calendar}}} = await graphql(`
|
const {user:{calendar:{contributionCalendar:calendar}}} = await graphql(`
|
||||||
query Calendar {
|
query Calendar {
|
||||||
user(login: $login) {
|
user(login: "${login}") {
|
||||||
calendar:contributionsCollection(from: $calendar.from, to: $calendar.to) {
|
calendar:contributionsCollection(from: "${from.toISOString()}", to: "${(new Date()).toISOString()}") {
|
||||||
contributionCalendar {
|
contributionCalendar {
|
||||||
weeks {
|
weeks {
|
||||||
contributionDays {
|
contributionDays {
|
||||||
@@ -246,11 +246,8 @@ var E_Users_lecoq_Documents_GitHub_gitstats_node_modules_axios_index_default = /
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
.replace(/[$]login/, `"${login}"`)
|
|
||||||
.replace(/[$]calendar.to/, `"${(new Date()).toISOString()}"`)
|
|
||||||
.replace(/[$]calendar.from/, `"${from.toISOString()}"`)
|
|
||||||
)
|
)
|
||||||
//Compute max contribution per day to scale
|
//Compute the highest contributions in a day, streaks and average commits per day
|
||||||
let max = 0, streak = {max:0, current:0}, values = [], average = 0
|
let max = 0, streak = {max:0, current:0}, values = [], average = 0
|
||||||
for (const week of calendar.weeks) {
|
for (const week of calendar.weeks) {
|
||||||
for (const day of week.contributionDays) {
|
for (const day of week.contributionDays) {
|
||||||
@@ -266,20 +263,13 @@ var E_Users_lecoq_Documents_GitHub_gitstats_node_modules_axios_index_default = /
|
|||||||
let i = 0, j = 0
|
let i = 0, j = 0
|
||||||
let svg = `
|
let svg = `
|
||||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="margin-top: -52px;" viewBox="0,0 480,170">
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="margin-top: -52px;" viewBox="0,0 480,170">
|
||||||
<filter id="brightness1">
|
${[1, 2].map(k => `
|
||||||
<feComponentTransfer>
|
<filter id="brightness${k}">
|
||||||
<feFuncR type="linear" slope="0.6" />
|
<feComponentTransfer>
|
||||||
<feFuncG type="linear" slope="0.6" />
|
${[..."RGB"].map(channel => `<feFunc${channel} type="linear" slope="${1-k*0.4}" />`).join("")}
|
||||||
<feFuncB type="linear" slope="0.6" />
|
</feComponentTransfer>
|
||||||
</feComponentTransfer>
|
</filter>`
|
||||||
</filter>
|
).join("")}
|
||||||
<filter id="brightness2">
|
|
||||||
<feComponentTransfer>
|
|
||||||
<feFuncR type="linear" slope="0.2" />
|
|
||||||
<feFuncG type="linear" slope="0.2" />
|
|
||||||
<feFuncB type="linear" slope="0.2" />
|
|
||||||
</feComponentTransfer>
|
|
||||||
</filter>
|
|
||||||
<g transform="scale(4) translate(12, 0)">`
|
<g transform="scale(4) translate(12, 0)">`
|
||||||
//Iterate through weeks
|
//Iterate through weeks
|
||||||
for (const week of calendar.weeks) {
|
for (const week of calendar.weeks) {
|
||||||
|
|||||||
@@ -5,16 +5,16 @@
|
|||||||
//Check if plugin is enabled and requirements are met
|
//Check if plugin is enabled and requirements are met
|
||||||
if ((!enabled)||(!q.isocalendar))
|
if ((!enabled)||(!q.isocalendar))
|
||||||
return null
|
return null
|
||||||
//Compute start day (need to )
|
//Compute start day (need to start on monday to ensure last row is complete)
|
||||||
const from = new Date(Date.now()-180*24*60*60*1000)
|
const from = new Date(Date.now()-180*24*60*60*1000)
|
||||||
const day = from.getDay()||7
|
const day = from.getDay()||7
|
||||||
if (day !== 1)
|
if (day !== 1)
|
||||||
from.setHours(-24*(day-1))
|
from.setHours(-24*(day-1))
|
||||||
//Retrieve more data from contribution calendar
|
//Retrieve contribution calendar from graphql api
|
||||||
const {user:{calendar:{contributionCalendar:calendar}}} = await graphql(`
|
const {user:{calendar:{contributionCalendar:calendar}}} = await graphql(`
|
||||||
query Calendar {
|
query Calendar {
|
||||||
user(login: $login) {
|
user(login: "${login}") {
|
||||||
calendar:contributionsCollection(from: $calendar.from, to: $calendar.to) {
|
calendar:contributionsCollection(from: "${from.toISOString()}", to: "${(new Date()).toISOString()}") {
|
||||||
contributionCalendar {
|
contributionCalendar {
|
||||||
weeks {
|
weeks {
|
||||||
contributionDays {
|
contributionDays {
|
||||||
@@ -28,11 +28,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
.replace(/[$]login/, `"${login}"`)
|
|
||||||
.replace(/[$]calendar.to/, `"${(new Date()).toISOString()}"`)
|
|
||||||
.replace(/[$]calendar.from/, `"${from.toISOString()}"`)
|
|
||||||
)
|
)
|
||||||
//Compute max contribution per day to scale
|
//Compute the highest contributions in a day, streaks and average commits per day
|
||||||
let max = 0, streak = {max:0, current:0}, values = [], average = 0
|
let max = 0, streak = {max:0, current:0}, values = [], average = 0
|
||||||
for (const week of calendar.weeks) {
|
for (const week of calendar.weeks) {
|
||||||
for (const day of week.contributionDays) {
|
for (const day of week.contributionDays) {
|
||||||
@@ -48,20 +45,13 @@
|
|||||||
let i = 0, j = 0
|
let i = 0, j = 0
|
||||||
let svg = `
|
let svg = `
|
||||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="margin-top: -52px;" viewBox="0,0 480,170">
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="margin-top: -52px;" viewBox="0,0 480,170">
|
||||||
<filter id="brightness1">
|
${[1, 2].map(k => `
|
||||||
<feComponentTransfer>
|
<filter id="brightness${k}">
|
||||||
<feFuncR type="linear" slope="0.6" />
|
<feComponentTransfer>
|
||||||
<feFuncG type="linear" slope="0.6" />
|
${[..."RGB"].map(channel => `<feFunc${channel} type="linear" slope="${1-k*0.4}" />`).join("")}
|
||||||
<feFuncB type="linear" slope="0.6" />
|
</feComponentTransfer>
|
||||||
</feComponentTransfer>
|
</filter>`
|
||||||
</filter>
|
).join("")}
|
||||||
<filter id="brightness2">
|
|
||||||
<feComponentTransfer>
|
|
||||||
<feFuncR type="linear" slope="0.2" />
|
|
||||||
<feFuncG type="linear" slope="0.2" />
|
|
||||||
<feFuncB type="linear" slope="0.2" />
|
|
||||||
</feComponentTransfer>
|
|
||||||
</filter>
|
|
||||||
<g transform="scale(4) translate(12, 0)">`
|
<g transform="scale(4) translate(12, 0)">`
|
||||||
//Iterate through weeks
|
//Iterate through weeks
|
||||||
for (const week of calendar.weeks) {
|
for (const week of calendar.weeks) {
|
||||||
|
|||||||
Reference in New Issue
Block a user