-
Notifications
You must be signed in to change notification settings - Fork 0
[25.03.20 / TASK-132] Feature - view growth order #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Walkthrough์ด PR์ Changes
Sequence Diagram(s)sequenceDiagram
participant U as ์ฌ์ฉ์
participant PS as PostService
participant PR as PostRepository
U->>PS: getAllposts(userId, cursor, sort, isAsc, limit)
alt sort ๊ฐ์ด "viewGrowth"์ธ ๊ฒฝ์ฐ
PS->>PR: findPostsByUserIdWithGrowthMetrics(userId, cursor, isAsc, limit)
else
PS->>PR: findPostsByUserId(userId, cursor, sort, isAsc, limit)
end
PR-->>PS: posts ๋ฐ nextCursor ๋ฐํ
PS-->>U: ์ต์ข
๊ฒฐ๊ณผ ๋ฐํ
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
โจ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ๐ชง TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
๐งน Nitpick comments (2)
src/repositories/post.repository.ts (1)
122-212
: ํธ๋ํฝ ์ฑ์ฅ๋ฅ ๊ธฐ์ค ๊ฒ์๋ฌผ ์กฐํ ๋ฉ์๋ ์ถ๊ฐ์๋ก์ด ๋ฉ์๋
findPostsByUserIdWithGrowthMetrics
๊ฐ ์ ๊ตฌํ๋์์ต๋๋ค. ๋ค์๊ณผ ๊ฐ์ ์ ์ด ํนํ ์ข์ต๋๋ค:
- ์ด์ ์ ์ค๋์ ๋ฐ์ดํฐ๋ฅผ ๋น๊ตํ์ฌ ํธ๋ํฝ ์ฑ์ฅ๋ฅ ์ ์ ํํ ๊ณ์ฐ
- ์ปค์ ๊ธฐ๋ฐ ํ์ด์ง๋ค์ด์ ๊ตฌํ
- ๋ช ํํ ์ค๋ฅ ์ฒ๋ฆฌ ๋ฐ ๋ก๊น
์ฝ๋ ์ฌ์ฌ์ฉ์ฑ์ ๊ฐ์ ํ๊ธฐ ์ํด ๊ณตํต ๋ก์ง(์: ๋ ์ง ์ฟผ๋ฆฌ ๋ถ๋ถ)์ ๋ณ๋์ ์ ํธ๋ฆฌํฐ ํจ์๋ก ์ถ์ถํ๋ ๊ฒ์ ๊ณ ๋ คํด ๋ณด์ธ์. ์ด๋ ๊ฒ ํ๋ฉด ํฅํ ์ ์ง ๊ด๋ฆฌ๊ฐ ๋ ์ฌ์์ง ์ ์์ต๋๋ค.
+ // ๊ณตํต์ผ๋ก ์ฌ์ฉ๋๋ ๋ ์ง ๊ด๋ จ SQL ์ฟผ๋ฆฌ๋ฅผ ์์ฑํ๋ ์ ํธ๋ฆฌํฐ ํจ์ + private getTodayStatsSubquery() { + return ` + SELECT post_id, daily_view_count, daily_like_count, date + FROM posts_postdailystatistics + WHERE (date AT TIME ZONE 'Asia/Seoul' AT TIME ZONE 'UTC')::date = (NOW() AT TIME ZONE 'UTC')::date + `; + } + + private getYesterdayStatsSubquery() { + return ` + SELECT post_id, daily_view_count, daily_like_count, date + FROM posts_postdailystatistics + WHERE (date AT TIME ZONE 'Asia/Seoul' AT TIME ZONE 'UTC')::date = (NOW() AT TIME ZONE 'UTC' - INTERVAL '1 day')::date + `; + }src/repositories/__test__/post.repo.integration.test.ts (1)
297-313
: ์ค๋ฆ์ฐจ์ ์ ๋ ฌ ํ ์คํธ๊ฐ ์ ์ ํฉ๋๋ค.์ค๋ฆ์ฐจ์ ์ ๋ ฌ ํ ์คํธ๊ฐ ์ ๊ตฌํ๋์ด ์์ต๋๋ค. ๋ค๋ง, ์ฝ๋ ๊ฐ๋ ์ฑ์ ๋์ด๊ธฐ ์ํด ์ฃผ์์ ์ถ๊ฐํ๋ ๊ฒ์ด ์ข๊ฒ ์ต๋๋ค.
- return post.view_growth >= result.posts[index - 1].view_growth; + // ์ค๋ฆ์ฐจ์ ์ ๋ ฌ์ด๋ฏ๋ก ํ์ฌ ๊ฐ์ด ์ด์ ๊ฐ๋ณด๋ค ํฌ๊ฑฐ๋ ๊ฐ์์ผ ํจ + return post.view_growth >= result.posts[index - 1].view_growth;
๐ Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
๐ Files selected for processing (5)
src/repositories/__test__/post.repo.integration.test.ts
(1 hunks)src/repositories/__test__/post.repo.test.ts
(1 hunks)src/repositories/post.repository.ts
(3 hunks)src/services/post.service.ts
(1 hunks)src/types/dto/requests/getAllPostsQuery.type.ts
(1 hunks)
๐งฐ Additional context used
๐งฌ Code Definitions (1)
src/repositories/post.repository.ts (1)
src/exception/index.ts (1) (1)
DBError
(2-2)
๐ Additional comments (7)
src/services/post.service.ts (1)
10-16
: ์กฐ๊ฑด๋ถ ๋ก์ง ์ถ๊ฐ๋ก ์ฑ์ฅ๋ฅ ์ ๋ ฌ ์ง์์๋ก์ด
viewGrowth
์ ๋ ฌ ์ต์ ์ ์ํ ์กฐ๊ฑด๋ถ ๋ก์ง์ด ์ ๊ตฌํ๋์์ต๋๋ค. ์ด ๋ณ๊ฒฝ์ผ๋ก ์ฌ์ฉ์ ์๊ตฌ์ฌํญ์ ๋ง๊ฒ ํธ๋ํฝ ์ฑ์ฅ๋ฅ ์ ๋ฐ๋ฅธ ์ ๋ ฌ์ด ๊ฐ๋ฅํด์ก์ต๋๋ค.src/types/dto/requests/getAllPostsQuery.type.ts (1)
10-11
: Swagger ๋ฌธ์ ๋ฐ ํ์ ์ ์์ viewGrowth ์ต์ ์ถ๊ฐ
PostSortType
์ ์๋ก์ด ์ ๋ ฌ ์ต์ viewGrowth
๊ฐ ์ถ๊ฐ๋์๊ณ , Swagger ๋ฌธ์์๋ ์ ์ ํ ๋ฐ์๋์์ต๋๋ค. ํ์ ์์คํ ์ ํตํด ์์ ํ๊ฒ ์ ๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.Also applies to: 16-17, 19-19
src/repositories/post.repository.ts (1)
8-14
: findPostsByUserId ๋ฉ์๋์ isAsc ํ๋ผ๋ฏธํฐ์ ๊ธฐ๋ณธ๊ฐ ์ค์
isAsc
ํ๋ผ๋ฏธํฐ์ ๊ธฐ๋ณธ๊ฐfalse
๋ฅผ ๋ถ์ฌํ์ฌ ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ์ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ค์ ํ์ต๋๋ค. ์ด๋ ์ฌ์ฉ์ ๊ฒฝํ ์ธก๋ฉด์์ ์ ์ ํ ๋ณ๊ฒฝ์ ๋๋ค.src/repositories/__test__/post.repo.test.ts (1)
61-160
: ํธ๋ํฝ ์ฑ์ฅ๋ฅ ์กฐํ ๋ฉ์๋์ ๋ํ ํ ์คํธ ์ผ์ด์ค ์ถ๊ฐ
findPostsByUserIdWithGrowthMetrics
๋ฉ์๋์ ๋ํ ํฌ๊ด์ ์ธ ํ ์คํธ ์ผ์ด์ค๊ฐ ์ ๊ตฌํ๋์์ต๋๋ค. ๋ค์ ์ธก๋ฉด๋ค์ด ํ ์คํธ๋๊ณ ์์ด ์ฝ๋์ ์ ๋ขฐ์ฑ์ ๋์ ๋๋ค:
- ์ฑ์ฅ๋ฅ ๋ฐ์ดํฐ ๋ฐํ ๊ธฐ๋ฅ
- ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ ํ์ธ
- ์ปค์ ๊ธฐ๋ฐ ํ์ด์ง๋ค์ด์
- ์ค๋ฅ ์ฒ๋ฆฌ
src/repositories/__test__/post.repo.integration.test.ts (3)
265-278
: ํ ์คํธ ๊ตฌ์กฐ๊ฐ ๋ช ํํ๊ณ ์ ์ ํฉ๋๋ค.์๋ก์ด
findPostsByUserIdWithGrowthMetrics
๋ฉ์๋์ ๋ํ ํ ์คํธ ์ค์ํธ๊ฐ ์ ๊ตฌ์ฑ๋์ด ์์ต๋๋ค. ์ฒซ ๋ฒ์งธ ํ ์คํธ๋ ๊ธฐ๋ณธ ๊ธฐ๋ฅ์ ๊ฒ์ฆํ๊ณ ์์ผ๋ฉฐ, ๋ฐํ๋ ๊ฒฐ๊ณผ๊ฐ ์์๋๋ ์์ฑ(posts
,nextCursor
,view_growth
,like_growth
)์ ๋ชจ๋ ํฌํจํ๊ณ ์๋์ง ํ์ธํฉ๋๋ค.
280-295
: ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ ํ ์คํธ๊ฐ ์ ์ ํฉ๋๋ค.ํธ๋ํฝ ์ฑ์ฅ๋ฅ (view_growth)์ ๊ธฐ์ค์ผ๋ก ๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ์ด ์ ๋๋ก ์๋ํ๋์ง ๊ฒ์ฆํ๋ ํ ์คํธ์ ๋๋ค. ๋ฐ์ดํฐ๊ฐ ์ถฉ๋ถํ์ง ์์ ๊ฒฝ์ฐ๋ฅผ ๊ณ ๋ คํ ์กฐ๊ฑด๋ถ ๋ก์ง๋ ์ ๊ตฌํ๋์ด ์์ต๋๋ค.
315-344
: ํ์ด์ง๋ค์ด์ ํ ์คํธ๊ฐ ์ฒด๊ณ์ ์ผ๋ก ๊ตฌํ๋์ด ์์ต๋๋ค.ํ์ด์ง๋ค์ด์ ๊ธฐ๋ฅ์ ๋ํ ํ ์คํธ๊ฐ ๋งค์ฐ ์ฒด๊ณ์ ์ผ๋ก ๊ตฌํ๋์ด ์์ต๋๋ค. ์๋ ์ฌํญ์ ๊ฒ์ฆํ๊ณ ์์ต๋๋ค:
- ์ ํ๋ ๊ฒฐ๊ณผ๋ฅผ ์กฐํํ ๋
nextCursor
๊ฐ ์ ๊ณต๋๋์งnextCursor
๋ฅผ ์ฌ์ฉํ ๋ค์ ํ์ด์ง ์กฐํ๊ฐ ๊ฐ๋ฅํ์ง- ๋ ํ์ด์ง ๊ฐ์ ์ค๋ณต๋ ํญ๋ชฉ์ด ์๋์ง
์ด๋ ํ์ด์ง๋ค์ด์ ๊ธฐ๋ฅ์ ๊ฒฌ๊ณ ์ฑ์ ๋ณด์ฅํ๋ ์ค์ํ ํ ์คํธ์ ๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฝ๋ ์ ์ฝ์์ต๋๋ค!
์ข์๋ ์
- ํ ์คํธ ์ฝ๋๋๋ถ์ ์ ์ฒด์ ์ผ๋ก ์ด๋ค ๋์์ ํ ์ง ์์ธกํ ์ ์์์ต๋๋ค.
- findPostsByUserIdWithGrowthMetrics๋ฅผ ๋ฐ๋ก ๋ถ๋ฆฌํด๋ฌ์ ์ถํ ์ ์ง๋ณด์์ ๋์์ด ๋ ๊ฒ ๊ฐ์ต๋๋ค!
- findPostsByUserId์ ๋ค ํฉ์ณค์ ๊ฒฝ์ฐ ๋ณด๊ธฐ ์กฐ๊ธ ์ด๋ ต์ง ์์์๊น ์ถ์ต๋๋ค
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ข์๋ ์
- ๊ฐ ๊ธฐ๋ฅ๋ณ ํ ์คํธ์ฝ๋๊ฐ ์ธ๋ฐํ๊ฒ ๊ตฌํ๋์ด ์์ด, ์ ์ฒด์ ์ธ ํ๋ฆ์ ์ดํดํ๊ธฐ ์์ํ์ต๋๋ค!
- SQL๋ฌธ ๊ตฌํํ๋๊ฒ ์ค๋ฌด์์ ๋์ฑ ์ค์ํ๋ค๊ณ ๋ค์๋ ํฐ๋ผ, ์กฐ์ธ ์ฟผ๋ฆฌ ๊ตฌํํ์ ๋ถ๋ถ์ด ์ธ์ ๊น์์ต๋๋ค!
๐ฅ ๋ณ๊ฒฝ ์ฌํญ
ํธ๋ํฝ ๋ฐ์ผ๋ฆฌ ์์น๋ ์์ ์ ๋ ฌ
๐ธ ์คํฌ๋ฆฐ์ท (UI ๋ณ๊ฒฝ ์ ํ์)
๐ ์ฒดํฌ๋ฆฌ์คํธ
Summary by CodeRabbit
์๋ก์ด ๊ธฐ๋ฅ
๋ฌธ์