codestates / codestates/dalyuck-client-

[Dev Log] 이기범 / 2021-05-31

Open
#172 0 comments 0 reactions 1 assignee Claimed by @gibson-lee93 View on GitHub
dev-log
Dominant language
TypeScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### 오늘은 어떻게 프로젝트에 기여했나요?
* Event에 대한 notification 로직 구현 완료
> - 유저가 원하는 event에 알림을 추가하면 client는 server에게 event의 아이디와 알림 시간을 server에 전달한다.
> - Server는 notification table에 하나의 알림을 저장하는 record를 저장한다.
> - 저장이 성공되면 'luxon' 라이브러리를 사용하여 저장이 성공된 시간과 client에서 보내준 알림 시간의 시간 차이를 계산한다.
> - 계산된 시간은 setTimeout 함수에서 delay로 전달되고 delay 시간이 끝나면 notification에 아직 알림 시간이 유효한지 확인하고 유효하면 유저의 이메일로 알림을 보낸다.
> - 알림을 수정하거나 삭제하면 setTimeout에서 이메일을 보내기 전 알림이 유효한지 확인하기 때문에 유저가 원하는 시간에 알림이 간다.

### 오늘의 프로젝트에서 힘든 점은 무엇인가요?
* 알림을 보내는 로직을 setTimeout으로 구현했는데 이렇게 했을떄 알림이 굉장히 많을 경우 server 성능이 급격히 저하될 것 같다.
```javascript
setTimeoutPromise(alarm)
.then(() => {
this.notificationRepository.findOne({ id: notificationId })
.then((result) => {
if(!result) {
return;
}
this.mailerService
.sendMail({
to: email,
subject: 'You have a notification for an event',
template: './sendNotification',
context: {
eventName: event.eventName,
startTime: event.startTime,
endTime: event.endTime
}
});
})
});
```
* 알림이 수정 되거나 삭제 되면은 setTimeout을 삭제해야 하는데 모든 setTimeout을 삭제할 수 있으나 특정한 setTimeout 삭제는 힘들기 때문에 이메일을 보내기 전에 notification 테이블을 조회하여 유효성을 확인하고 이메일을 보내는 식으로 구현했다. 이것 또한 성능에 안좋은 영향을 준다.

### 내일은 프로젝트에 기여하기 위해 무엇을 해야 하나요?
- [x] NestJs의 매력중의 하나는 jest를 이용하여 test case를 구현하기 쉽다는 것이다. 이것을 공부해 보자!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.