Skip to content

Commit

Permalink
Merge pull request #112 from gentlementlegen/fix/deadline-message
Browse files Browse the repository at this point in the history
fix: removed deadline message on issue assigned
  • Loading branch information
gentlementlegen authored Jan 2, 2025
2 parents 9ccdb93 + 630c2f7 commit f9a97ff
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions src/adapters/supabase/helpers/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { SupabaseClient } from "@supabase/supabase-js";
import { Super } from "./supabase";
import { Context } from "../../../types/context";
import { addCommentToIssue } from "../../../utils/issue";
import { Super } from "./supabase";

type Wallet = {
address: string;
Expand All @@ -17,8 +16,7 @@ export class User extends Super {
if ((error && !data) || !data.wallets?.address) {
this.context.logger.error("No wallet address found", { userId, issueNumber });
if (this.context.config.startRequiresWallet) {
await addCommentToIssue(this.context, this.context.logger.error(this.context.config.emptyWalletText, { userId, issueNumber }).logMessage.diff);
throw new Error("No wallet address found");
throw this.context.logger.error(this.context.config.emptyWalletText, { userId, issueNumber });
}
} else {
this.context.logger.info("Successfully fetched wallet", { userId, address: data.wallets?.address });
Expand Down
5 changes: 2 additions & 3 deletions src/handlers/shared/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { addAssignees, addCommentToIssue, getAssignedIssues, getPendingOpenedPul
import { HttpStatusCode, Result } from "../result-types";
import { hasUserBeenUnassigned } from "./check-assignments";
import { checkTaskStale } from "./check-task-stale";
import { generateAssignmentComment, getDeadline } from "./generate-assignment-comment";
import { generateAssignmentComment } from "./generate-assignment-comment";
import { getUserRoleAndTaskLimit } from "./get-user-task-limit-and-role";
import structuredMetadata from "./structured-metadata";
import { assignTableComment } from "./table";
Expand Down Expand Up @@ -167,10 +167,9 @@ ${issues}
}
}

const deadline = getDeadline(labels);
const toAssignIds = await fetchUserIds(context, toAssign);

const assignmentComment = await generateAssignmentComment(context, issue.created_at, issue.number, sender.id, deadline);
const assignmentComment = await generateAssignmentComment(context, issue.created_at, issue.number, sender.id, null);
const logMessage = logger.info("Task assigned successfully", {
taskDeadline: assignmentComment.deadline,
taskAssignees: toAssignIds,
Expand Down
5 changes: 1 addition & 4 deletions src/handlers/user-start-stop.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Repository } from "@octokit/graphql-schema";
import { Context, isIssueCommentEvent, Label } from "../types";
import { QUERY_CLOSING_ISSUE_REFERENCES } from "../utils/get-closing-issue-references";
import { addCommentToIssue, closePullRequestForAnIssue, getOwnerRepoFromHtmlUrl } from "../utils/issue";
import { closePullRequestForAnIssue, getOwnerRepoFromHtmlUrl } from "../utils/issue";
import { HttpStatusCode, Result } from "./result-types";
import { getDeadline } from "./shared/generate-assignment-comment";
import { start } from "./shared/start";
Expand Down Expand Up @@ -60,9 +60,6 @@ export async function userSelfAssign(context: Context<"issues.assigned">): Promi
return { status: HttpStatusCode.NOT_MODIFIED };
}

const users = issue.assignees.map((user) => `@${user?.login}`).join(", ");

await addCommentToIssue(context, `${users} the deadline is at ${deadline}`);
return { status: HttpStatusCode.OK };
}

Expand Down
18 changes: 9 additions & 9 deletions tests/http/run.http
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ X-GitHub-Delivery: mock-delivery-id
}
],
"user": {
"login": "ubiquity-ubiquibot",
"login": "{{LOGIN}}",
"id": 12345678,
"node_id": "MDQ6VXNlcjEyMzQ1Njc4",
"avatar_url": "https://avatars.githubusercontent.com/u/12345678?v=4",
"url": "https://api.github.com/users/ubiquity-ubiquibot",
"html_url": "https://github.com/ubiquity-ubiquibot",
"url": "https://api.github.com/users/{{LOGIN}}",
"html_url": "https://github.com/{{LOGIN}}",
"type": "User",
"site_admin": false
},
Expand All @@ -82,12 +82,12 @@ X-GitHub-Delivery: mock-delivery-id
"id": 1234567890,
"node_id": "IC_kwDOA1234567",
"user": {
"login": "ubiquity-ubiquibot",
"login": "{{LOGIN}}",
"id": 163369652,
"node_id": "MDQ6VXNlcjEyMzQ1Njc4",
"avatar_url": "https://avatars.githubusercontent.com/u/12345678?v=4",
"url": "https://api.github.com/users/ubiquity-ubiquibot",
"html_url": "https://github.com/ubiquity-ubiquibot",
"url": "https://api.github.com/users/{{LOGIN}}",
"html_url": "https://github.com/{{LOGIN}}",
"type": "User",
"site_admin": false
},
Expand Down Expand Up @@ -134,12 +134,12 @@ X-GitHub-Delivery: mock-delivery-id
"description": "Ubiquity Organization"
},
"sender": {
"login": "ubiquity-ubiquibot",
"login": "{{LOGIN}}",
"id": 163369652,
"node_id": "MDQ6VXNlcjEyMzQ1Njc4",
"avatar_url": "https://avatars.githubusercontent.com/u/12345678?v=4",
"url": "https://api.github.com/users/ubiquity-ubiquibot",
"html_url": "https://github.com/ubiquity-ubiquibot",
"url": "https://api.github.com/users/{{LOGIN}}",
"html_url": "https://github.com/{{LOGIN}}",
"type": "User",
"site_admin": false
}
Expand Down
4 changes: 2 additions & 2 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect } from "@j
import { drop } from "@mswjs/data";
import { TransformDecodeError, Value } from "@sinclair/typebox/value";
import { createClient } from "@supabase/supabase-js";
import { cleanLogString, Logs } from "@ubiquity-os/ubiquity-os-logger";
import { cleanLogString, LogReturn, Logs } from "@ubiquity-os/ubiquity-os-logger";
import dotenv from "dotenv";
import { createAdapters } from "../src/adapters";
import { HttpStatusCode } from "../src/handlers/result-types";
Expand Down Expand Up @@ -211,7 +211,7 @@ describe("User start/stop", () => {
const context = createContext(issue, sender, "/start", "2", true) as Context<"issue_comment.created">;

context.adapters = createAdapters(getSupabase(false), context);
await expect(userStartStop(context)).rejects.toThrow("No wallet address found");
await expect(userStartStop(context)).rejects.toBeInstanceOf(LogReturn);
});

test("User can't start an issue that's closed", async () => {
Expand Down

0 comments on commit f9a97ff

Please sign in to comment.