Skip to content
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

[#35] restdocs도입 #36

Merged
merged 78 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
5263c13
Feat: 일, 주, 월별 인기 피드 업데이트
jzakka Feb 5, 2024
37fffa3
Fix: zset조회 로직 수정
jzakka Feb 5, 2024
38b4e53
Fix: deleteByMemberAndFeed가 id를 받도록 수정
jzakka Feb 5, 2024
0bd5a48
Refactor: feedId를 인자로 받도록 수정
jzakka Feb 5, 2024
e9810dd
Refactor: 랭킹정보를 RankingController에서 제공
jzakka Feb 6, 2024
ee59359
Style: 테스트이름 변경
jzakka Feb 6, 2024
5d632ce
Feat: 권한이 필요한 경우 서비스에서 PostAuthroize로 체크
jzakka Feb 4, 2024
a5d1fdc
Feat: 좋아요 기능
jzakka Feb 4, 2024
59e31df
Feat: 댓글, 대댓글 작성
jzakka Feb 4, 2024
9f412ce
Delete: FeedService에서 rankingRepository에 대한 의존성 제거
jzakka Feb 6, 2024
2bf9736
Feat: 배치작업 구성
jzakka Feb 8, 2024
e24aa60
Test: 통합테스트 한 테스트로 묶음
jzakka Feb 8, 2024
51a51d0
Test: RankingRepositoryTest 통합테스트로 묶음
jzakka Feb 8, 2024
f4d1144
Test: 테스트 추가
jzakka Feb 8, 2024
bb90b84
Feat: 여행일지 작성
jzakka Feb 6, 2024
fd65df0
Feat: 기본 여행일지 제목 테스트
jzakka Feb 6, 2024
45369c1
Fix: 연관관계 설정 수정
jzakka Feb 6, 2024
51e31e4
충돌 수정
jzakka Feb 8, 2024
ac4725f
Test: 테스트 리팩토링
jzakka Feb 8, 2024
c314823
Feat: 여행일지에 섬네일 지정
jzakka Feb 8, 2024
8178870
Feat: 사용자의 여행일지 조회
jzakka Feb 8, 2024
1ec063f
Feat: 여행일지 취소
jzakka Feb 8, 2024
2ee6a56
Feat: 컨트롤러에 diaryService 연결
jzakka Feb 8, 2024
ca72473
Fix: geoApi 연결 설정 수정
jzakka Feb 8, 2024
8f3ed12
Package: batch 설정을 config패키지 밖으로 뺌
jzakka Feb 9, 2024
c4bae8f
Refactor: CacheKey 목적에 따라 분리
jzakka Feb 9, 2024
124e3e0
Refactor: 배치 파일을 잡 목적에 따라 분리
jzakka Feb 9, 2024
082c0e2
Feat: 잡이 프로필설정에 따라 생성되도록 설정
jzakka Feb 9, 2024
2e77773
Fix: 인기 피드 정보를 한 쿼리로 가져오도록 수정
jzakka Feb 9, 2024
eef16d7
Fix: 잡 이름 수정
jzakka Feb 9, 2024
2c0e01d
Feat: 인기 피드는 삭제 못하게 설정
jzakka Feb 9, 2024
f3b3cdf
Feat: 여행일지 작성
jzakka Feb 6, 2024
9a9fd5e
Feat: 기본 여행일지 제목 테스트
jzakka Feb 6, 2024
13cac6e
Fix: 연관관계 설정 수정
jzakka Feb 6, 2024
4448917
충돌 수정
jzakka Feb 8, 2024
d73b418
Test: 테스트 리팩토링
jzakka Feb 8, 2024
86c3e1e
Feat: 여행일지에 섬네일 지정
jzakka Feb 8, 2024
4717de0
Feat: 사용자의 여행일지 조회
jzakka Feb 8, 2024
2901c77
Feat: 여행일지 취소
jzakka Feb 8, 2024
859d3cf
Feat: 컨트롤러에 diaryService 연결
jzakka Feb 8, 2024
bab0db3
Fix: geoApi 연결 설정 수정
jzakka Feb 8, 2024
328a4cb
Refactor: 여행일지 썸네일이 GraphicContent를 참조하도록 수정
jzakka Feb 9, 2024
2271738
Style: ResponseEntity<Object> -> void
jzakka Feb 9, 2024
eeddc8f
Refactor: 페이지 반환값을 커스텀 페이지로 반환
jzakka Feb 9, 2024
49c20b3
Refactor: @PostAuthorize에서 검증역할을 도메인으로 옮김
jzakka Feb 9, 2024
c959510
충돌수정
jzakka Feb 9, 2024
8d106bf
Feat: 인기피드 저장시, `id`, `작성자`, `여행지역`을 저장하도록 수정
jzakka Feb 10, 2024
3155b96
Style: 메서드 이름 수정
jzakka Feb 10, 2024
8960803
Feat: 여행일지 작성
jzakka Feb 6, 2024
93b68b1
Feat: 기본 여행일지 제목 테스트
jzakka Feb 6, 2024
bcd6aa5
Fix: 연관관계 설정 수정
jzakka Feb 6, 2024
2ccd84c
충돌 수정
jzakka Feb 8, 2024
de7294b
Test: 테스트 리팩토링
jzakka Feb 8, 2024
9c2abb3
Feat: 여행일지에 섬네일 지정
jzakka Feb 8, 2024
a331ecd
Feat: 사용자의 여행일지 조회
jzakka Feb 8, 2024
2047a9c
Feat: 여행일지 취소
jzakka Feb 8, 2024
97e97be
Feat: 컨트롤러에 diaryService 연결
jzakka Feb 8, 2024
0b89cfa
Fix: geoApi 연결 설정 수정
jzakka Feb 8, 2024
39a8792
Refactor: 여행일지 썸네일이 GraphicContent를 참조하도록 수정
jzakka Feb 9, 2024
cc95e28
Style: ResponseEntity<Object> -> void
jzakka Feb 9, 2024
e060707
Refactor: 페이지 반환값을 커스텀 페이지로 반환
jzakka Feb 9, 2024
7286be6
Refactor: @PostAuthorize에서 검증역할을 도메인으로 옮김
jzakka Feb 9, 2024
29119ec
Feat: 기본 여행일지 제목 테스트
jzakka Feb 6, 2024
28a94d6
충돌 수정
jzakka Feb 8, 2024
248e3b3
Test: 테스트 리팩토링
jzakka Feb 8, 2024
ab3e2db
Feat: 사용자의 여행일지 조회
jzakka Feb 8, 2024
938fb27
Feat: 컨트롤러에 diaryService 연결
jzakka Feb 8, 2024
6e52db5
충돌수정
jzakka Feb 10, 2024
341d0d4
충돌수정
jzakka Feb 10, 2024
c7a99aa
충돌수정
jzakka Feb 10, 2024
00eb2d2
Chore: restdocs 추가
jzakka Feb 8, 2024
81a886d
Test: 피드 생성 테스트&문서화
jzakka Feb 10, 2024
044095a
Test: 피드 테스트
jzakka Feb 10, 2024
1584a95
Test: 댓글 테스트
jzakka Feb 11, 2024
97e7131
Test: 좋아요 테스트
jzakka Feb 11, 2024
4acb3a4
Test: 랭킹 테스트
jzakka Feb 11, 2024
1c133e4
Test: 여행일지 테스트
jzakka Feb 11, 2024
ee1b497
docs: retdocs로 api 문서화
jzakka Feb 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ plugins {
id 'groovy'
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
id "org.asciidoctor.jvm.convert" version "3.3.2"
}

configurations {
asciidoctorExt
}

group = 'com'
Expand Down Expand Up @@ -38,6 +43,8 @@ dependencies {
testImplementation 'org.springframework.security:spring-security-test'
implementation 'org.springframework.session:spring-session-data-redis'
testImplementation 'org.springframework.batch:spring-batch-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'

// 구글 지오코딩 api
implementation 'com.google.maps:google-maps-services:2.2.0'
Expand All @@ -52,6 +59,43 @@ dependencies {
testAnnotationProcessor 'org.projectlombok:lombok'
}

ext {
snippetsDir = file('build/generated-snippets')
}

test {
outputs.dir snippetsDir
}

bootJar {
dependsOn asciidoctor
from ("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}

tasks.named('test') {
useJUnitPlatform()
}


asciidoctor {
inputs.dir snippetsDir
configurations 'asciidoctorExt'
dependsOn test
baseDirFollowsSourceFile()
}

asciidoctor.doFirst {
delete file('src/main/resources/static/docs')
}

task copyDocument(type: Copy) {
dependsOn asciidoctor
from file("build/docs/asciidoc")
into file("src/main/resources/static/docs")
}

build {
dependsOn copyDocument
}
2 changes: 2 additions & 0 deletions src/docs/asciidoc/CancelLike.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Like a feed
operation::like-controller-test/Cancel like[snippets="http-request,http-response,path-parameters"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 한파일에 다 못 몰아두나요 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url마다 파일로 만들어서 index.html에서 참조하는 식으로 했는데 처음부터 한파일에 모아서 할 걸 그랬군요...!

2 changes: 2 additions & 0 deletions src/docs/asciidoc/CreateADiary.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Create a diary
operation::diary-controller-test/Create a diary[snippets="http-request,http-response"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/CreateChildComment.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Create a nested comment
operation::comment-controller-test/Create child comment[snippets="http-request,http-response,path-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/CreateComment.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Create a comment
operation::comment-controller-test/Create comment[snippets="http-request,http-response,path-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/CreateFeed.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Create a feed
operation::feed-controller-test/Create Feed[snippets="http-request,http-response"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/DeleteADiary.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Delete a diary
operation::diary-controller-test/Delete a diary[snippets="http-request,http-response,path-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/DeleteAFeed.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get a feed
operation::feed-controller-test/Delete a feed[snippets="http-request,http-response,path-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/DeleteComments.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Delete a comment
operation::comment-controller-test/Delete a comment[snippets="http-request,http-response,path-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetAFeed.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get a feed
operation::feed-controller-test/Get a feed[snippets="http-request,http-response,path-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetChildComments.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get child comments
operation::comment-controller-test/Get child comments[snippets="http-request,http-response,path-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetComments.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get comments
operation::comment-controller-test/Get comments[snippets="http-request,http-response,path-parameters,query-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetDailyHotFeeds.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get daily hot feeds
operation::ranking-controller-test/get daily-hot-feeds[snippets="http-request,http-response"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetDiariesOfAMember.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get diaries of a member
operation::diary-controller-test/Get diaries of a member[snippets="http-request,http-response,path-parameters,query-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetFeedsByTag.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get feeds by tag
operation::feed-controller-test/Get feeds by tag[snippets="http-request,http-response,path-parameters,query-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetFeedsOfMember.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get feeds of member
operation::feed-controller-test/Get feeds of member[snippets="http-request,http-response,path-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetMonthlyHotFeeds.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get monthly hot feeds
operation::ranking-controller-test/get monthly-hot-feeds[snippets="http-request,http-response"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetPopularAbroadSpots.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get popular abroad spots
operation::ranking-controller-test/Get popular abroad spots[snippets="http-request,http-response"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetPopularDomesticSpots.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get popular domestic spots
operation::ranking-controller-test/Get popular domestic spots[snippets="http-request,http-response"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/GetWeeklyHotFeeds.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get weekly hot feeds
operation::ranking-controller-test/get weekly-hot-feeds[snippets="http-request,http-response"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/JoinMember.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== JoinMember
operation::member-controller-test/JoinMember[snippets="http-request,http-response"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/LikeAFeed.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Like a feed
operation::like-controller-test/Like a feed[snippets="http-request,http-response,path-parameters"]
2 changes: 2 additions & 0 deletions src/docs/asciidoc/UpdateAFeed.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
== Get a feed
operation::feed-controller-test/Update a feed[snippets="http-request,http-response,path-parameters"]
30 changes: 30 additions & 0 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
= Stoury API docs
:doctype: book
:source-highlighter: highlightjs
:toc: left
:toclevels: 2
:seclinks:

include::JoinMember.adoc[]
include::CreateFeed.adoc[]
include::GetAFeed.adoc[]
include::GetFeedsByTag.adoc[]
include::GetFeedsOfMember.adoc[]
include::UpdateAFeed.adoc[]
include::DeleteAFeed.adoc[]
include::LikeAFeed.adoc[]
include::CancelLike.adoc[]
include::CreateComment.adoc[]
include::CreateChildComment.adoc[]
include::GetComments.adoc[]
include::GetChildComments.adoc[]
include::DeleteComments.adoc[]
include::CreateADiary.adoc[]
include::GetDiariesOfAMember.adoc[]
include::DeleteADiary.adoc[]
include::GetPopularDomesticSpots.adoc[]
include::GetPopularAbroadSpots.adoc[]
include::GetDailyHotFeeds.adoc[]
include::GetWeeklyHotFeeds.adoc[]
include::GetMonthlyHotFeeds.adoc[]

133 changes: 133 additions & 0 deletions src/main/java/com/stoury/batch/BatchHotFeedsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package com.stoury.batch;

import com.stoury.domain.Feed;
import com.stoury.dto.feed.SimpleFeedResponse;
import com.stoury.repository.LikeRepository;
import com.stoury.repository.RankingRepository;
import jakarta.persistence.EntityManagerFactory;
import lombok.RequiredArgsConstructor;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.job.builder.JobBuilder;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.item.database.JpaPagingItemReader;
import org.springframework.batch.item.database.builder.JpaPagingItemReaderBuilder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.util.Pair;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.PlatformTransactionManager;

import java.time.temporal.ChronoUnit;

@Configuration
@RequiredArgsConstructor
@ConditionalOnExpression("'${spring.batch.job.names}'.contains('jobHotFeeds')")
public class BatchHotFeedsConfig {
private final EntityManagerFactory entityManagerFactory;

private final RankingRepository rankingRepository;

@Bean
public Job jobDailyFeed(JobRepository jobRepository, PlatformTransactionManager tm,
ThreadPoolTaskExecutor taskExecutor, LikeRepository likeRepository) {
return new JobBuilder("jobDailyFeed", jobRepository)
.start(stepDailyFeed(jobRepository, tm, taskExecutor, likeRepository))
.build();
}

@Bean
public Job jobWeeklyFeed(JobRepository jobRepository, PlatformTransactionManager tm,
ThreadPoolTaskExecutor taskExecutor, LikeRepository likeRepository) {
return new JobBuilder("jobWeeklyFeed", jobRepository)
.start(stepWeeklyFeed(jobRepository, tm, taskExecutor, likeRepository))
.build();
}

@Bean
public Job jobMonthlyFeed(JobRepository jobRepository, PlatformTransactionManager tm,
ThreadPoolTaskExecutor taskExecutor, LikeRepository likeRepository) {
return new JobBuilder("jobMonthlyFeed", jobRepository)
.start(stepMonthlyFeed(jobRepository, tm, taskExecutor, likeRepository))
.build();
}

@Bean
public Step stepDailyFeed(JobRepository jobRepository, PlatformTransactionManager tm,
ThreadPoolTaskExecutor taskExecutor, LikeRepository likeRepository) {
return new StepBuilder("stepDailyFeed", jobRepository)
.<Feed, Pair<SimpleFeedResponse, Long>>chunk(100, tm)
.reader(feedReader())
.processor(feedProcessor(likeRepository, ChronoUnit.DAYS))
.writer(feedWriter(ChronoUnit.DAYS))
.taskExecutor(taskExecutor)
.build();
}

@Bean
public Step stepWeeklyFeed(JobRepository jobRepository, PlatformTransactionManager tm,
ThreadPoolTaskExecutor taskExecutor, LikeRepository likeRepository) {
return new StepBuilder("stepWeeklyFeed", jobRepository)
.<Feed, Pair<SimpleFeedResponse, Long>>chunk(100, tm)
.reader(feedReader())
.processor(feedProcessor(likeRepository, ChronoUnit.WEEKS))
.writer(feedWriter(ChronoUnit.WEEKS))
.taskExecutor(taskExecutor)
.build();
}

@Bean
public Step stepMonthlyFeed(JobRepository jobRepository, PlatformTransactionManager tm,
ThreadPoolTaskExecutor taskExecutor, LikeRepository likeRepository) {
return new StepBuilder("stepMonthlyFeed", jobRepository)
.<Feed, Pair<SimpleFeedResponse, Long>>chunk(100, tm)
.reader(feedReader())
.processor(feedProcessor(likeRepository, ChronoUnit.MONTHS))
.writer(feedWriter(ChronoUnit.MONTHS))
.taskExecutor(taskExecutor)
.build();
}


public JpaPagingItemReader<Feed> feedReader() {
return new JpaPagingItemReaderBuilder<Feed>()
.name("feedReader")
.pageSize(100)
.entityManagerFactory(entityManagerFactory)
.queryString("select f from Feed f")
.build();
}

public ItemProcessor<Feed, Pair<SimpleFeedResponse, Long>> feedProcessor(LikeRepository likeRepository, ChronoUnit chronoUnit) {
return feed -> {
Long feedId = feed.getId();

if (!likeRepository.existsByFeedId(feedId.toString())) {
return null;
}
long currentLikes = likeRepository.getCountByFeedId(feedId.toString());
long prevLikes = likeRepository.getCountSnapshotByFeed(feedId.toString(), chronoUnit);

SimpleFeedResponse simpleFeed = SimpleFeedResponse.from(feed);

return Pair.of(simpleFeed, currentLikes - prevLikes);
};
}

public ItemWriter<Pair<SimpleFeedResponse, Long>> feedWriter(ChronoUnit chronoUnit) {
return list -> {
for (Pair<SimpleFeedResponse, Long> pair : list) {
SimpleFeedResponse rawSimpleFeed = pair.getFirst();
Long likeIncrease = pair.getSecond();

if (likeIncrease > 0) {
rankingRepository.saveHotFeed(rawSimpleFeed, likeIncrease, chronoUnit);
}
}
};
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.stoury.config.batch;
package com.stoury.batch;

import com.stoury.repository.FeedRepository;
import com.stoury.repository.RankingRepository;
import com.stoury.utils.CacheKeys;
import com.stoury.utils.cachekeys.PopularSpotsKey;
import lombok.RequiredArgsConstructor;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
Expand All @@ -12,30 +12,31 @@
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.PlatformTransactionManager;

import java.util.List;

@Configuration
@EnableScheduling
@RequiredArgsConstructor
public class BatchConfig {
@ConditionalOnExpression("'${spring.batch.job.names}'.contains('jobPopularSpots')")
public class BatchPopularSpotsConfig {
Pageable pageable = PageRequest.of(0, 10);
private final FeedRepository feedRepository;
private final RankingRepository rankingRepository;


@Bean
public Step stepUpdatePopularDomesticCities(JobRepository jobRepository, PlatformTransactionManager tm) {
return new StepBuilder("stepUpdatePopularDomesticCities", jobRepository)
.tasklet((contribution, chunkContext) -> {
List<String> rankedDomesticCities = feedRepository.findTop10CitiesInKorea(pageable);
rankingRepository.update(CacheKeys.POPULAR_DOMESTIC_SPOTS, rankedDomesticCities);
rankingRepository.update(PopularSpotsKey.POPULAR_DOMESTIC_SPOTS, rankedDomesticCities);
return RepeatStatus.FINISHED;
}, tm)
.build();
Expand All @@ -46,7 +47,7 @@ public Step stepUpdatePopularAbroadCities(JobRepository jobRepository, PlatformT
return new StepBuilder("stepUpdatePopularAbroadCities", jobRepository)
.tasklet((contribution, chunkContext) -> {
List<String> rankedCountries = feedRepository.findTop10CountriesNotKorea(pageable);
rankingRepository.update(CacheKeys.POPULAR_ABROAD_SPOTS, rankedCountries);
rankingRepository.update(PopularSpotsKey.POPULAR_ABROAD_SPOTS, rankedCountries);
return RepeatStatus.FINISHED;
}, tm)
.build();
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/stoury/config/ContextConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ public PasswordEncoder passwordEncoder() {
public GeoApiContext geoApiContext() {
return new GeoApiContext.Builder()
.apiKey(apiKey)
.connectTimeout(5, TimeUnit.SECONDS)
.connectTimeout(2, TimeUnit.SECONDS)
.readTimeout(3, TimeUnit.SECONDS)
.retryTimeout(2, TimeUnit.SECONDS)
.writeTimeout(5, TimeUnit.SECONDS)
.maxRetries(5)
.maxRetries(3)
.build();
}
}
Loading
Loading