Skip to content

Commit

Permalink
fix: combine tests and simplify priority label logic
Browse files Browse the repository at this point in the history
  • Loading branch information
k-borley committed Sep 29, 2023
1 parent e396a83 commit 1f18f04
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 70 deletions.
25 changes: 7 additions & 18 deletions dist/146.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/146.index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 13 additions & 19 deletions src/helpers/comment-issue-due-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,24 @@ import { octokit } from '../octokit';
import { PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4 } from '../constants';

export class CreateIssueDuedateComment extends HelperInputs {
label?: string;
label!: typeof PRIORITY_1 | typeof PRIORITY_2 | typeof PRIORITY_3 | typeof PRIORITY_4;
}

export type PriorityDueDateMapping = {
[key: string]: number;
};

const daysOpenBasedOnPriority: PriorityDueDateMapping = {
[PRIORITY_1]: 2,
[PRIORITY_2]: 14,
[PRIORITY_3]: 45,
[PRIORITY_4]: 90
};

export const commentIssueDueDate = async ({ label }: CreateIssueDuedateComment) => {
const issue_number = context.issue.number;

// eslint-disable-next-line functional/no-let
let numDaysAllowedOpen;
switch (label) {
case PRIORITY_1:
numDaysAllowedOpen = 2;
break;
case PRIORITY_2:
numDaysAllowedOpen = 14;
break;
case PRIORITY_3:
numDaysAllowedOpen = 45;
break;
case PRIORITY_4:
numDaysAllowedOpen = 90;
break;
}

if (!numDaysAllowedOpen) return;
const numDaysAllowedOpen = daysOpenBasedOnPriority[label];

const response = await octokit.issues.get({
issue_number,
Expand Down
Loading

0 comments on commit 1f18f04

Please sign in to comment.