Skip to content

Commit 3c795bc

Browse files
committed
fix: format code with Prettier
1 parent c6a5e12 commit 3c795bc

File tree

6 files changed

+80
-71
lines changed

6 files changed

+80
-71
lines changed

src/infrastructure/discord/commands/myIssues.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function execute(interaction: CommandInteraction) {
2626
}
2727

2828
const discordUserId = interaction.user.id;
29-
29+
3030
const userResult = await UserService.findUserByDiscordID(discordUserId);
3131
if (userResult.err) {
3232
await interaction.reply({
@@ -38,7 +38,6 @@ export async function execute(interaction: CommandInteraction) {
3838

3939
const githubUsername = userResult.val.githubUsername;
4040

41-
4241
await interaction.deferReply({ ephemeral: true });
4342

4443
const githubItemsResult = await GithubAPI.fetchProjectItems();

src/infrastructure/discord/interactions/assigneeSelectInteraction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function assigneeSelectInteraction(
2323
}
2424

2525
// Find the GitHub ID using the selected Discord ID
26-
const githubId = userResult.val.githubId
26+
const githubId = userResult.val.githubId;
2727

2828
const result = await ItemService.updateAssignee({
2929
itemId: githubIssueId,

src/infrastructure/discord/tasks/urgentItemsDirectMessage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export const urgentItemsDirectMessage = async (client: any) => {
3838
const githubUsername = githubUrl.split("/").pop();
3939
if (!githubUsername) continue;
4040

41-
const userResult = await UserService.findUserByGithubUsername(githubUsername);
41+
const userResult =
42+
await UserService.findUserByGithubUsername(githubUsername);
4243
if (userResult.err || !userResult.val.discordId) {
4344
logger.warn({
4445
event: "dailyTasksReminder.missingMapping",

src/infrastructure/discord/webhookMessages.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ const formatDiscordAssignees = async (assignees: string[]) => {
7373
const mentions = await Promise.all(
7474
assignees.map(async (githubUrl) => {
7575
const githubUsername = githubUrl.replace("https://github.com/", "");
76-
const userResult = await UserService.findUserByGithubUsername(githubUsername);
76+
const userResult =
77+
await UserService.findUserByGithubUsername(githubUsername);
7778

7879
return userResult.ok ? `<@${userResult.val.discordId}>` : githubUsername;
7980
}),

src/items/services/UserService.ts

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1-
import githubDiscordMap from "../../../data/githubDiscordMap.json";
2-
import { Err, Ok, Result } from "ts-results";
3-
4-
export interface User {
5-
githubUsername: string;
6-
githubId: string;
7-
discordId: string;
8-
}
9-
10-
const users: User[] = Object.values(githubDiscordMap);
11-
12-
export class UserService {
13-
static async findUserByDiscordID(discordId: string): Promise<Result<User, Error>> {
14-
const user = users.find((u) => u.discordId === discordId);
15-
return user ? Ok(user) : Err(new Error("Could not find user with that DiscordID"));
16-
}
17-
18-
static async findUserByGithubUsername(githubUsername: string): Promise<Result<User, Error>> {
19-
const user = users.find((u) => u.githubUsername === githubUsername);
20-
return user ? Ok(user) : Err(new Error("Could not find user with that GitHub username"));
21-
}
22-
}
1+
import githubDiscordMap from "../../../data/githubDiscordMap.json";
2+
import { Err, Ok, Result } from "ts-results";
3+
4+
export interface User {
5+
githubUsername: string;
6+
githubId: string;
7+
discordId: string;
8+
}
9+
10+
const users: User[] = Object.values(githubDiscordMap);
11+
12+
export class UserService {
13+
static async findUserByDiscordID(
14+
discordId: string,
15+
): Promise<Result<User, Error>> {
16+
const user = users.find((u) => u.discordId === discordId);
17+
return user
18+
? Ok(user)
19+
: Err(new Error("Could not find user with that DiscordID"));
20+
}
21+
22+
static async findUserByGithubUsername(
23+
githubUsername: string,
24+
): Promise<Result<User, Error>> {
25+
const user = users.find((u) => u.githubUsername === githubUsername);
26+
return user
27+
? Ok(user)
28+
: Err(new Error("Could not find user with that GitHub username"));
29+
}
30+
}
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
import { UserService } from "@src/items/services/UserService";
2-
3-
jest.mock("../../../data/githubDiscordMap.json", () => ({
4-
alice: {
5-
githubUsername: "alice",
6-
githubId: "ghid-alice",
7-
discordId: "discord-alice",
8-
},
9-
bob: {
10-
githubUsername: "bob",
11-
githubId: "ghid-bob",
12-
discordId: "discord-bob",
13-
},
14-
}));
15-
16-
describe("UserService", () => {
17-
it("finds user by Discord ID", async () => {
18-
const result = await UserService.findUserByDiscordID("discord-bob");
19-
expect(result.ok).toBe(true);
20-
21-
if (result.ok) {
22-
expect(result.val.githubUsername).toBe("bob");
23-
}
24-
});
25-
26-
it("will return error for unknown Discord ID", async () => {
27-
const result = await UserService.findUserByDiscordID("unknown");
28-
expect(result.err).toBe(true);
29-
});
30-
31-
it("finds user by GitHub username", async () => {
32-
const result = await UserService.findUserByGithubUsername("alice");
33-
expect(result.ok).toBe(true);
34-
35-
if (result.ok) {
36-
expect(result.val.discordId).toBe("discord-alice");
37-
}
38-
});
39-
40-
it("will return error for unknown GitHub username", async () => {
41-
const result = await UserService.findUserByGithubUsername("charlie");
42-
expect(result.err).toBe(true);
43-
});
44-
});
1+
import { UserService } from "@src/items/services/UserService";
2+
3+
jest.mock("../../../data/githubDiscordMap.json", () => ({
4+
alice: {
5+
githubUsername: "alice",
6+
githubId: "ghid-alice",
7+
discordId: "discord-alice",
8+
},
9+
bob: {
10+
githubUsername: "bob",
11+
githubId: "ghid-bob",
12+
discordId: "discord-bob",
13+
},
14+
}));
15+
16+
describe("UserService", () => {
17+
it("finds user by Discord ID", async () => {
18+
const result = await UserService.findUserByDiscordID("discord-bob");
19+
expect(result.ok).toBe(true);
20+
21+
if (result.ok) {
22+
expect(result.val.githubUsername).toBe("bob");
23+
}
24+
});
25+
26+
it("will return error for unknown Discord ID", async () => {
27+
const result = await UserService.findUserByDiscordID("unknown");
28+
expect(result.err).toBe(true);
29+
});
30+
31+
it("finds user by GitHub username", async () => {
32+
const result = await UserService.findUserByGithubUsername("alice");
33+
expect(result.ok).toBe(true);
34+
35+
if (result.ok) {
36+
expect(result.val.discordId).toBe("discord-alice");
37+
}
38+
});
39+
40+
it("will return error for unknown GitHub username", async () => {
41+
const result = await UserService.findUserByGithubUsername("charlie");
42+
expect(result.err).toBe(true);
43+
});
44+
});

0 commit comments

Comments
 (0)