-   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
μλ‘μ΄ κΈ°λ₯
λ¬Έμ