Skip to content

Commit

Permalink
fix: remove duplicate maxTask checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan-ae committed Sep 3, 2024
1 parent 14f8e5f commit 99ccab3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
11 changes: 1 addition & 10 deletions src/handlers/shared/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,7 @@ export async function start(context: Context, issue: Context["payload"]["issue"]
} catch (e) {
logger.error("Error while getting commit hash", { error: e as Error });
}

const assignedIssues = await getAssignedIssues(context, sender.login);
logger.info("Max issues allowed is", { limit: maxTask.limit, assigned: assignedIssues.length });

// check for max and enforce max

if (assignedIssues.length >= maxTask.limit) {
throw new Error(`Too many assigned issues, you have reached your max limit of ${maxTask.limit} issues.`);
}


// is it assignable?

if (issue.state === ISSUE_TYPE.CLOSED) {
Expand Down
4 changes: 2 additions & 2 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe("User start/stop", () => {
const context = createContext(issue, sender) as unknown as Context;

context.adapters = createAdapters(getSupabase(), context as unknown as Context);
await expect(userStartStop(context)).rejects.toThrow(`Too many assigned issues, you have reached your max limit of ${memberLimit} issues.`);
await expect(userStartStop(context)).rejects.toThrow("You have reached your max task limit. Please close out some tasks before assigning new ones.");

expect(memberLimit).toEqual(4);
});
Expand All @@ -197,7 +197,7 @@ test("should set maxLimits to 6 if the user is an admin", async () => {
const context = createContext(issue, sender) as unknown as Context;

context.adapters = createAdapters(getSupabase(), context as unknown as Context);
await expect(userStartStop(context)).rejects.toThrow(`Too many assigned issues, you have reached your max limit of ${adminLimit} issues.`);
await expect(userStartStop(context)).rejects.toThrow("You have reached your max task limit. Please close out some tasks before assigning new ones.");

expect(adminLimit).toEqual(6);
});
Expand Down

0 comments on commit 99ccab3

Please sign in to comment.