Skip to content

Commit

Permalink
Update preliminary-update-comment.js
Browse files Browse the repository at this point in the history
  • Loading branch information
t-will-gillis authored Jul 19, 2024
1 parent 907a127 commit dab10c9
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const postComment = require('../../utils/post-issue-comment');
const formatComment = require('../../utils/format-comment');
const getTimeline = require('../../utils/get-timeline');
const getTeamMembers = require('../../utils/get-team-members');
const queryIssueInfo = require('../../utils/query-issue-info');
const mutateIssueStatus = require('../../utils/mutate-issue-status');

// Global variables
let github;
Expand Down Expand Up @@ -76,8 +78,8 @@ async function main({ g, c }, { shouldPost, issueNum }) {
await addLabel(READY_FOR_DEV_LABEL); // Add 'ready for dev lead' label

// Update item's status to "New Issue Approval"
const itemInfo = await getItemInfo();
await updateItemStatus(itemInfo.id, statusValues.get(New_Issue_Approval));
const itemInfo = await queryIssueInfo(context);
await mutateIssueStatus(itemInfo.id, statusValues.get(New_Issue_Approval));
} else {
// Otherwise, post the normal comment
console.log(`Issue assignment to developer OK- proceeding with "Preliminary Update Comment"`);
Expand Down Expand Up @@ -131,10 +133,10 @@ async function assignedToAnotherIssue() {
const isPreWork = issue.labels.some(label => label.name === "Complexity: Prework");

// Check if it exists in "Emergent Request" Status
const inEmergentRequestStatus = (await getItemInfo()).statusName === Emergent_Requests;
const inEmergentRequestStatus = (await queryIssueInfo(context)).statusName === Emergent_Requests;

// Check if it exists in "New Issue Approval" Status
const inNewIssueApprovalStatus = (await getItemInfo()).statusName === New_Issue_Approval;
const inNewIssueApprovalStatus = (await queryIssueInfo(context)).statusName === New_Issue_Approval;

// Include the issue only if none of the conditions are met
if(!(isAgendaIssue || isPreWork || inEmergentRequestStatus || inNewIssueApprovalStatus))
Expand Down Expand Up @@ -172,7 +174,7 @@ async function unAssignDev() {
*/
async function createComment(fileName) {
try {
const { statusName } = await getItemInfo();
const { statusName } = await queryIssueInfo(context);

const isPrework = context.payload.issue.labels.some((label) => label.name === 'Complexity: Prework');
const isDraft = context.payload.issue.labels.some((label) => label.name === 'Draft');
Expand Down Expand Up @@ -243,10 +245,13 @@ async function getLatestAssignee() {
}
}



/**
* @description - Get item info using its issue number
* @returns {Object} - An object containing the item ID and its status name
*/
/*
async function getItemInfo() {
const ISSUE_NUMBER = context.payload.issue.number;
Expand Down Expand Up @@ -296,12 +301,14 @@ async function getItemInfo() {
throw new Error("Error updating item's status: " + error);
}
}
*/

/**
* @description - Update item to a new status
* @param {String} itemId - The ID of the item to be updated
* @param {String} newStatusValue - The new status value to be assigned to the item
*/
/*
async function updateItemStatus(itemId, newStatusValue) {
try {
const mutation = `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) {
Expand Down Expand Up @@ -331,5 +338,6 @@ async function updateItemStatus(itemId, newStatusValue) {
throw new Error("Error in updateItemStatus function: " + error);
}
}
*/

module.exports = main;

0 comments on commit dab10c9

Please sign in to comment.