Skip to content

Commit

Permalink
adding omitted labels, fixing call to label dir, adjusting module
Browse files Browse the repository at this point in the history
  • Loading branch information
t-will-gillis committed Oct 3, 2024
1 parent 3f9d22b commit e7fab32
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ const minimizeIssueComment = require('../../utils/hide-issue-comment');
var github;
var context;

// Use labelIds to retrieve current labelNames from directory
const statusUpdated = retrieveLabelDirectory('statusUpdated');
const statusInactive1 = retrieveLabelDirectory('statusInactive1');
const statusInactive2 = retrieveLabelDirectory('statusInactive2');
// Use labelIds to map current labelNames from label directory
const [
statusUpdated,
statusInactive1,
statusInactive2,
draft,
er,
epic,
dependency,
] = [
"statusUpdated",
"statusInactive1",
"statusInactive2",
"draft",
"er",
"epic",
"dependency"
].map(retrieveLabelDirectory);

const updatedByDays = 3; // If last update update 3 days, the issue is considered updated
const commentByDays = 7; // If last update between 7 to 14 days ago, issue is outdated and needs update
Expand Down Expand Up @@ -82,7 +96,7 @@ async function main({ g, c }) {
* @returns {Promise<Array>} issueNums - an array of open, assigned, and statused issue numbers
*/
async function getIssueNumsFromRepo() {
const labelsToExclude = ['Draft', 'ER', 'Epic', 'Dependency'];
const labelsToExclude = [draft, er, epic, dependency];
let issueNums = [];
let pageNum = 1;
let result = [];
Expand Down
31 changes: 17 additions & 14 deletions github-actions/utils/retrieve-label-directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,33 @@ const fs = require('fs');

// Global variables
var filepath = 'github-actions/utils/_data/label-directory.json';
var labelData;

/*
* Matches label reference name(s) to the label display name(s) from JSON
* @param {string } filepath - Path to `label_directory.json`
* @param {Array} labelKeys - List of reference names to look up display names
* @return {Array} displayNames - List of display names
* @return {Array} labelName - Display name for each label
*/
function labelRetrieveNames(...labelKeys) {

// Retrieve label directory
const rawData = fs.readFileSync(filepath, 'utf8');
const data = JSON.parse(rawData);
// Retrieve label directory if not read already
if (labelData === undefined) {
console.log(`Reading label directory...`);
const rawData = fs.readFileSync(filepath, 'utf8');
labelData = JSON.parse(rawData);
}

let labelKey = labelKeys[0];
let labelName = '';

const displayNames = [ ];
for(let labelKey of labelKeys) {
try {
displayNames.push(data[labelKey][0]);
console.log(`Success! From label key: '${labelKey}' found label display: '${data[labelKey][0]}'`);
} catch (err) {
console.error(`Failed to find label display for label key: '${labelKey}'`)
}
try {
labelName = labelData[labelKey][0];
console.log(`Success! Found labelKey: '${labelKey}', returning labelName: '${labelName}'`);
} catch (err) {
console.error(`Failed to find labelKey: '${labelKey}'`)
}

return displayNames;
return labelName;
}

module.exports = labelRetrieveNames;

0 comments on commit e7fab32

Please sign in to comment.