Skip to content

Add daily rotating recommended category endpoint#53

Closed
Copilot wants to merge 3 commits intodevelopfrom
copilot/add-recommended-category-tab
Closed

Add daily rotating recommended category endpoint#53
Copilot wants to merge 3 commits intodevelopfrom
copilot/add-recommended-category-tab

Conversation

Copy link
Copy Markdown

Copilot AI commented Jan 22, 2026

Implements /api/categories/today-recommended endpoint that returns category recommendations that rotate daily but remain consistent within each day.

Implementation

  • Daily rotation via deterministic shuffling: Uses LocalDate.now().toEpochDay() as Random seed to ensure same-day consistency
  • Redis caching: Date-based cache key CATEGORIES:TODAY_RECOMMENDED:YYYY-MM-DD with 24h TTL
  • Cache validation: Falls through to regeneration if cached list has insufficient items for requested count

Code

public List<CategorySimpleResponse> getTodayRecommendedCategories(int count) {
    LocalDate today = LocalDate.now();
    String cacheKey = CacheKeyConstants.TODAY_RECOMMENDED_CATEGORIES + ":" + today;
    
    List<CategorySimpleResponse> cached = redisCacheService.getList(cacheKey, CategorySimpleResponse.class);
    if (cached != null && cached.size() >= count) {
        return cached.stream().limit(count).collect(Collectors.toList());
    }
    
    List<Category> subCategories = categoryRepository.findAllSubCategories();
    List<Category> shuffledCategories = new ArrayList<>(subCategories);
    Collections.shuffle(shuffledCategories, new Random(today.toEpochDay()));
    
    // ... cache and return
}

API

GET /api/categories/today-recommended?count=8

  • Returns: List<CategorySimpleResponse> (categoryId, name, iconUrl, displayOrder)
  • Default count: 8, range: 1-100
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feat]오늘의 추천 카테고리 탭</issue_title>
<issue_description>## 📌 Description

[Feat]오늘의 추천 카테고리 탭

✅ To-do

  • 진행 예정
  • 진행 완료

📒 기타</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 22, 2026 17:54
Co-authored-by: neibler <87866961+neibler@users.noreply.github.com>
…d validate cache size

Co-authored-by: neibler <87866961+neibler@users.noreply.github.com>
Copilot AI changed the title [WIP] Add today's recommended category tab feature Add daily rotating recommended category endpoint Jan 22, 2026
Copilot AI requested a review from neibler January 22, 2026 17:58
@neibler neibler closed this Jan 23, 2026
@neibler neibler reopened this Jan 23, 2026
@neibler neibler closed this Jan 25, 2026
@marshmallowing marshmallowing deleted the copilot/add-recommended-category-tab branch January 26, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]마이페이지 -개인 프로필

2 participants