From 767dc6ebda943710db86daa26f3213c7064cf56a Mon Sep 17 00:00:00 2001 From: Sion Kang Date: Tue, 13 Dec 2022 04:04:00 +0900 Subject: [PATCH 01/20] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7d9eda4d..e35f5f16 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Devrank +[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fboostcampwm-2022%2Fweb21-devrank&count_bg=%23C455F9&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com) + ![Frame 12023](https://user-images.githubusercontent.com/79798443/206137429-5cb1d269-4bec-4aaa-85ad-053ae564c625.png) **_Devrank_** 는 게임과 유사한 등급 시스템과 랭킹을 제공하여, Github 활동시 사용자에게 성취감을 주고 오픈소스 활동을 장려하는 서비스 입니다. From f5fdc3c814caabfc4b8397cc6bb7200df96ba77c Mon Sep 17 00:00:00 2001 From: Sion Kang <31057849+Yaminyam@users.noreply.github.com> Date: Tue, 13 Dec 2022 04:44:03 +0900 Subject: [PATCH 02/20] =?UTF-8?q?refactor:=20=EC=98=A4=EB=8A=98=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=EC=99=80=20=EA=B0=99=EC=9D=80=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?scoreHistory=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/user/user.service.ts | 42 ++++++++++++++------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/backend/src/user/user.service.ts b/backend/src/user/user.service.ts index 61b1f1de..5190c2c5 100644 --- a/backend/src/user/user.service.ts +++ b/backend/src/user/user.service.ts @@ -83,6 +83,24 @@ export class UserService { organizations, pinnedRepositories, }; + if (!updatedUser.scoreHistory) { + updatedUser.scoreHistory = []; + } + const KR_TIME_DIFF = 9 * 60 * 60 * 1000; + const utc = updatedUser.scoreHistory[updatedUser.scoreHistory.length - 1].date.getTime(); + if (new Date(utc + KR_TIME_DIFF).getDate() == new Date().getDate()) { + updatedUser.scoreHistory.pop(); + } + updatedUser.scoreHistory.push({ + date: new Date(), + score: updatedUser.score, + }); + if (updatedUser.scoreHistory.length > 1) { + updatedUser.scoreDifference = + updatedUser.score - updatedUser.scoreHistory[updatedUser.scoreHistory.length - 2].score; + } else { + updatedUser.scoreDifference = 0; + } user = await this.userRepository.createOrUpdate(updatedUser); const { totalRank, tierRank } = await this.setUserRelativeRanking(user); const userWithRank: UserProfileDto = { @@ -102,15 +120,6 @@ export class UserService { await sleep(GITHUB_API_DELAY); try { const updateUser = await this.updateUser(user.lowerUsername, githubToken); - if (!updateUser.scoreHistory) updateUser.scoreHistory = []; - if (updateUser.scoreHistory.length) updateUser.scoreHistory.pop(); - updateUser.scoreHistory.push({ date: new Date(), score: updateUser.score }); - if (updateUser.scoreHistory.length > 1) { - updateUser.scoreDifference = - updateUser.score - updateUser.scoreHistory[updateUser.scoreHistory.length - 2].score; - } else { - updateUser.scoreDifference = 0; - } this.userRepository.createOrUpdate(updateUser); this.userRepository.deleteCachedUserRank(updateUser.lowerUsername + '&'); } catch { @@ -126,17 +135,6 @@ export class UserService { await sleep(GITHUB_API_DELAY); try { const updatedUser = await this.updateUser(user.lowerUsername, githubToken); - if (!updatedUser.scoreHistory) updatedUser.scoreHistory = []; - updatedUser.scoreHistory.push({ - date: new Date(), - score: updatedUser.score, - }); - if (updatedUser.scoreHistory.length > 1) { - updatedUser.scoreDifference = - updatedUser.score - updatedUser.scoreHistory[updatedUser.scoreHistory.length - 2].score; - } else { - updatedUser.scoreDifference = 0; - } updatedUser.dailyViews = 0; this.userRepository.createOrUpdate(updatedUser); } catch { @@ -202,20 +200,16 @@ export class UserService { username: lowerUsername, id, }); - const personalResponse: any = await octokit.graphql(nonForkRepositoryQuery, { username: lowerUsername, id, }); - const followersResponse: any = await octokit.graphql(followersQuery, { username: lowerUsername, }); - const issuesResponse: any = await octokit.graphql(issueQuery, { username: lowerUsername, }); - let languagesScore = new Map(); function getCommitScore(acc: number, repository) { if (!repository.defaultBranchRef) { From 3ccffaffc07ec4ffb8b3357212fd6761e407a8aa Mon Sep 17 00:00:00 2001 From: Sion Kang <31057849+Yaminyam@users.noreply.github.com> Date: Tue, 13 Dec 2022 10:43:32 +0900 Subject: [PATCH 03/20] =?UTF-8?q?fix:=20cron=20=EC=8B=A4=ED=96=89=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20timeZone=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/batch/batch.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/batch/batch.service.ts b/backend/src/batch/batch.service.ts index 340a00df..ad8304e4 100644 --- a/backend/src/batch/batch.service.ts +++ b/backend/src/batch/batch.service.ts @@ -8,7 +8,7 @@ import { UserService } from '../user/user.service'; export class BatchService { constructor(private readonly userService: UserService, private readonly configService: ConfigService) {} - @Cron('0 0 0 * * *', { name: 'cronTask' }) + @Cron('0 0 0 * * *', { name: 'cronTask', timeZone: 'Asia/Seoul' }) handleCron() { logger.log('Task Called'); this.userService.dailyUpdateAllUsers(this.configService.get('GITHUB_PERSONAL_ACCESS_TOKEN')); From 5b99fa1c6b26fc72abc30e69667696085042a7e5 Mon Sep 17 00:00:00 2001 From: asdf99245 Date: Tue, 13 Dec 2022 11:42:49 +0900 Subject: [PATCH 04/20] =?UTF-8?q?feat:=20=EB=9D=BC=EC=9D=B8=EC=B0=A8?= =?UTF-8?q?=ED=8A=B8=20=EC=84=A0=20=EC=95=84=EB=9E=98=20=EC=98=81=EC=97=AD?= =?UTF-8?q?=20=EC=8B=9C=EC=9E=91=EC=84=A0=EC=84=A0=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Chart/LineChart/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/components/Chart/LineChart/index.tsx b/frontend/src/components/Chart/LineChart/index.tsx index 17229138..75c05024 100644 --- a/frontend/src/components/Chart/LineChart/index.tsx +++ b/frontend/src/components/Chart/LineChart/index.tsx @@ -20,6 +20,7 @@ function LineChart({ data, min, max, markers, tooltip }: LineChartProps) { margin={{ top: 60, right: 60, bottom: 60, left: 60 }} curve='monotoneX' enableArea={true} + areaBaselineValue={min || 0} xScale={{ type: 'time', format: '%Y-%m-%d', From 940a2d007c690ea6f9c13c7ffeb40f8252242fb5 Mon Sep 17 00:00:00 2001 From: asdf99245 Date: Tue, 13 Dec 2022 11:44:35 +0900 Subject: [PATCH 05/20] =?UTF-8?q?feat:=20=EC=8A=A4=EC=BD=94=EC=96=B4=20?= =?UTF-8?q?=ED=9E=88=EC=8A=A4=ED=86=A0=EB=A6=AC=20=EC=B0=A8=ED=8A=B8=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=8B=9C=EA=B0=84=20=ED=95=9C?= =?UTF-8?q?=EA=B5=AD=EC=8B=9C=EA=B0=84=EC=9C=BC=EB=A1=9C=20=EA=B3=A0?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/utils.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/utils/utils.ts b/frontend/src/utils/utils.ts index 41941ac8..74d2f2cf 100644 --- a/frontend/src/utils/utils.ts +++ b/frontend/src/utils/utils.ts @@ -26,6 +26,14 @@ export const getDate = (dateString: string) => { return { year, month, date, day }; }; +export const getKSTDateString = (date: Date) => { + const utc = date.getTime() + date.getTimezoneOffset() * 60 * 1000; + const KR_TIME_DIFF = 9 * 60 * 60 * 1000; + const kst_date = new Date(utc + KR_TIME_DIFF); + + return `${kst_date.getFullYear()}-${kst_date.getMonth() + 1}-${kst_date.getDate()}`; +}; + export const getProfileDescription = (locale: string, data: ProfileUserResponse) => { const { t } = useTranslation(); const { tier, score, totalRank, tierRank, primaryLanguages } = data; @@ -96,7 +104,7 @@ export const transScoreHistoryToLineChartData = (data: ScoreHistory[], tier: RAN { id: 'contribution', color: theme.colors[`${tier}2`], - data: data.map((value) => ({ x: value.date.slice(0, 10), y: value.score })), + data: data.map((value) => ({ x: getKSTDateString(new Date(value.date)), y: value.score })), }, ]; }; From ace985b618d443076b6219d888bb1aed5b84c65e Mon Sep 17 00:00:00 2001 From: asdf99245 Date: Tue, 13 Dec 2022 12:03:59 +0900 Subject: [PATCH 06/20] =?UTF-8?q?design=20=EB=9D=BC=EC=9D=B8=20=EC=B0=A8?= =?UTF-8?q?=ED=8A=B8=20axis=20=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EC=8A=A4?= =?UTF-8?q?=ED=83=80=EC=9D=BC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Chart/theme.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Chart/theme.json b/frontend/src/components/Chart/theme.json index 032bd9a3..4685f6b6 100644 --- a/frontend/src/components/Chart/theme.json +++ b/frontend/src/components/Chart/theme.json @@ -39,7 +39,8 @@ "strokeWidth": 1 }, "text": { - "fontSize": 14, + "fontSize": 12, + "fontWeight": 100, "fill": "#FBFBFB" } } From 0eccc5dd577233699ec291811643f599c584a99f Mon Sep 17 00:00:00 2001 From: asdf99245 Date: Tue, 13 Dec 2022 12:07:14 +0900 Subject: [PATCH 07/20] =?UTF-8?q?design:=20=EB=9D=BC=EC=9D=B8=EC=B0=A8?= =?UTF-8?q?=ED=8A=B8=20axis=20legend=20font=20weight=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Chart/theme.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/Chart/theme.json b/frontend/src/components/Chart/theme.json index 4685f6b6..f9444cc5 100644 --- a/frontend/src/components/Chart/theme.json +++ b/frontend/src/components/Chart/theme.json @@ -29,7 +29,7 @@ "legend": { "text": { "fontSize": 14, - "fontWeight": 700, + "fontWeight": 400, "fill": "#FBFBFB" } }, From d3cd0f019c764d24867e264d4c2f38afd987043f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=9A=B0=EC=84=9D?= Date: Tue, 13 Dec 2022 12:18:45 +0900 Subject: [PATCH 08/20] =?UTF-8?q?feat:=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=8B=A4=ED=8C=A8=ED=95=9C=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=B2=98=EB=A6=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/user/user.service.ts | 34 ++++++++++++++------------------ 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/backend/src/user/user.service.ts b/backend/src/user/user.service.ts index c19597a2..d99eb0f7 100644 --- a/backend/src/user/user.service.ts +++ b/backend/src/user/user.service.ts @@ -32,32 +32,28 @@ export class UserService { } async findOneByUsername(githubToken: string, ip: string, lowerUsername: string): Promise { - let user = null; - if (await this.userRepository.isDuplicatedRequestIp(ip, lowerUsername)) { - user = await this.userRepository.findOneByLowerUsername(lowerUsername); - } else { - user = await this.userRepository.findOneByLowerUsernameAndUpdateViews(lowerUsername); - } - + let user = await this.userRepository.findOneByLowerUsername(lowerUsername); if (!user) { - user = await this.updateUser(lowerUsername, githubToken); - if (!user.scoreHistory) { - user.scoreHistory = []; + try { + user = await this.updateUser(lowerUsername, githubToken); + if (!user.scoreHistory) { + user.scoreHistory = []; + } + user.scoreHistory.push({ date: new Date(), score: user.score }); + user = await this.userRepository.createOrUpdate(user); + } catch { + throw new HttpException(`can't update this user.`, HttpStatus.NO_CONTENT); } - user.scoreHistory.push({ date: new Date(), score: user.score }); - user = await this.userRepository.createOrUpdate(user); } - await this.userRepository.createOrUpdate(user); - const { totalRank, tierRank } = (await this.getUserRelativeRanking(user)) || (await this.setUserRelativeRanking(user)); + if (!(await this.userRepository.isDuplicatedRequestIp(ip, lowerUsername))) { + user.dailyViews += 1; + await this.userRepository.createOrUpdate(user); + } this.userRepository.setDuplicatedRequestIp(ip, lowerUsername); user.updateDelayTime = await this.userRepository.findUpdateScoreTimeToLive(lowerUsername); - user.totalRank = totalRank; - user.tierRank = tierRank; - user.startExp = getStartExp(user.score); - user.needExp = getNeedExp(user.score); - return user; + return { ...user, totalRank, tierRank, startExp: getStartExp(user.score), needExp: getNeedExp(user.score) }; } async findAllByPrefixUsername(limit: number, lowerUsername: string): Promise { From 556ffd1be1008e0762b43c8dad35a51495a06ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=9A=B0=EC=84=9D?= Date: Tue, 13 Dec 2022 12:19:08 +0900 Subject: [PATCH 09/20] =?UTF-8?q?feat:=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=8B=AA=ED=95=9C=20=EC=9C=A0=EC=A0=80=20updateDel?= =?UTF-8?q?ayTime=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/user/user.controller.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/backend/src/user/user.controller.ts b/backend/src/user/user.controller.ts index ba2dc5d7..2d1d232a 100644 --- a/backend/src/user/user.controller.ts +++ b/backend/src/user/user.controller.ts @@ -6,6 +6,7 @@ import { Controller, DefaultValuePipe, Get, + NotFoundException, Param, ParseIntPipe, Patch, @@ -74,18 +75,15 @@ export class UserController { @Param('username') username: string, ): Promise { const lowerUsername = username.toLowerCase(); - if ( - (await this.userService.findUpdateScoreTimeToLive(lowerUsername)) > 0 && - (await this.userService.findOneByFilter({ lowerUsername }))?.id !== id - ) { + const targetUser = await this.userService.findOneByFilter({ lowerUsername }); + if ((await this.userService.findUpdateScoreTimeToLive(lowerUsername)) > 0 && targetUser?.id !== id) { throw new BadRequestException('user score has been updated recently.'); } + await this.userService.setUpdateScoreDelayTime(lowerUsername, UPDATE_DELAY_TIME); const user = await this.userService.updateUser( lowerUsername, githubToken || this.configService.get('GITHUB_PERSONAL_ACCESS_TOKEN'), ); - - await this.userService.setUpdateScoreDelayTime(lowerUsername, UPDATE_DELAY_TIME); user.updateDelayTime = UPDATE_DELAY_TIME + 3; return user; } From 05554240ac2250dd765e856de92edfc3cf6bc2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=A5=EC=9A=B0=EC=84=9D?= Date: Tue, 13 Dec 2022 12:21:15 +0900 Subject: [PATCH 10/20] =?UTF-8?q?feat:=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=8B=A4=ED=8C=A8=20=EC=9C=A0=EC=A0=80=EB=8A=94=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=EC=88=98=20=EC=83=81=EC=8A=B9=20X?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/user/user.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/user/user.service.ts b/backend/src/user/user.service.ts index d99eb0f7..5591abac 100644 --- a/backend/src/user/user.service.ts +++ b/backend/src/user/user.service.ts @@ -47,7 +47,7 @@ export class UserService { } const { totalRank, tierRank } = (await this.getUserRelativeRanking(user)) || (await this.setUserRelativeRanking(user)); - if (!(await this.userRepository.isDuplicatedRequestIp(ip, lowerUsername))) { + if (!(await this.userRepository.isDuplicatedRequestIp(ip, lowerUsername)) && user.history) { user.dailyViews += 1; await this.userRepository.createOrUpdate(user); } From 4558defc72d7542b28876badfb8374616bfabc03 Mon Sep 17 00:00:00 2001 From: tunggary Date: Tue, 13 Dec 2022 14:41:39 +0900 Subject: [PATCH 11/20] =?UTF-8?q?fix:=20github=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/utils/constants.ts b/frontend/src/utils/constants.ts index 26236999..5e8a51cb 100644 --- a/frontend/src/utils/constants.ts +++ b/frontend/src/utils/constants.ts @@ -6,7 +6,7 @@ export const DEVICON_URL = 'https://cdn.jsdelivr.net/gh/devicons/devicon/icons/' export const DEVRANK_REPOSITORY_URL = 'https://github.com/boostcampwm-2022/web21-devrank'; -export const GITHUB_AUTH_REQUEST_URL = `https://github.com/login/oauth/authorize?client_id=${process.env.NEXT_PUBLIC_GITHUB_CLIENT_ID}&scope=user%20read:org`; +export const GITHUB_AUTH_REQUEST_URL = `https://github.com/login/oauth/authorize?client_id=${process.env.NEXT_PUBLIC_GITHUB_CLIENT_ID}&scope=read:user%20read:org`; export const MAIN_PAGE_RANK_COUNT = 12; From 29b42d2ab92d66fc286a1eb2aceb62d1e1997498 Mon Sep 17 00:00:00 2001 From: tunggary Date: Tue, 13 Dec 2022 14:42:23 +0900 Subject: [PATCH 12/20] =?UTF-8?q?fix:=20ProfileUserResponse=20type=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/type/response.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/type/response.ts b/frontend/src/type/response.ts index 6c76f3f4..80a9b9b6 100644 --- a/frontend/src/type/response.ts +++ b/frontend/src/type/response.ts @@ -71,7 +71,7 @@ export interface ProfileUserResponse { scoreHistory: ScoreHistory[]; updateDelayTime: number; primaryLanguages: [string]; - history: HistoryType; + history?: HistoryType; pinnedRepositories: PinnedRepositoryType[]; organizations: OrganizationType[]; totalRank: number; From 18d22cf09981c107caf0b222c1f81d78ace6396c Mon Sep 17 00:00:00 2001 From: tunggary Date: Tue, 13 Dec 2022 14:43:32 +0900 Subject: [PATCH 13/20] =?UTF-8?q?chore:=20invalid=20cube=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../public/icons/cube-large-background.svg | 21 ------------------- .../public/icons/cube/cube-small-invalid.svg | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) delete mode 100644 frontend/public/icons/cube-large-background.svg create mode 100644 frontend/public/icons/cube/cube-small-invalid.svg diff --git a/frontend/public/icons/cube-large-background.svg b/frontend/public/icons/cube-large-background.svg deleted file mode 100644 index 31fa0a67..00000000 --- a/frontend/public/icons/cube-large-background.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/frontend/public/icons/cube/cube-small-invalid.svg b/frontend/public/icons/cube/cube-small-invalid.svg new file mode 100644 index 00000000..a49c9a5e --- /dev/null +++ b/frontend/public/icons/cube/cube-small-invalid.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + From 062f8dc5565a0b271da2ed91924366ce9c826dd5 Mon Sep 17 00:00:00 2001 From: tunggary Date: Tue, 13 Dec 2022 14:44:03 +0900 Subject: [PATCH 14/20] =?UTF-8?q?refactor:=20ranking=20prefetch=20?= =?UTF-8?q?=EC=98=A4=ED=83=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/ranking.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/src/pages/ranking.tsx b/frontend/src/pages/ranking.tsx index 6b944a39..b2a1472f 100644 --- a/frontend/src/pages/ranking.tsx +++ b/frontend/src/pages/ranking.tsx @@ -129,9 +129,7 @@ export const getServerSideProps: GetServerSideProps = ssrWrapper( const query = queryValidator({ tier, username, page }); await Promise.allSettled([ queryClient.prefetchQuery(['user'], () => requestTokenRefresh(context)), - queryClient.prefetchQuery(['ranking', CUBE_RANK.ALL, ''], () => - requestTopRankingByScore({ limit: COUNT_PER_PAGE }), - ), + queryClient.prefetchQuery(['ranking', CUBE_RANK.ALL], () => requestTopRankingByScore({ limit: COUNT_PER_PAGE })), ]); return { From fed19089822dd77ac76f58e01a6d167fbf220fde Mon Sep 17 00:00:00 2001 From: tunggary Date: Tue, 13 Dec 2022 14:45:15 +0900 Subject: [PATCH 15/20] =?UTF-8?q?fix:=20logout=20=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Header/index.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/Header/index.tsx b/frontend/src/components/Header/index.tsx index 2cdecf7d..fa14d5fd 100644 --- a/frontend/src/components/Header/index.tsx +++ b/frontend/src/components/Header/index.tsx @@ -2,24 +2,25 @@ import { useTranslation } from 'next-i18next'; import Image from 'next/image'; import Link from 'next/link'; import { useRouter } from 'next/router'; +import { useState } from 'react'; import styled from 'styled-components'; -import { useMutation, useQuery } from '@tanstack/react-query'; +import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { Avatar, Button } from '@components/common'; import Dropdown from '@components/common/Dropdown'; import { requestTokenRefresh, requestUserLogout } from '@apis/auth'; import { GITHUB_AUTH_REQUEST_URL } from '@utils/constants'; function Header() { + const queryClient = useQueryClient(); + const { mutate: logout } = useMutation({ mutationFn: requestUserLogout, + onSuccess: () => queryClient.invalidateQueries(['user']), }); + const router = useRouter(); - const { - isLoading, - data: userData, - remove: removeUser, - } = useQuery(['user'], () => requestTokenRefresh(), { + const { isLoading, data: userData } = useQuery(['user'], () => requestTokenRefresh(), { enabled: router.pathname !== '/callback', cacheTime: Infinity, }); @@ -31,9 +32,8 @@ function Header() { window.location.assign(GITHUB_AUTH_REQUEST_URL); }; - const onClickLogoutButton = () => { + const onClickLogoutButton = async () => { logout(); - removeUser(); }; return ( From a7e20ef359b6459769067b0fda1ee2cef09dfa9d Mon Sep 17 00:00:00 2001 From: tunggary Date: Tue, 13 Dec 2022 14:46:02 +0900 Subject: [PATCH 16/20] =?UTF-8?q?feat:=20CubeLogo=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20invalid=20option=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Profile/ProfileCard/index.tsx | 47 +++++++++++-------- .../src/components/common/CubeLogo/index.tsx | 42 ++++++++++++----- 2 files changed, 57 insertions(+), 32 deletions(-) diff --git a/frontend/src/components/Profile/ProfileCard/index.tsx b/frontend/src/components/Profile/ProfileCard/index.tsx index d4700fc4..f1a03b2c 100644 --- a/frontend/src/components/Profile/ProfileCard/index.tsx +++ b/frontend/src/components/Profile/ProfileCard/index.tsx @@ -28,6 +28,7 @@ interface ProfileCardProps { updateData: () => void; isLoading: boolean; isMine: boolean; + isInvalid: boolean; }; } @@ -53,6 +54,7 @@ function ProfileCard({ profileData }: ProfileCardProps) { updateData, isLoading, isMine, + isInvalid, } = profileData; const { t } = useTranslation(['profile', 'tier']); @@ -119,18 +121,24 @@ function ProfileCard({ profileData }: ProfileCardProps) { )} - -
-

- {t('profile:total')} {totalRank} - {getRankingUnit(locale, totalRank)} -

-

- {t(`tier:${tier}`)} -  {tierRank} - {getRankingUnit(locale, tierRank)} -

-
+ + {isInvalid ? ( + +

등수를 표시할 수 없습니다.

+
+ ) : ( + +

+ {t('profile:total')} {totalRank} + {getRankingUnit(locale, totalRank)} +

+

+ {t(`tier:${tier}`)} +  {tierRank} + {getRankingUnit(locale, tierRank)} +

+
+ )}
); @@ -172,15 +180,14 @@ const ProfileInfos = styled.ul` const ProfileRank = styled.div` max-width: 300px; width: 100%; - div { - margin-top: 20px; - ${({ theme }) => theme.common.flexCenterColumn}; - p { - margin-top: 8px; - } - } + ${({ theme }) => theme.common.flexCenterColumn}; +`; - transform: translateZ(-50); +const RankText = styled.div` + margin-top: 20px; + p { + margin-top: 8px; + } `; const ImageStyle = { diff --git a/frontend/src/components/common/CubeLogo/index.tsx b/frontend/src/components/common/CubeLogo/index.tsx index 6ab645fe..2182ac2b 100644 --- a/frontend/src/components/common/CubeLogo/index.tsx +++ b/frontend/src/components/common/CubeLogo/index.tsx @@ -1,3 +1,4 @@ +import Image from 'next/image'; import React from 'react'; import styled, { css, keyframes } from 'styled-components'; import { CubeRankType } from '@type/common'; @@ -7,6 +8,7 @@ type sizeType = 'sm' | 'lg'; interface CubeLogoProps { size: sizeType; tier: CubeRankType; + isInvalid?: boolean; } interface StyledSVGProps { @@ -67,21 +69,32 @@ const CUBE_PATH_LIST = [ 'M258.05 95.2628L257.925 130.472L290.049 147.733L320.512 129.625L321.629 94.4603L288.931 78.2781L258.05 95.2628Z', ]; -function CubeLogo({ size, tier }: CubeLogoProps) { +function CubeLogo({ size, tier, isInvalid = false }: CubeLogoProps) { return ( - - {CUBE_PATH_LIST.map((d) => ( - - ))} - + {isInvalid ? ( + + ) : ( + + {CUBE_PATH_LIST.map((d) => ( + + ))} + + )} ); } @@ -160,6 +173,11 @@ const Svg = styled.svg` animation: ${floating} 4s cubic-bezier(0.28, 0, 0.44, 0.99) infinite; `; +const InvalidSvg = styled(Image)` + z-index: 1; + animation: ${floating} 4s cubic-bezier(0.28, 0, 0.44, 0.99) infinite; +`; + const Path = styled.path` fill: ${({ tier }) => tier !== 'all' && CUBE_COLOR_MAP[tier]}; ${({ tier }) => From eb07bf638282db4c081a8a4b90e707859a4259ed Mon Sep 17 00:00:00 2001 From: tunggary Date: Tue, 13 Dec 2022 14:46:56 +0900 Subject: [PATCH 17/20] =?UTF-8?q?refactor:=20invalid=20cube=20path=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Ranking/NotFound/index.tsx | 3 +- frontend/src/pages/404.tsx | 3 +- frontend/src/pages/profile/404.tsx | 5 +- frontend/src/pages/profile/[username].tsx | 93 +++++++++++++++---- 4 files changed, 81 insertions(+), 23 deletions(-) diff --git a/frontend/src/components/Ranking/NotFound/index.tsx b/frontend/src/components/Ranking/NotFound/index.tsx index 60bf7bc3..6960b6e9 100644 --- a/frontend/src/components/Ranking/NotFound/index.tsx +++ b/frontend/src/components/Ranking/NotFound/index.tsx @@ -11,7 +11,7 @@ function NotFound() {

Oops!

{t('404:user-not-found')}

- EXP - - - Contributions -

{`${t('maximum-continuous-commit-history')} : ${data.history.maxContinuousCount}${ - data.history.maxContinuousCount >= MAX_COMMIT_STREAK ? `${t('day')}~` : t('day') - }`}

-
- - - - Stats - - - - Pinned Repositories - - - + {data.history ? ( + <> + EXP + + + Contributions +

{`${t('maximum-continuous-commit-history')} : ${data.history.maxContinuousCount}${ + data.history.maxContinuousCount >= MAX_COMMIT_STREAK ? `${t('day')}~` : t('day') + }`}

+
+ + + + Stats + + + + Pinned Repositories + + + + + ) : ( + +
+ +
+ Invalid User +

정보를 불러올 수 없는 유저입니다.

+
+ )} )} @@ -153,3 +174,37 @@ const ContributionHeader = styled.div` margin: 80px 20px 10px; } `; + +const Alert = styled.div` + ${({ theme }) => theme.common.flexCenterColumn}; + width: 100%; + background-color: ${({ theme }) => theme.colors.black4}; + margin-top: 60px; + position: relative; + height: 600px; + + div { + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + } + + strong { + z-index: 1; + font-size: 50px; + margin-bottom: 44px; + } + + p { + z-index: 1; + font-size: 28px; + } +`; + +const CubeImage = styled(Image)` + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +`; From e99650201c0eeb6526078dd525d1eb84c5daacb7 Mon Sep 17 00:00:00 2001 From: tunggary Date: Tue, 13 Dec 2022 14:59:11 +0900 Subject: [PATCH 18/20] =?UTF-8?q?chore:=20=EA=B5=AD=EC=A0=9C=ED=99=94=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/public/locales/en/profile.json | 4 +++- frontend/public/locales/ko/profile.json | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/public/locales/en/profile.json b/frontend/public/locales/en/profile.json index bc3dd0f5..85c055a7 100644 --- a/frontend/public/locales/en/profile.json +++ b/frontend/public/locales/en/profile.json @@ -6,5 +6,7 @@ "user-update-delay": "You can update it in", "day": "day", "total": "Total", - "rank": "Rank" + "rank": "Rank", + "invalid-user": "This user cannot get information", + "invalid-rank": "Unable to get the rank" } diff --git a/frontend/public/locales/ko/profile.json b/frontend/public/locales/ko/profile.json index 5f61cdac..8e897e45 100644 --- a/frontend/public/locales/ko/profile.json +++ b/frontend/public/locales/ko/profile.json @@ -6,5 +6,7 @@ "user-update-delay": "초 후 업데이트 가능합니다.", "day": "일", "total": "전체", - "rank": "등급" + "rank": "등급", + "invalid-user": "정보를 가져올 수 없는 유저입니다", + "invalid-rank": "등수를 표시할 수 없습니다" } From 295978bfe34289c608492d6729828353948606e1 Mon Sep 17 00:00:00 2001 From: tunggary Date: Tue, 13 Dec 2022 14:59:28 +0900 Subject: [PATCH 19/20] =?UTF-8?q?refactor:=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Header/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/components/Header/index.tsx b/frontend/src/components/Header/index.tsx index fa14d5fd..0c060a33 100644 --- a/frontend/src/components/Header/index.tsx +++ b/frontend/src/components/Header/index.tsx @@ -2,7 +2,6 @@ import { useTranslation } from 'next-i18next'; import Image from 'next/image'; import Link from 'next/link'; import { useRouter } from 'next/router'; -import { useState } from 'react'; import styled from 'styled-components'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { Avatar, Button } from '@components/common'; @@ -32,7 +31,7 @@ function Header() { window.location.assign(GITHUB_AUTH_REQUEST_URL); }; - const onClickLogoutButton = async () => { + const onClickLogoutButton = () => { logout(); }; From f8c38a2ed11206593d5901c7998aef7f0d447c40 Mon Sep 17 00:00:00 2001 From: tunggary Date: Tue, 13 Dec 2022 14:59:52 +0900 Subject: [PATCH 20/20] =?UTF-8?q?feat:=20=EA=B5=AD=EC=A0=9C=ED=99=94=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/Profile/ProfileCard/index.tsx | 2 +- frontend/src/pages/profile/[username].tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Profile/ProfileCard/index.tsx b/frontend/src/components/Profile/ProfileCard/index.tsx index f1a03b2c..ff488954 100644 --- a/frontend/src/components/Profile/ProfileCard/index.tsx +++ b/frontend/src/components/Profile/ProfileCard/index.tsx @@ -124,7 +124,7 @@ function ProfileCard({ profileData }: ProfileCardProps) { {isInvalid ? ( -

등수를 표시할 수 없습니다.

+

{t('profile:invalid-rank')}

) : ( diff --git a/frontend/src/pages/profile/[username].tsx b/frontend/src/pages/profile/[username].tsx index 7cb1b893..4624969b 100644 --- a/frontend/src/pages/profile/[username].tsx +++ b/frontend/src/pages/profile/[username].tsx @@ -105,7 +105,7 @@ function Profile({ username }: ProfileProps) { />
Invalid User -

정보를 불러올 수 없는 유저입니다.

+

{t('profile:invalid-user')}

)}