From 7a4068dfddaec8b804e56d4aa6bd0b1278efb9f3 Mon Sep 17 00:00:00 2001 From: tunggary Date: Fri, 16 Dec 2022 11:18:49 +0900 Subject: [PATCH 1/8] =?UTF-8?q?refactor:=20update=20=EC=9A=94=EC=B2=AD?= =?UTF-8?q?=EC=97=90=20=EA=B2=BD=EC=9A=B0=20err=20=EC=A0=84=EB=8B=AC?= =?UTF-8?q?=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/axiosInstance.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/utils/axiosInstance.ts b/frontend/src/utils/axiosInstance.ts index aeb692bd..de6ea664 100644 --- a/frontend/src/utils/axiosInstance.ts +++ b/frontend/src/utils/axiosInstance.ts @@ -34,6 +34,10 @@ instance.interceptors.response.use( } } } + + if (originConfig.url.startsWith('/users/') && originConfig.method === 'patch') { + return Promise.reject(err); + } }, ); From c8de48c2453c51a6ae51b98066952fd61985cbbb Mon Sep 17 00:00:00 2001 From: tunggary Date: Fri, 16 Dec 2022 11:19:33 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20update=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC=20=ED=95=B8=EB=93=A4=EB=A7=81=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 --- frontend/src/pages/profile/[username].tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/profile/[username].tsx b/frontend/src/pages/profile/[username].tsx index 276994b4..dea766e8 100644 --- a/frontend/src/pages/profile/[username].tsx +++ b/frontend/src/pages/profile/[username].tsx @@ -1,6 +1,7 @@ import { GetServerSideProps } from 'next'; import { useTranslation } from 'next-i18next'; import Image from 'next/image'; +import { AxiosError } from 'axios'; import { useEffect } from 'react'; import styled from 'styled-components'; import { useQueryData } from '@hooks'; @@ -29,10 +30,20 @@ function Profile({ username }: ProfileProps) { const { mutate, isLoading } = useMutation({ mutationFn: () => requestUserInfoByUsername({ username, method: 'PATCH' }), - onError: () => alert('최근에 업데이트 했습니다.'), + onError: (err) => updateErrorHandler(err), onSettled: () => refetch(), }); + const { t } = useTranslation(['profile', 'meta']); + const updateErrorHandler = (err: unknown) => { + if (err instanceof AxiosError && err.response) { + if (err.response.status >= 500) { + alert('정보를 불러올 수 없는 유저입니다.'); + } else if (err.response.status >= 400) { + alert('최근에 업데이트 했습니다. 잠시 후 다시 시도해주세요.'); + } + } + }; useEffect(() => { requestTokenRefresh(); From f295c3d3c29b7f6fc561f9de93d249bd502f1428 Mon Sep 17 00:00:00 2001 From: asdf99245 Date: Fri, 16 Dec 2022 11:20:36 +0900 Subject: [PATCH 3/8] =?UTF-8?q?fix:=20useInterval=20=EB=B9=84=ED=99=9C?= =?UTF-8?q?=EC=84=B1=20=EC=83=81=ED=83=9C=EC=8B=9C=20=EB=8F=99=EC=9E=91=20?= =?UTF-8?q?=EB=B8=94=EB=A1=9C=ED=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Profile/ProfileRefreshButton/index.tsx | 10 +++++++--- frontend/src/hooks/useInterval.ts | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/Profile/ProfileRefreshButton/index.tsx b/frontend/src/components/Profile/ProfileRefreshButton/index.tsx index ed5228c9..6b9d1245 100644 --- a/frontend/src/components/Profile/ProfileRefreshButton/index.tsx +++ b/frontend/src/components/Profile/ProfileRefreshButton/index.tsx @@ -13,9 +13,13 @@ interface ProfileRefreshButtonProps { function ProfileRefreshButton({ updateDelayTime, updateData, isLoading, isMine }: ProfileRefreshButtonProps) { const [count, setCount] = useState(updateDelayTime); - useInterval(() => { - setCount(count - 1); - }, 1000); + useInterval( + () => { + setCount(count - 1); + }, + 1000, + count > 0, + ); useEffect(() => { setCount(updateDelayTime); diff --git a/frontend/src/hooks/useInterval.ts b/frontend/src/hooks/useInterval.ts index d1cfaa2f..18aca103 100644 --- a/frontend/src/hooks/useInterval.ts +++ b/frontend/src/hooks/useInterval.ts @@ -4,7 +4,7 @@ interface CallbackType { (): void; } -export function useInterval(callback: CallbackType, delay: number) { +export function useInterval(callback: CallbackType, delay: number, isActivate: boolean) { const savedCallback = useRef(); useEffect(() => { @@ -14,6 +14,8 @@ export function useInterval(callback: CallbackType, delay: number) { }, [callback]); useEffect(() => { + if (!isActivate) return; + function tick() { if (savedCallback.current) { savedCallback.current(); @@ -21,6 +23,9 @@ export function useInterval(callback: CallbackType, delay: number) { } const id = setInterval(tick, delay); - return () => clearInterval(id); - }, [delay]); + + return () => { + clearInterval(id); + }; + }, [delay, isActivate]); } From 05eec1ff8403a4088741218718a75831d59f9f07 Mon Sep 17 00:00:00 2001 From: asdf99245 Date: Fri, 16 Dec 2022 11:20:50 +0900 Subject: [PATCH 4/8] =?UTF-8?q?chore:=20.gitignore=20storybook-static=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 8239645e..a37a4cc9 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,6 @@ dist # TernJS port file .tern-port + +# storybook +storybook-static \ No newline at end of file From d05e74ef2c181d93ead6cc729f135800ac425810 Mon Sep 17 00:00:00 2001 From: tunggary Date: Fri, 16 Dec 2022 11:49:45 +0900 Subject: [PATCH 5/8] =?UTF-8?q?refactor:=20callback=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=20useCallback=EC=9C=BC=EB=A1=9C=20=EB=A9=94=EB=AA=A8=EC=9D=B4?= =?UTF-8?q?=EC=A0=9C=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Profile/ProfileRefreshButton/index.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/Profile/ProfileRefreshButton/index.tsx b/frontend/src/components/Profile/ProfileRefreshButton/index.tsx index 6b9d1245..86b2e36a 100644 --- a/frontend/src/components/Profile/ProfileRefreshButton/index.tsx +++ b/frontend/src/components/Profile/ProfileRefreshButton/index.tsx @@ -1,6 +1,6 @@ import { Trans } from 'next-i18next'; import Image from 'next/image'; -import React, { useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import styled, { keyframes } from 'styled-components'; import { useInterval } from '@hooks/useInterval'; @@ -13,13 +13,9 @@ interface ProfileRefreshButtonProps { function ProfileRefreshButton({ updateDelayTime, updateData, isLoading, isMine }: ProfileRefreshButtonProps) { const [count, setCount] = useState(updateDelayTime); - useInterval( - () => { - setCount(count - 1); - }, - 1000, - count > 0, - ); + const countDown = useCallback(() => setCount((prev) => prev - 1), []); + + useInterval(countDown, 1000, count > 0); useEffect(() => { setCount(updateDelayTime); From 128c10a36a93519e16ab89ccfabf0f72251e60b6 Mon Sep 17 00:00:00 2001 From: tunggary Date: Fri, 16 Dec 2022 11:50:06 +0900 Subject: [PATCH 6/8] =?UTF-8?q?refactor:=20useInterval=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/hooks/useInterval.ts | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/frontend/src/hooks/useInterval.ts b/frontend/src/hooks/useInterval.ts index 18aca103..c9ccd424 100644 --- a/frontend/src/hooks/useInterval.ts +++ b/frontend/src/hooks/useInterval.ts @@ -1,31 +1,17 @@ -import { useEffect, useRef } from 'react'; +import { useEffect } from 'react'; interface CallbackType { (): void; } export function useInterval(callback: CallbackType, delay: number, isActivate: boolean) { - const savedCallback = useRef(); - - useEffect(() => { - if (callback) { - savedCallback.current = callback; - } - }, [callback]); - useEffect(() => { if (!isActivate) return; - function tick() { - if (savedCallback.current) { - savedCallback.current(); - } - } - - const id = setInterval(tick, delay); + const id = setInterval(callback, delay); return () => { clearInterval(id); }; - }, [delay, isActivate]); + }, [callback, delay, isActivate]); } From 96269559d4f50a27a09cb6fa19557e73802a5236 Mon Sep 17 00:00:00 2001 From: Sion Kang <31057849+Yaminyam@users.noreply.github.com> Date: Tue, 20 Dec 2022 18:17:22 +0900 Subject: [PATCH 7/8] =?UTF-8?q?fix:=20fork=20=EB=A0=88=ED=8F=AC=EC=9D=98?= =?UTF-8?q?=20commit=20=EC=A0=90=EC=88=98=20=EC=82=B0=EC=A0=95=EC=9D=84=20?= =?UTF-8?q?5=EB=85=84=EC=9C=BC=EB=A1=9C=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/libs/consts/index.ts | 10 +++++++++- backend/src/user/utils/query.ts | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/libs/consts/index.ts b/backend/libs/consts/index.ts index 7867a849..747e8618 100644 --- a/backend/libs/consts/index.ts +++ b/backend/libs/consts/index.ts @@ -1,5 +1,13 @@ const MINUTE = 60; -const HOUR = 60 * MINUTE; +export const HOUR = 60 * MINUTE; + +export const DAY = 24 * HOUR; + +export const WEEK = 7 * DAY; + +export const MONTH = 30 * DAY; + +export const YEAR = 365 * DAY; export const EXPIRATION = { ACCESS_TOKEN: 600, diff --git a/backend/src/user/utils/query.ts b/backend/src/user/utils/query.ts index 35213b15..589a9716 100644 --- a/backend/src/user/utils/query.ts +++ b/backend/src/user/utils/query.ts @@ -1,3 +1,5 @@ +import { YEAR } from '@libs/consts'; + export const pinnedRepositoriesQuery = `query pinnedReposities($username: String!) { user(login: $username) { organizations(first:100) { @@ -110,7 +112,9 @@ export const forkRepositoryQuery = `query repositories($username: String!, $id: defaultBranchRef { target { ... on Commit { - history(author: {id: $id}, first: 100) { + history(author: {id: $id}, first: 100, since: ${new Date( + new Date().getTime() - 5 * YEAR * 1000, + ).toISOString()}) { nodes { committedDate } From 107b96cf8e87bd04e004b361fb38140d19e9fa35 Mon Sep 17 00:00:00 2001 From: Sion Kang <31057849+Yaminyam@users.noreply.github.com> Date: Fri, 30 Dec 2022 21:59:56 +0900 Subject: [PATCH 8/8] fix: fork commit limit 5years --- backend/src/user/utils/query.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/src/user/utils/query.ts b/backend/src/user/utils/query.ts index 589a9716..c1f66a2a 100644 --- a/backend/src/user/utils/query.ts +++ b/backend/src/user/utils/query.ts @@ -112,9 +112,7 @@ export const forkRepositoryQuery = `query repositories($username: String!, $id: defaultBranchRef { target { ... on Commit { - history(author: {id: $id}, first: 100, since: ${new Date( - new Date().getTime() - 5 * YEAR * 1000, - ).toISOString()}) { + history(author: {id: $id}, since: "${new Date(new Date().getTime() - 3 * YEAR * 1000).toISOString()}") { nodes { committedDate }