Skip to content

Commit eca2ace

Browse files
committed
Merge branch 'main' into refactor/test-code
2 parents dc5406b + 98d11a8 commit eca2ace

File tree

8 files changed

+60
-41
lines changed

8 files changed

+60
-41
lines changed

.github/workflows/docker-publish.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ jobs:
2727
- name: Create .env file
2828
run: |
2929
echo "NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }}" >> .env
30-
echo "NEXT_PUBLIC_VELOG_URL=${{ secrets.NEXT_PUBLIC_VELOG_URL }}" >> .env
31-
echo "NEXT_PUBLIC_ABORT_MS=${{ secrets.NEXT_PUBLIC_ABORT_MS }}" >> .env
32-
echo "NEXT_PUBLIC_EVENT_LOG=${{ secrets.NEXT_PUBLIC_EVENT_LOG }}" >> .env
3330
echo "NEXT_PUBLIC_SENTRY_AUTH_TOKEN=${{ secrets.NEXT_PUBLIC_SENTRY_AUTH_TOKEN }}" >> .env
3431
echo "NEXT_PUBLIC_CHANNELTALK_PLUGIN_KEY=${{ secrets.NEXT_PUBLIC_CHANNELTALK_PLUGIN_KEY }}" >> .env
3532
echo "NEXT_PUBLIC_GA_ID=${{ secrets.NEXT_PUBLIC_GA_ID }}" >> .env
3633
echo "NEXT_PUBLIC_SENTRY_DSN=${{ secrets.NEXT_PUBLIC_SENTRY_DSN }}" >> .env
37-
echo "NEXT_PUBLIC_ARCADE_URL=${{ secrets.NEXT_PUBLIC_ARCADE_URL }}" >> .env
3834
cp .env .env.production
3935
4036
- name: Build Next.js application

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ COPY .env.production ./.env.production
1616
COPY package.json pnpm-lock.yaml ./
1717
RUN pnpm install --no-frozen-lockfile --prod
1818

19-
2019
EXPOSE 3000
2120

2221
CMD ["pm2-runtime", "start", "ecosystem.config.js"]

src/apis/instance.request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import returnFetch, { FetchArgs } from 'return-fetch';
33
import { ENVS } from '@/constants';
44
import { ServerNotRespondingError } from '@/errors';
55

6-
const ABORT_MS = 10000;
6+
const ABORT_MS = 5000;
77

88
type ErrorType = {
99
code: string;

src/app/(auth-required)/leaderboards/Content.tsx

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { startHolyLoader } from 'holy-loader';
55
import { useMemo } from 'react';
66
import { leaderboardList } from '@/apis';
77
import { Rank } from '@/app/components';
8-
import { PATHS } from '@/constants';
8+
import { PATHS, URLS } from '@/constants';
99
import { useSearchParam } from '@/hooks';
1010
import { Dropdown, EmptyState } from '@/shared';
1111
import { LeaderboardItemType } from '@/types';
@@ -17,17 +17,16 @@ export type searchParamsType = {
1717
dateRange: string;
1818
};
1919

20+
const defaultParams = {
21+
based: 'user' as const,
22+
sort: 'viewCount' as const,
23+
limit: '10',
24+
dateRange: '30',
25+
};
26+
2027
export const Content = () => {
2128
const [searchParams, setSearchParams] = useSearchParam<searchParamsType>();
2229

23-
// 기본값 설정
24-
const defaultParams = {
25-
based: 'user' as const,
26-
sort: 'viewCount' as const,
27-
limit: '10',
28-
dateRange: '30',
29-
};
30-
3130
const finalParams = {
3231
...defaultParams,
3332
...searchParams,
@@ -39,16 +38,18 @@ export const Content = () => {
3938
});
4039

4140
const data = useMemo(() => {
42-
const value = (
43-
finalParams.based === 'user' ? boards?.users : boards?.posts
44-
) as LeaderboardItemType[];
45-
return (
46-
value?.map((item) => ({
47-
name: finalParams.based === 'user' ? item.email.split('@')[0] : item.title,
48-
value: finalParams.sort === 'viewCount' ? item.viewDiff : item.likeDiff,
49-
})) || []
50-
);
51-
}, [boards, finalParams.based, finalParams.sort]);
41+
const isUserBased = finalParams?.based === 'user';
42+
const isViewBased = finalParams?.sort === 'viewCount';
43+
44+
const value = ((isUserBased ? boards?.users : boards?.posts) || []) as LeaderboardItemType[];
45+
46+
return value.map(({ username, title, viewDiff, likeDiff, slug }) => ({
47+
key: isUserBased ? username : title,
48+
username,
49+
url: URLS.VELOG + `/@${username}` + (isUserBased ? '/posts' : `/${slug}`),
50+
value: isViewBased ? viewDiff : likeDiff,
51+
}));
52+
}, [boards, finalParams?.based, finalParams?.sort]);
5253

5354
const handleChange = (param: Partial<searchParamsType>) => {
5455
startHolyLoader();
@@ -109,8 +110,15 @@ export const Content = () => {
109110
icon="📊"
110111
/>
111112
) : (
112-
data?.map(({ name, value }, index) => (
113-
<Rank name={name} key={index} count={value} rank={index + 1} />
113+
data?.map(({ key, username, url, value }, index) => (
114+
<Rank
115+
name={key}
116+
key={index}
117+
url={url}
118+
count={value}
119+
rank={index + 1}
120+
suffix={finalParams.based === 'post' ? username : ''}
121+
/>
114122
))
115123
)}
116124
</div>

src/app/(auth-required)/main/Content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const Content = () => {
5252
fetchNextPage();
5353
}, [inView]);
5454

55-
const joinedPosts = useMemo(() => posts?.pages.flatMap((i) => i.posts), [posts]);
55+
const joinedPosts = useMemo(() => posts?.pages.flatMap((i) => i.posts) || [], [posts]);
5656

5757
// 로딩 중이 아니고 게시물이 없는 경우
5858
const isEmpty = !isLoading && (!joinedPosts || joinedPosts.length === 0);

src/app/components/Rank.tsx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
1+
'use client';
2+
13
import { HTMLAttributes } from 'react';
24
import { twMerge } from 'tailwind-merge';
35

46
export interface IProp extends HTMLAttributes<HTMLDivElement> {
57
name: string;
68
rank: number;
9+
url: string;
710
count?: string | number;
811
suffix?: string;
912
}
1013

1114
const colorTable = ['border-[#DAA520]', 'border-[#A9A9A9]', 'border-[#B87333]'];
1215

13-
export const Rank = ({ name, rank, count, suffix = '회' }: IProp) => {
16+
export const Rank = ({ name, rank, count, url, suffix }: IProp) => {
1417
return (
15-
<div
18+
<button
1619
className={twMerge(
17-
'min-w-[40%] w-full p-[25px] bg-BG-SUB rounded-[4px] gap-3 justify-between flex',
20+
'min-w-[40%] group w-full p-[25px] bg-BG-SUB rounded-[4px] gap-3 justify-between flex cursor-pointer items-center',
1821
rank > 3 ? 'border-0' : `border-2 ${colorTable[rank - 1]}`,
1922
)}
23+
onClick={() => window.open(url, '_blank', 'noopener,noreferrer')}
2024
>
21-
<span
22-
data-rank={rank}
23-
className="text-TITLE-3 text-TEXT-MAIN flex items-center gap-3 before:content-[attr(data-rank)_'위'] before:text-SUBTITLE-4 before:text-TEXT-ALT max-TBL:text-TITLE-4 max-TBL:before:text-SUBTITLE-5 max-MBI:text-SUBTITLE-4 max-MBI:before:text-SUBTITLE-5"
24-
>
25-
{name}
26-
</span>
25+
<div className="flex items-center gap-3">
26+
<span className="text-SUBTITLE-4 text-TEXT-ALT shrink-0 max-TBL:text-SUBTITLE-5 max-MBI:text-SUBTITLE-5">
27+
{rank + '위'}
28+
</span>
29+
30+
<div className="flex flex-col gap-0 items-start">
31+
<span className="group-hover:underline break-words text-left text-TITLE-3 text-TEXT-MAIN flex items-center gap-3 max-TBL:text-TITLE-4 max-MBI:text-SUBTITLE-4">
32+
{name}
33+
</span>
34+
{suffix !== undefined && (
35+
<span className="text-SUBTITLE-4 w-fit text-TEXT-ALT max-TBL:text-SUBTITLE-5 max-MBI:text-SUBTITLE-5">
36+
{String(suffix)}
37+
</span>
38+
)}
39+
</div>
40+
</div>
41+
2742
<span className="text-SUBTITLE-3 shrink-0 text-TEXT-SUB max-TBL:text-TITLE-4 max-MBI:text-SUBTITLE-4">
28-
{count}
29-
{suffix}
43+
{count}
3044
</span>
31-
</div>
45+
</button>
3246
);
3347
};

src/app/components/Summary/SidebarContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const SidebarContent = ({ title, content, increasement, typeIsCount, id }
2424
<Inform.Title>{title}</Inform.Title>
2525
<Inform.Horizontal>
2626
<Inform.Content suffix={typeIsCount ? '회' : '개'}>{parseNumber(content)}</Inform.Content>
27-
{increasement !== 0 && (
27+
{increasement && (
2828
<Inform.Highlighted suffix="↑">{parseNumber(increasement)}</Inform.Highlighted>
2929
)}
3030
</Inform.Horizontal>

src/types/leaderboard.type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
type LeaderboardListUser = {
22
id: string;
33
email: string;
4+
username: string;
45
totalViews: string;
56
totalLikes: string;
67
totalPosts: string;
@@ -12,6 +13,7 @@ type LeaderboardListPost = {
1213
id: string;
1314
title: string;
1415
slug: string;
16+
username: string;
1517
totalViews: number;
1618
totalLikes: number;
1719
viewDiff: number;

0 commit comments

Comments
 (0)