Skip to content

Commit

Permalink
chore: merge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Sep 1, 2024
1 parent 1977116 commit d7ca019
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/handlers/shared/generate-assignment-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@ export const options: Intl.DateTimeFormatOptions = {
timeZoneName: "short",
};

export function getDeadline(issue: Context["payload"]["issue"]) {
export function getDeadline(issue: Context["payload"]["issue"]): string | null {
if (!issue?.labels) {
throw new Error("No labels are set.");
}
const startTime = new Date().getTime();
const duration: number = calculateDurations(issue.labels).shift() ?? 0;
if (!duration) return null;
const endTime = new Date(startTime + duration * 1000);
return endTime.toLocaleString("en-US", options);
}

export async function generateAssignmentComment(context: Context, issueCreatedAt: string, issueNumber: number, senderId: number, deadline: string) {
export async function generateAssignmentComment(context: Context, issueCreatedAt: string, issueNumber: number, senderId: number, deadline: string | null) {
const startTime = new Date().getTime();

return {
daysElapsedSinceTaskCreation: Math.floor((startTime - new Date(issueCreatedAt).getTime()) / 1000 / 60 / 60 / 24),
deadline,
deadline: deadline ?? null,
registeredWallet:
(await context.adapters.supabase.user.getWalletByUserId(senderId, issueNumber)) ||
"Register your wallet address using the following slash command: `/wallet 0x0000...0000`",
Expand Down
8 changes: 0 additions & 8 deletions src/handlers/shared/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ export async function start(context: Context, issue: Context["payload"]["issue"]
throw new Error(logger.error(`Skipping '/start' since the issue is a parent issue`).logMessage.raw);
}

const hasBeenPreviouslyUnassigned = await hasUserBeenUnassigned(context);

if (hasBeenPreviouslyUnassigned) {
const log = logger.error("You were previously unassigned from this task. You can not reassign yourself.", { sender });
await addCommentToIssue(context, log?.logMessage.diff as string);
throw new Error("User was previously unassigned from this task");
}

let commitHash: string | null = null;

try {
Expand Down

0 comments on commit d7ca019

Please sign in to comment.