-
Notifications
You must be signed in to change notification settings - Fork 0
[FIX] #205
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
base: develop
Are you sure you want to change the base?
[FIX] #205
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,8 +41,8 @@ public Long createReview(Long writerUserId, ReviewRequest request) { | |
|
|
||
| // 2 ์ต์ ํ ์ํ ์กฐํ ๋ฐ ๋ฐ์ดํฐ ์์ง | ||
| GroupBuyPost post = groupBuyService.getPostWithLock(postId); | ||
| int reviewCount = post.getRatingCount(); | ||
| double postAvg = post.getRatingAvg(); | ||
| Integer reviewCount = post.getRatingCount(); | ||
| Double postAvg = post.getRatingAvg(); | ||
|
Comment on lines
+44
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. postAvg/reviewCount null ๊ฐ๋ฅ์ฑ ์ฒ๋ฆฌ ํ์ํฉ๋๋ค.
๐ ๏ธ ์ ์ ์์ GroupBuyPost post = groupBuyService.getPostWithLock(postId);
Integer reviewCount = post.getRatingCount();
Double postAvg = post.getRatingAvg();
+Integer safeReviewCount = (reviewCount != null) ? reviewCount : 0;
+Double safePostAvg = (postAvg != null) ? postAvg : 0.0;
int postCount = groupBuyService.countPostsByLeader(sellerId);
// 3 ํ๋งค์ ํ์ ๋ฐ์
-userService.applyPostContribution(sellerId, postId, postAvg, reviewCount, postCount);
+userService.applyPostContribution(sellerId, postId, safePostAvg, safeReviewCount, postCount);Also applies to: 50-50 ๐ค Prompt for AI Agents |
||
|
|
||
| int postCount = groupBuyService.countPostsByLeader(sellerId); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,11 +56,11 @@ public class User extends BaseSoftDeleteEntity { | |
| @Column(name = "rating_avg") | ||
| private Double ratingAvg; | ||
|
|
||
| @Column(name = "rating_sum", nullable = false) | ||
| private long ratingSum = 0L; | ||
| @Column(name = "rating_sum", nullable = true) | ||
| private Long ratingSum = 0L; | ||
|
|
||
| @Column(name = "rating_count", nullable = false) | ||
| private int ratingCount = 0; | ||
| @Column(name = "rating_count", nullable = true) | ||
| private Integer ratingCount = 0; | ||
|
Comment on lines
+59
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐งฉ Analysis chain๐ Script executed: #!/bin/bash
# Find all usages of ratingSum and ratingCount in the codebase
rg -n --type java -C3 '(getRatingSum|getRatingCount|ratingSum|ratingCount)' --max-count=100Repository: team-poti/POTI-SERVER Length of output: 3802 ๐ Script executed: #!/bin/bash
# Check if Lombok is used and look for getter method patterns
rg -n --type java '@Getter|@Data|getRatingSum|getRatingCount' src/main/java/org/sopt/poti/domain/user/entity/User.java src/main/java/org/sopt/poti/domain/groupbuy/entity/GroupBuyPost.java -A2 -B2
echo "---"
# Search for all method calls and usages beyond the initial results
rg -n --type java 'getRatingSum|getRatingCount' --max-count=200Repository: team-poti/POTI-SERVER Length of output: 1083 ๐ Script executed: #!/bin/bash
# Check ReviewApplicationService context around the usage
cat -n src/main/java/org/sopt/poti/domain/review/application/ReviewApplicationService.java | sed -n '35,65p'
echo "---"
# Also check for any arithmetic operations or method calls on ratingCount/ratingSum
rg -n --type java '(ratingCount|ratingSum)\s*[+\-*/=<>]|ratingCount\s*\)|\+\s*(ratingCount|ratingSum)' -A2 -B2Repository: team-poti/POTI-SERVER Length of output: 3059
DB ์ปฌ๋ผ์ด
๋ง์ด๊ทธ๋ ์ด์ ์ด๋ ๊ธฐ์กด ๋ฐ์ดํฐ์ null์ด ์กด์ฌํ๋ค๋ฉด ๋ฐํ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ ์ ์์ผ๋, ๋ค์ ์ค ํ๋๋ฅผ ํ์ธ/์ ์ฉํด์ฃผ์ธ์:
๐ค Prompt for AI Agents |
||
|
|
||
| @Column(name = "rating_weighted_sum", nullable = false) | ||
| private double ratingWeightedSum = 0.0; | ||
|
|
||
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.
Nullable๋ก ๋ฐ๋ rating ํ๋๊ฐ null์ด๋ฉด addRating์์ NPE ๊ฐ๋ฅ์ฑ ์์ต๋๋ค.
์ปฌ๋ผ์ด nullable์ด๋ฉด ๊ธฐ์กด ๋ฐ์ดํฐ๊ฐ null๋ก ๋ก๋๋ ์ ์๊ณ ,
+=์ฐ์ฐ์์ ์คํ ์ธ๋ฐ์ฑ์ผ๋ก NPE๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค. ์ต์ํaddRating์ง์ ์ null-safe ๋ณด์ (๋๋@PostLoad/@PrePersist, ๋ฐฑํ) ์ฒ๋ฆฌ๊ฐ ํ์ํฉ๋๋ค.๐ ๏ธ ์ ์ ์์
public void addRating(int score) { validateScore(score); + if (this.ratingSum == null) this.ratingSum = 0L; + if (this.ratingCount == null) this.ratingCount = 0; + if (this.ratingAvg == null) this.ratingAvg = 0.0; + this.ratingSum += score; this.ratingCount += 1; - Double avg = (double) this.ratingSum / this.ratingCount; + double avg = (double) this.ratingSum / this.ratingCount; this.ratingAvg = Math.round(avg * 10) / 10.0; }Also applies to: 210-218
๐ค Prompt for AI Agents