Skip to content

refactor(rank): 매출 데이터 없는 경우 redis 초기화 로직 추가#138

Merged
Jjiggu merged 1 commit into
developfrom
refactor/#137-init-redis
Jul 22, 2025
Merged

refactor(rank): 매출 데이터 없는 경우 redis 초기화 로직 추가#138
Jjiggu merged 1 commit into
developfrom
refactor/#137-init-redis

Conversation

@Jjiggu

@Jjiggu Jjiggu commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

작업 요약

  • 매출 데이터 없는 경우 redis 초기화 로직 추가

Issue Link

#137

문제점 및 어려움

해결 방안

Reference

Summary by CodeRabbit

  • 버그 수정
    • 매출 데이터가 없을 때 랭킹 스냅샷 관련 캐시가 모두 삭제되어, 이전 데이터가 남아있지 않도록 개선되었습니다.

@Jjiggu Jjiggu self-assigned this Jul 22, 2025
@Jjiggu Jjiggu added bug Something isn't working refactor 리팩토링 labels Jul 22, 2025
@coderabbitai

coderabbitai Bot commented Jul 22, 2025

Copy link
Copy Markdown

Walkthrough

이 변경사항은 판매 데이터가 없을 때 Redis에 저장된 현재, 이전, 다음 스냅샷 키를 명시적으로 모두 삭제하도록 RankingRefreshScheduler의 로직을 수정합니다. 기존에는 다음 스냅샷 키만 삭제했으나, 이제 세 개의 키 모두 삭제 후 로직이 종료됩니다.

Changes

파일/경로 변경 요약
.../statistic/scheduler/RankingRefreshScheduler.java 판매 데이터가 없을 때 Redis의 현재, 이전, 다음 스냅샷 키를 모두 삭제하도록 doRefresh() 메서드 수정

Estimated code review effort

1 (~2 minutes)

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions Bot requested a review from HyemIin July 22, 2025 08:59
@Jjiggu Jjiggu linked an issue Jul 22, 2025 that may be closed by this pull request
1 task

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/statistic/scheduler/RankingRefreshScheduler.java (1)

63-66: 매출 데이터 없을 때 Redis 키 정리 로직이 올바르게 구현되었습니다.

전체적인 로직은 올바르게 구현되어 있으며, 매출 데이터가 없을 때 모든 스냅샷 키를 정리하는 것은 적절한 접근법입니다.

다만, nextKey가 중복으로 삭제되고 있습니다 (56번째 줄과 65번째 줄). 기능적으로는 문제가 없지만 불필요한 중복입니다.

다음과 같이 중복 제거를 고려해보세요:

	private void doRefresh() {
		String nextKey = RedisKeyUtils.buildNextKey();
		String currentKey = RedisKeyUtils.buildCurrentKey();
		String previousKey = RedisKeyUtils.buildPreviousKey();

-		// 1) 다음 스냅샷 키 초기화
-		redis.delete(nextKey);

		// 2) DB에서 매출 합계 가져와 ZADD
		List<StoreSales> salesList = statisticCustomRepository.findTotalSales();

		if (salesList.isEmpty()) {
			log.warn("매출 데이터가 없습니다. 다음 스냅샷 키를 초기화합니다.");
			redis.delete(currentKey);
			redis.delete(previousKey);
			redis.delete(nextKey);

			return;
		}

+		// 1) 다음 스냅샷 키 초기화
+		redis.delete(nextKey);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9c78199 and 14e2572.

📒 Files selected for processing (1)
  • nowait-app-admin-api/src/main/java/com/nowait/applicationadmin/statistic/scheduler/RankingRefreshScheduler.java (1 hunks)

@Jjiggu Jjiggu merged commit 30c111a into develop Jul 22, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working refactor 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[백엔드] 매출 순위 스케줄러 조회 시 데이터 최신화 누락

1 participant