Skip to content

Commit

Permalink
⚡ slack 직접 쏘는 대신 와닷api 적용 (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
woohm402 authored Jul 6, 2024
1 parent 1f80d32 commit 86e0447
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 61 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"dependencies": {
"express": "4.19.2",
"octokit": "4.0.2",
"openai": "4.52.1",
"p-limit": "5.0.0"
"openai": "4.52.1"
},
"devDependencies": {
"@types/express": "4.17.21",
Expand Down
48 changes: 0 additions & 48 deletions src/infrastructures/implementMemberSlackRepository.ts

This file was deleted.

21 changes: 21 additions & 0 deletions src/infrastructures/implementMemberWaffleDotComRepository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Member } from '../entities/Member';

/*
* API
* @see https://wafflestudio.slack.com/archives/C06H0PJPDNH/p1720256977566729?thread_ts=1707317300.593519&cid=C06H0PJPDNH
*/
export const implementMemberWaffleDotComRepository = (): {
getAllMembers: () => Promise<{ members: Member[] }>;
} => {
return {
getAllMembers: async () => {
const users = await fetch('https://wadot-api.wafflestudio.com/api/v1/users', {
method: 'GET',
}).then((res) => res.json() as Promise<{ github_id: string; slack_id: string }[]>);

return {
members: users.map((user) => ({ slackUserId: user.slack_id, githubUsername: user.github_id })),
};
},
};
};
4 changes: 2 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import dotenv from 'dotenv';
import express from 'express';

import { implementGitHubDeployWebhookController } from './infrastructures/implementGitHubDeployWebhookController';
import { implementMemberSlackRepository } from './infrastructures/implementMemberSlackRepository';
import { implementMemberWaffleDotComRepository } from './infrastructures/implementMemberWaffleDotComRepository';
import { implementOpenAiSummarizeRepository } from './infrastructures/implementOpenAiSummarizeRepository';
import { implementSlackPresenter } from './infrastructures/implementSlackPresenter';
import { implementDeploymentService } from './services/GithubDeploymentService';
Expand Down Expand Up @@ -46,7 +46,7 @@ const deployWebhookController = implementGitHubDeployWebhookController({
channelId: deployWatcherChannelId,
}),
summarizeLLMRepository: implementOpenAiSummarizeRepository({ openaiApiKey }),
memberRepository: implementMemberSlackRepository({ slackAuthToken }),
memberRepository: implementMemberWaffleDotComRepository(),
}),
});

Expand Down
4 changes: 2 additions & 2 deletions src/weekly-dashboard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dotenv from 'dotenv';

import { implementGithubOctokitRepository } from './infrastructures/implementGithubOctokitRepository';
import { implementMemberSlackRepository } from './infrastructures/implementMemberSlackRepository';
import { implementMemberWaffleDotComRepository } from './infrastructures/implementMemberWaffleDotComRepository';
import { implementSlackPresenter } from './infrastructures/implementSlackPresenter';
import { implementDashboardService } from './services/DashboardService';

Expand Down Expand Up @@ -29,7 +29,7 @@ if (!githubOrganization) throw new Error('Missing Github Organization');
const dashboardService = implementDashboardService({
githubApiRepository: implementGithubOctokitRepository({ githubAuthToken: githubAccessToken }),
messengerPresenter: implementSlackPresenter({ slackAuthToken, channelId: slackWeeklyChannelId }),
memberRepository: implementMemberSlackRepository({ slackAuthToken }),
memberRepository: implementMemberWaffleDotComRepository(),
});

dashboardService.sendWeeklyDashboard(githubOrganization).catch(console.error);
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1901,20 +1901,20 @@ optionator@^0.9.3:
type-check "^0.4.0"
word-wrap "^1.2.5"

[email protected], p-limit@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-5.0.0.tgz#6946d5b7140b649b7a33a027d89b4c625b3a5985"
integrity sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==
dependencies:
yocto-queue "^1.0.0"

p-limit@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b"
integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==
dependencies:
yocto-queue "^0.1.0"

p-limit@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-5.0.0.tgz#6946d5b7140b649b7a33a027d89b4c625b3a5985"
integrity sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==
dependencies:
yocto-queue "^1.0.0"

p-locate@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834"
Expand Down

0 comments on commit 86e0447

Please sign in to comment.