Skip to content

Commit

Permalink
refactor(controller): 상수 추출
Browse files Browse the repository at this point in the history
  • Loading branch information
jminkkk committed Dec 30, 2024
1 parent 1536a34 commit 7d94d65
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public ResponseEntity<FindAllTagsResponse> getTags(@RequestParam Long memberId)
}

@GetMapping("/top")
public ResponseEntity<FindAllTagsResponse> getTopTags(@RequestParam(defaultValue = "10") int size) {
public ResponseEntity<FindAllTagsResponse> getTopTags(@RequestParam(defaultValue = DEFAULT_TOP_TAG_COUNT) int size) {
FindAllTagsResponse response = tagService.getTopTags(size);
return ResponseEntity.ok(response);
}
Expand Down
3 changes: 2 additions & 1 deletion backend/src/main/java/codezap/tag/service/TagService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@Transactional(readOnly = true)
public class TagService {

private static final int DEFAULT_POPULAR_DATE_RANGE = 7;
private final TagRepository tagRepository;
private final TemplateTagRepository templateTagRepository;

Expand Down Expand Up @@ -89,7 +90,7 @@ public FindAllTagsResponse getTopTags(int size) {
}

private List<Tag> findTopTags(int size, LocalDate startDate) {
List<Tag> tags = tagRepository.findMostUsedTagsWithinDateRange(size, startDate.minusDays(7));
List<Tag> tags = tagRepository.findMostUsedTagsWithinDateRange(size, startDate.minusDays(DEFAULT_POPULAR_DATE_RANGE));

if (tags.size() >= size) {
return tags;
Expand Down

0 comments on commit 7d94d65

Please sign in to comment.