diff --git a/one-off-scripts/add-comment-on-frontmatter-issues.js b/one-off-scripts/add-comment-on-frontmatter-issues.js index 52474cfe88..729207cb9b 100644 --- a/one-off-scripts/add-comment-on-frontmatter-issues.js +++ b/one-off-scripts/add-comment-on-frontmatter-issues.js @@ -2,7 +2,7 @@ This is a one-off script to run on all open PRs to add a comment and "status: needs update" label to any PR with guide articles which have frontmatter issues. -*//************ log.js **************/ +*/ require('dotenv').config({ path: '../.env' }); const fetch = require('node-fetch'); @@ -85,6 +85,7 @@ const guideFolderChecks = async (number, prFiles, user) => { (async () => { const { firstPR, lastPR } = await getUserInput(); + log.setFirstLast({ firstPR, lastPR }); const prPropsToGet = ['number', 'labels', 'user']; const { openPRs } = await getPRs(firstPR, lastPR, prPropsToGet); @@ -102,7 +103,7 @@ const guideFolderChecks = async (number, prFiles, user) => { const labelsAdded = await labeler(number, prFiles, currentLabels, guideFolderErrorsComment); const labelLogVal = labelsAdded.length ? labelsAdded : 'none added'; - log.update(number, { comment: commentLogVal, labels: labelLogVal }); + log.add(number, { comment: commentLogVal, labels: labelLogVal }); await rateLimiter(+process.env.RATELIMIT_INTERVAL | 1500); } } diff --git a/one-off-scripts/add-test-locally-label.js b/one-off-scripts/add-test-locally-label.js index c4e04e1a3c..fbb4c8c795 100644 --- a/one-off-scripts/add-test-locally-label.js +++ b/one-off-scripts/add-test-locally-label.js @@ -19,6 +19,7 @@ const log = new ProcessingLog('all-locally-tested-labels'); (async () => { const { firstPR, lastPR } = await getUserInput(); + log.setFirstLast({ firstPR, lastPR }); const prPropsToGet = ['number', 'labels']; const { openPRs } = await getPRs(firstPR, lastPR, prPropsToGet); diff --git a/one-off-scripts/comments-and-labels-summary.js b/one-off-scripts/comments-and-labels-summary.js index 72a20fd879..5aaa6f54b3 100644 --- a/one-off-scripts/comments-and-labels-summary.js +++ b/one-off-scripts/comments-and-labels-summary.js @@ -1,28 +1,45 @@ /* This is a one-off script which can be used to parse a production or test version of the open-prs-processed.json file in the work-logs directory. It will generate a text -file referencing only PRs and any comments/labels either added (prodouction) or -would be added (test) based on data stored in the open-prs-processed.json file. +file referencing only PRs with any comments/labels either added (prodouction) or +would be added (test) based on data stored in the specific JSON log file. */ const { saveToFile, openJSONFile } = require('../utils'); const path = require('path'); +const dedent = require("dedent"); + +const specificLogFile = path.resolve(__dirname, `../work-logs/production_sweeper_3-6_2018-11-23T003553.json`); (() => { - let fileObj = openJSONFile(path.resolve(__dirname, `../work-logs/test_open-prs-processed.json`)); + let fileObj = openJSONFile(specificLogFile); let { prs } = fileObj; let count = 0; - let prsWithComments = prs.reduce((text, pr) => { - let number = Object.keys(pr).map(key => key); - let { comment, labels } = pr[number]; + let prsWithComments = prs.reduce((text, { number, data: { comment, labels } }) => { if (comment !== 'none' || labels !== 'none added') { - text += `PR #${number}\r\nComment: ${comment}\r\n\r\nLabels: ${labels}\r\n*************************\r\n\r\n`; + text += dedent` + + PR #${number} + Comment: ${comment} + + Labels: ${labels} + + *************************\n + + `; count++; } return text; }, ''); - prsWithComments = '# of PRs with comments or labels added: ' + count + '\r\n\r\n*************************\r\n' + prsWithComments; + prsWithComments = dedent` + # of PRs with comments or labels added: ${count} + + ************************* + ${prsWithComments} + `; + saveToFile(path.resolve(__dirname, `../work-logs/guideErrorComments.txt`), prsWithComments); + console.log('guideErrorComments.txt created'); })()