Repository navigation
[REFACTOR] notification transaction flow #79
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
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 |
|---|---|---|
|
|
@@ -440,11 +440,24 @@ export const receivedEstimateService = { | |
| tx, | ||
| ); | ||
|
|
||
| const notification = await notificationService.createNotification( | ||
| { | ||
| userId: confirmedEstimate.mover.id, | ||
| type: "ESTIMATE_CONFIRMED", | ||
| title: "๊ฒฌ์ ํ์ ", | ||
| content: `${estimate.estimateRequest.customer.name}๋์`, | ||
|
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. ๐ฏ Functional Correctness | ๐ก Minor | โก Quick win ์๋ฆผ ๋ด์ฉ์ ์์ ํ ๋ฌธ์ฅ์ผ๋ก ์ค์ ํ์ธ์. ํ์ฌ ์๋ฆผ ๋ณธ๋ฌธ์ ๐ค Prompt for AI Agents |
||
| linkUrl: "/estimate/received-requests", | ||
| expiresAt: getKstEndOfDay(estimate.estimateRequest.moveDate), | ||
| }, | ||
| tx, | ||
| ); | ||
|
Comment on lines
+443
to
+453
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. ๐๏ธ Data Integrity & Integration | ๐ Major | ๐๏ธ Heavy lift ๐งฉ Analysis chain๐ Script executed: #!/bin/bash
set -euo pipefail
fd -a '^notification\.service\.ts$' src -x ast-grep outline {} --items all
fd -a '^notification\.service\.ts$' src -x rg -n -C 8 'createNotification|sendNotification' {}
rg -n -C 6 'createNotification\(' \
src/modules/estimate/customer/customer-estimate.service.ts \
src/modules/estimate/mover/mover-estimate.service.tsRepository: 4roro-moving/moving-backend Length of output: 5511 ๐ Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- notification service ---'
sed -n '1,230p' src/modules/notification/notification.service.ts
printf '%s\n' '--- notification repository ---'
sed -n '1,180p' src/modules/notification/notification.repository.ts
printf '%s\n' '--- transaction utility and notification types ---'
sed -n '1,220p' src/utils/transaction.ts
rg -n -C 5 'CreateNotificationInput|NotificationItem|PrismaClient|TransactionClient' \
src/modules/notification src/modules/estimate
printf '%s\n' '--- all createNotification call shapes ---'
rg -n -U -P 'createNotification\s*\([^;]*?\)' src --glob '*.ts' || trueRepository: 4roro-moving/moving-backend Length of output: 21480 ๐ Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- estimate and review transaction contexts ---'
sed -n '220,280p' src/modules/estimate/mover/mover-estimate.service.ts
sed -n '330,380p' src/modules/estimate/mover/mover-estimate.service.ts
sed -n '410,465p' src/modules/estimate/customer/customer-estimate.service.ts
sed -n '230,275p' src/modules/review/review.service.ts
printf '%s\n' '--- notification repository create implementation ---'
sed -n '235,275p' src/modules/notification/notification.repository.ts
printf '%s\n' '--- static call/signature verifier ---'
python3 - <<'PY'
from pathlib import Path
import re
service = Path("src/modules/notification/notification.service.ts").read_text()
match = re.search(
r"const\s+createNotification\s*=\s*async\s*\((.*?)\)\s*:\s*Promise",
service,
re.S,
)
if not match:
raise SystemExit("createNotification declaration not found")
params = [p.strip() for p in match.group(1).split(",") if p.strip()]
print(f"notificationService.createNotification declared parameters: {len(params)}")
print("\n".join(f" {i + 1}: {p}" for i, p in enumerate(params)))
for path in Path("src/modules").rglob("*.service.ts"):
text = path.read_text()
for m in re.finditer(r"notificationService\.createNotification\s*\(", text):
start = m.start()
depth = 0
end = None
for i in range(text.find("(", start), len(text)):
if text[i] == "(":
depth += 1
elif text[i] == ")":
depth -= 1
if depth == 0:
end = i + 1
break
if end is None:
continue
args = text[text.find("(", start) + 1:end - 1]
# Top-level commas count arguments without executing repository code.
level = 0
commas = 0
for ch in args:
if ch in "({[":
level += 1
elif ch in ")}]":
level -= 1
elif ch == "," and level == 0:
commas += 1
print(f"{path}:{text[:start].count(chr(10)) + 1}: call arguments={commas + 1}")
PYRepository: 4roro-moving/moving-backend Length of output: 7560 ๐ Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- estimate and review transaction contexts ---'
sed -n '220,280p' src/modules/estimate/mover/mover-estimate.service.ts
sed -n '330,380p' src/modules/estimate/mover/mover-estimate.service.ts
sed -n '410,465p' src/modules/estimate/customer/customer-estimate.service.ts
sed -n '230,275p' src/modules/review/review.service.ts
printf '%s\n' '--- notification repository create implementation ---'
sed -n '235,275p' src/modules/notification/notification.repository.ts
printf '%s\n' '--- static call/signature verifier ---'
python3 - <<'PY'
from pathlib import Path
import re
service = Path("src/modules/notification/notification.service.ts").read_text()
match = re.search(
r"const\s+createNotification\s*=\s*async\s*\((.*?)\)\s*:\s*Promise",
service,
re.S,
)
if not match:
raise SystemExit("createNotification declaration not found")
params = [p.strip() for p in match.group(1).split(",") if p.strip()]
print(f"notificationService.createNotification declared parameters: {len(params)}")
print("\n".join(f" {i + 1}: {p}" for i, p in enumerate(params)))
for path in Path("src/modules").rglob("*.service.ts"):
text = path.read_text()
for m in re.finditer(r"notificationService\.createNotification\s*\(", text):
start = m.start()
depth = 0
end = None
for i in range(text.find("(", start), len(text)):
if text[i] == "(":
depth += 1
elif text[i] == ")":
depth -= 1
if depth == 0:
end = i + 1
break
if end is None:
continue
args = text[text.find("(", start) + 1:end - 1]
level = 0
commas = 0
for ch in args:
if ch in "({[":
level += 1
elif ch in ")}]":
level -= 1
elif ch == "," and level == 0:
commas += 1
print(f"{path}:{text[:start].count(chr(10)) + 1}: call arguments={commas + 1}")
PYRepository: 4roro-moving/moving-backend Length of output: 7560 ๐ Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- notification service exports and send calls ---'
rg -n -C 4 'sendNotification|export const notificationService|notificationService' \
src/modules/notification/notification.service.ts \
src/modules/estimate/mover/mover-estimate.service.ts \
src/modules/estimate/customer/customer-estimate.service.ts \
src/modules/review/review.service.ts
printf '%s\n' '--- imports of notification service ---'
rg -n -C 3 'notificationService' \
src/modules/estimate/mover/mover-estimate.service.ts \
src/modules/estimate/customer/customer-estimate.service.ts \
src/modules/review/review.service.tsRepository: 4roro-moving/moving-backend Length of output: 16649
๋ํ ํธ์ถ๋ถ์ ๐ Affects 2 files
๐ค Prompt for AI AgentsSource: Path instructions |
||
|
|
||
| //ํ์ ์๋ต ํํ ๊ฐ๊ณต | ||
| return { | ||
| estimateRequest: confirmedEstimateRequest, | ||
| moveDate: estimate.estimateRequest.moveDate, | ||
| customerName: estimate.estimateRequest.customer.name, | ||
| notification, | ||
| estimate: { | ||
| id: confirmedEstimate.id, | ||
| price: confirmedEstimate.price, | ||
|
|
@@ -461,15 +474,10 @@ export const receivedEstimateService = { | |
| }; | ||
| }); | ||
|
|
||
| await notificationService.createNotification({ | ||
| userId: result.estimate.mover.id, | ||
| type: "ESTIMATE_CONFIRMED", | ||
| title: "๊ฒฌ์ ํ์ ", | ||
| content: `${result.customerName}๋์`, | ||
| linkUrl: "/estimate/received-requests", | ||
| expiresAt: getKstEndOfDay(result.moveDate), | ||
| }); | ||
| notificationService.sendNotification(result.estimate.mover.id, result.notification); | ||
|
|
||
| const { notification: _, ...response } = result; | ||
|
|
||
| return result; | ||
| return response; | ||
| }, | ||
| }; | ||
|
Contributor
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. ๊ฒฌ์ ์ ์ยท๋ฐ๋ ค ๋ชจ๋ ์๋ฆผ ์ ์ฅ์ ํต์ฌ ์์
๊ณผ ๊ฐ์ ํธ๋์ญ์
์ ํฌํจํ๊ณ , ๊ณ ์ํ์ จ์ด์ยก |
|
Contributor
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. ์๋ฆผ ์ ์ฅ๊ณผ SSE ์ ์ก ๊ตฌ์กฐ๋ ์๋ํ ๋ฐฉ์๋๋ก ์ ์ ์ฉ๋ ๊ฒ ๊ฐ์ต๋๋ค. ๋ฆฌ๋ทฐ ์์ฑยท๊ธฐ์ฌ ๋ฆฌ๋ทฐ ํต๊ณ ๊ฐฑ์ ยท์๋ฆผ DB ์ ์ฅ์ ๋์ผ ํธ๋์ญ์
์ผ๋ก ์ฒ๋ฆฌํ๊ณ , ๊ณ ์ํ์ จ์ด์ฉยก |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -224,7 +224,7 @@ export const reviewService = { | |||||
|
|
||||||
| try { | ||||||
| // ๋ฆฌ๋ทฐ ์์ฑ๊ณผ ๊ธฐ์ฌ๋ ๋ฆฌ๋ทฐ ํต๊ณ ๊ฐฑ์ ์ ํ๋์ ์์ฑ ์ ์ค์ผ์ด์ค์ด๋ฏ๋ก Service์์ ํธ๋์ญ์ ๊ฒฝ๊ณ๋ฅผ ๊ด๋ฆฌ | ||||||
| const review = await runTransaction( | ||||||
| const result = await runTransaction( | ||||||
| async (tx) => { | ||||||
| const createdReview = await reviewRepository.createReview( | ||||||
| { | ||||||
|
|
@@ -253,25 +253,33 @@ export const reviewService = { | |||||
| tx, | ||||||
| ); | ||||||
|
|
||||||
| return createdReview; | ||||||
| const notification = await notificationService.createNotification( | ||||||
| { | ||||||
| userId: estimate.moverId, | ||||||
| type: "REVIEW_RECEIVED", | ||||||
| title: "๋ฆฌ๋ทฐ ๋์ฐฉ", | ||||||
| content: "๊ณ ๊ฐ๋์ด", | ||||||
|
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. ๐ฏ Functional Correctness | ๐ก Minor | โก Quick win ์์ ํ ์๋ฆผ ๋ณธ๋ฌธ์ ์ ์ฅํ์ธ์. Line 261์ ์์ ์์- content: "๊ณ ๊ฐ๋์ด",
+ content: "๊ณ ๊ฐ๋์ด ๋ฆฌ๋ทฐ๋ฅผ ๋จ๊ฒผ์ต๋๋ค.",๐ Committable suggestion
Suggested change
๐ค Prompt for AI Agents |
||||||
| linkUrl: null, | ||||||
| expiresAt: null, | ||||||
| }, | ||||||
| tx, | ||||||
| ); | ||||||
|
|
||||||
| return { | ||||||
| review: createdReview, | ||||||
| notification, | ||||||
| }; | ||||||
| }, | ||||||
| { | ||||||
| // ๊ฐ์ ๊ธฐ์ฌ๋์๊ฒ ์ฌ๋ฌ ๋ฆฌ๋ทฐ๊ฐ ๋์์ ๋ฑ๋ก๋ ๋ ํต๊ณ ์ฌ๊ณ์ฐ ๊ฒฐ๊ณผ๊ฐ ๋ฎ์ด์จ์ง๋ ๊ฒ์ ๋ฐฉ์ง | ||||||
| isolationLevel: Prisma.TransactionIsolationLevel.Serializable, | ||||||
| }, | ||||||
| ); | ||||||
|
|
||||||
| await notificationService.createNotification({ | ||||||
| userId: estimate.moverId, | ||||||
| type: "REVIEW_RECEIVED", | ||||||
| title: "๋ฆฌ๋ทฐ ๋์ฐฉ", | ||||||
| content: "๊ณ ๊ฐ๋์ด", | ||||||
| linkUrl: null, | ||||||
| expiresAt: null, | ||||||
| }); | ||||||
| notificationService.sendNotification(estimate.moverId, result.notification); | ||||||
|
Comment on lines
+256
to
+279
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. ๐ฏ Functional Correctness | ๐ Major | โก Quick win ๐งฉ Analysis chain๐ Script executed: #!/bin/bash
set -euo pipefail
# NotificationService ์ ์์ ํธ์ถ ๊ณ์ฝ์ ํ์ธํฉ๋๋ค.
fd -t f '^notification\.service\.ts$' src | while IFS= read -r file; do
ast-grep outline "$file" --items all
rg -n -C 8 '\b(createNotification|sendNotification)\s*\(' "$file"
done
# ์๋น์ค ํธ์ถ๋ถ์ ์ ๋ฌ ์ธ์๋ฅผ ํ์ธํฉ๋๋ค.
rg -n -C 6 '\b(createNotification|sendNotification)\s*\(' srcRepository: 4roro-moving/moving-backend Length of output: 11215 ๐ Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- notification.service.ts ---'
cat -n src/modules/notification/notification.service.ts | sed -n '1,235p'
printf '%s\n' '--- notification types and repository ---'
fd -t f . src/modules/notification | sort
rg -n -C 5 'CreateNotificationInput|NotificationItem|notificationService|sendNotification|createNotification' src/modules/notification src/modules/review/review.service.ts
printf '%s\n' '--- review imports and transaction context ---'
cat -n src/modules/review/review.service.ts | sed -n '1,40p;210,290p'Repository: 4roro-moving/moving-backend Length of output: 27822
๐ค Prompt for AI Agents |
||||||
|
|
||||||
| return { | ||||||
| review, | ||||||
| review: result.review, | ||||||
| }; | ||||||
| } catch (error) { | ||||||
| if (isReviewEstimateUniqueConstraintError(error)) { | ||||||
|
|
||||||
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.
๊ฒฌ์ ํ์ ๊ณผ ์๋ฆผ DB ์ ์ฅ์ ๋์ผ ํธ๋์ญ์ ์ ํฌํจํ๊ณ ,
์์ฑ๋ ์๋ฆผ์ ๋ฐํํ ๋ค ์ปค๋ฐ ์ดํ
sendNotification()์ผ๋ก SSE๋ฅผ ์ ์กํ๋๋ก์๋ํ ๊ตฌ์กฐ์ ๋ง๊ฒ ์ ์์ ๋ ๊ฒ ๊ฐ์ต๋๋ค.
๊ณ ์ํ์ จ์ต๋๋คยก