Add timeframe to contribution description
This commit is contained in:
parent
084dec58a9
commit
8b82b8b159
@ -115,7 +115,8 @@ async function initializeKredits () {
|
|||||||
return kredits;
|
return kredits;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateContributionData(reviews, Contributor) {
|
async function generateContributionData(reviews, Contributor, startDate, endDate) {
|
||||||
|
const dateFormatOptions = { year: 'numeric', month: 'long', day: 'numeric' };
|
||||||
const contributors = await Contributor.all();
|
const contributors = await Contributor.all();
|
||||||
const contributionData = {};
|
const contributionData = {};
|
||||||
const now = (new Date()).toISOString().split('.')[0]+"Z";
|
const now = (new Date()).toISOString().split('.')[0]+"Z";
|
||||||
@ -141,6 +142,9 @@ async function generateContributionData(reviews, Contributor) {
|
|||||||
contributionData[contributor.name].amount += kreditsAmount;
|
contributionData[contributor.name].amount += kreditsAmount;
|
||||||
contributionData[contributor.name].details.pullRequests.push(...urls);
|
contributionData[contributor.name].details.pullRequests.push(...urls);
|
||||||
} else {
|
} else {
|
||||||
|
const formattedStartDate = startDate.toLocaleString('en-us', dateFormatOptions);
|
||||||
|
const formattedEndDate = endDate.toLocaleString('en-us', dateFormatOptions);
|
||||||
|
|
||||||
contributionData[contributor.name] = {
|
contributionData[contributor.name] = {
|
||||||
contributorId: contributor.id,
|
contributorId: contributor.id,
|
||||||
contributorIpfsHash: contributor.ipfsHash,
|
contributorIpfsHash: contributor.ipfsHash,
|
||||||
@ -148,7 +152,7 @@ async function generateContributionData(reviews, Contributor) {
|
|||||||
time,
|
time,
|
||||||
amount: kreditsAmount,
|
amount: kreditsAmount,
|
||||||
kind: 'dev',
|
kind: 'dev',
|
||||||
description: 'PR reviews', // TODO add timeframe to description
|
description: `PR reviews from ${formattedStartDate} to ${formattedEndDate}`,
|
||||||
details: {
|
details: {
|
||||||
'pullRequests': urls
|
'pullRequests': urls
|
||||||
}
|
}
|
||||||
@ -167,7 +171,7 @@ Promise.all([initializeKredits(), getAllReviews(repos, startDate, endDate)]).the
|
|||||||
const kredits = values[0];
|
const kredits = values[0];
|
||||||
const reviews = values[1];
|
const reviews = values[1];
|
||||||
|
|
||||||
generateContributionData(reviews, kredits.Contributor).then(contributionData => {
|
generateContributionData(reviews, kredits.Contributor, startDate, endDate).then(contributionData => {
|
||||||
if (argv.dry) {
|
if (argv.dry) {
|
||||||
console.log('contributions:');
|
console.log('contributions:');
|
||||||
console.log(util.inspect(contributionData, { depth: 3, colors: true }));
|
console.log(util.inspect(contributionData, { depth: 3, colors: true }));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user