-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: likeCount AtomicInteger 로 변경 및 좋아요 개수 데이터베이스와 동기화하는 로직 추가
- Loading branch information
Showing
13 changed files
with
98 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
backend/src/main/java/shook/shook/song/domain/killingpart/LikeCountConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,4 @@ schedules: | |
cron: "0/1 * * * * *" | ||
in-memory-song: | ||
cron: "0 0/5 * * * *" # 1분 | ||
update-cron: "0 0/5 * * * *" # 1분 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,4 @@ schedules: | |
cron: "0 0 0/1 * * *" | ||
in-memory-song: | ||
cron: "0 0 0/1 * * *" #1시간 | ||
update-cron: "0 0 0/1 * * *" #1시간 |
Submodule shook-security
updated
from e40d1a to fc66c1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,14 @@ | |
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
import org.springframework.test.context.jdbc.Sql; | ||
import shook.shook.member.domain.Member; | ||
import shook.shook.member.domain.repository.MemberRepository; | ||
import shook.shook.song.domain.InMemorySongs; | ||
import shook.shook.song.domain.Song; | ||
import shook.shook.song.domain.killingpart.KillingPart; | ||
import shook.shook.song.domain.killingpart.KillingPartLike; | ||
import shook.shook.song.domain.killingpart.repository.KillingPartLikeRepository; | ||
import shook.shook.song.domain.killingpart.repository.KillingPartRepository; | ||
|
||
@Sql(value = "classpath:/killingpart/initialize_killing_part_song.sql") | ||
@EnableScheduling | ||
|
@@ -21,6 +28,15 @@ class InMemorySongsSchedulerTest { | |
@Autowired | ||
private InMemorySongsScheduler scheduler; | ||
|
||
@Autowired | ||
private KillingPartLikeRepository likeRepository; | ||
|
||
@Autowired | ||
private KillingPartRepository killingPartRepository; | ||
|
||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@DisplayName("InMemorySongs 를 재생성한다.") | ||
@Test | ||
void recreateCachedSong() { | ||
|
@@ -31,4 +47,24 @@ void recreateCachedSong() { | |
// then | ||
assertThat(inMemorySongs.getSongs()).hasSize(4); | ||
} | ||
|
||
@DisplayName("InMemorySongs 의 상태로 데이터베이스를 업데이트한다.") | ||
@Test | ||
void updateCachedSong() { | ||
// given | ||
scheduler.recreateCachedSong(); | ||
final Song song = inMemorySongs.getSongById(1L); | ||
final KillingPart killingPart = song.getKillingParts().get(0); | ||
final Member member = memberRepository.save(new Member("[email protected]", "nickname")); | ||
inMemorySongs.like(killingPart, likeRepository.save( | ||
new KillingPartLike(killingPart, member) | ||
)); | ||
|
||
// when | ||
scheduler.updateCachedSong(); | ||
|
||
// then | ||
killingPartRepository.findById(killingPart.getId()) | ||
.ifPresent(updatedKillingPart -> assertThat(updatedKillingPart.getLikeCount()).isEqualTo(1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters