Skip to content

[DP-473] 홈 피드 랭킹 방식 변경 — 관심 태그 우선 노출#167

Merged
github-actions[bot] merged 1 commit into
developV2from
auto/fix/DP-473-feed-ranking
May 10, 2026
Merged

[DP-473] 홈 피드 랭킹 방식 변경 — 관심 태그 우선 노출#167
github-actions[bot] merged 1 commit into
developV2from
auto/fix/DP-473-feed-ranking

Conversation

@nYeonG4001
Copy link
Copy Markdown
Collaborator

변경 사항

  • 홈 피드에서 관심 태그 보유 유저가 태그 매핑 글만 조회되던 문제 수정
  • 태그 필터(findByTagIdsAndIsAvailableTrue) → 랭킹 쿼리(findAllRankedByTagIds)로 교체
  • 관심 태그 일치 글을 상단에, 나머지 글은 publishedAt DESC 순으로 하단에 노출

근본 원인

  • DB 기준 is_available=true 비YouTube 글 94개 중 content_tags 매핑이 있는 글은 3개뿐(약 3%)
  • AI 파이프라인(ContentPipeline)이 배치(run_backfill_batch.py) 실행 시에만 태그를 붙이고, 수집기(collector) 자동 호출 없음
  • 태그가 없는 91개 글이 유저 관심 태그 필터링에서 전부 탈락 → 홈에 3개만 표시되는 현상

핵심 변경

// ContentRepository — 신규 쿼리
@Query("""
    SELECT c FROM Content c
    WHERE c.isAvailable = true AND c.source.name <> 'YouTube'
    ORDER BY
      CASE WHEN EXISTS (
        SELECT ct FROM ContentTag ct WHERE ct.content = c AND ct.tag.id IN :tagIds
      ) THEN 0 ELSE 1 END,
      c.publishedAt DESC
    """)
Page<Content> findAllRankedByTagIds(@Param("tagIds") List<UUID> tagIds, Pageable pageable);
// ContentService.getFeed() — 변경 후
if (tagIds.isEmpty()) {
    page = contentRepository.findByIsAvailableTrueOrderByPublishedAtDesc(pageable);
} else {
    page = contentRepository.findAllRankedByTagIds(tagIds, pageable);
}

테스트

  • ContentServiceTest 업데이트: 랭킹 쿼리 호출 검증, 태그 미일치 시에도 전체 글 반환 검증
  • ContentService 커버리지 87% (SonarCloud 기준 80% 충족)

관련 티켓

  • DP-473

content_tags 매핑이 없는 글이 피드에서 탈락하던 문제를 해결.
태그 필터링 대신 CASE WHEN EXISTS 기반 랭킹으로 관심 태그 일치 글을 상단에,
나머지 글을 publishedAt DESC 순으로 하단에 노출.
@github-actions github-actions Bot merged commit 96d72c9 into developV2 May 10, 2026
2 checks passed
@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant