Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
feat: label fat fingerer
Browse files Browse the repository at this point in the history
added warning for double labels
  • Loading branch information
Keyrxng committed Oct 26, 2023
1 parent d34ea95 commit 1f8686f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/handlers/pricing/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getBotConfig, getBotContext, getLogger } from "../../bindings";
import { GLOBAL_STRINGS } from "../../configs";
import { addCommentToIssue, addLabelToIssue, clearAllPriceLabelsOnIssue, createLabel, getLabel, calculateWeight, getAllLabeledEvents } from "../../helpers";
import { Payload, UserType } from "../../types";
import { ErrorDiff } from "../../utils/helpers";
import { handleLabelsAccess } from "../access";
import { getTargetPriceLabel } from "../shared";

Expand All @@ -12,6 +13,18 @@ export const pricingLabelLogic = async (): Promise<void> => {
const payload = context.payload as Payload;
if (!payload.issue) return;
const labels = payload.issue.labels;

const doubleTimePrefix = labels.filter((label) => label.name.toString().startsWith("Time:")).length > 1;
const doublePriorityPrefix = labels.filter((label) => label.name.toString().startsWith("Priority:")).length > 1;
const doublePrefix = doubleTimePrefix || doublePriorityPrefix;

if (doublePrefix) {
await addCommentToIssue(
ErrorDiff("Be careful not to add two labels of the same catergory or issue pricing will default to the lowest value."),
payload.issue.number
);
}

const labelNames = labels.map((i) => i.name);
logger.info(`Checking if the issue is a parent issue.`);
if (payload.issue.body && isParentIssue(payload.issue.body)) {
Expand Down

0 comments on commit 1f8686f

Please sign in to comment.