Skip to content

Add admin retrospect creation cycle average API#468

Closed
mikekks wants to merge 1 commit into
developfrom
codex/add-api-for-average-retrospective-data
Closed

Add admin retrospect creation cycle average API#468
mikekks wants to merge 1 commit into
developfrom
codex/add-api-for-average-retrospective-data

Conversation

@mikekks
Copy link
Copy Markdown
Collaborator

@mikekks mikekks commented May 9, 2026

Motivation

  • Provide an admin API to calculate average retrospect creation cycle (overall, team, individual) for a given time range so admins can monitor how frequently retrospects are created.

Description

  • Added a new controller endpoint GET /admin/retrospect/creation-cycle-average wired to AdminRetrospectService#getRetrospectCreationCycleAverage.
  • Introduced response DTO RetrospectCreationCycleAverageResponse with totalAverageSeconds, teamRetrospectAverageSeconds, and individualRetrospectAverageSeconds fields.
  • Added repository queries findEventTimesBetween and findEventTimesBetweenBySpaceCategory to AdminRetrospectHistoryRepository to fetch ordered creation timestamps overall and filtered by AdminSpaceCategory.
  • Implemented service logic to compute average adjacent-event gap in seconds (calculateAverageCreationCycleSeconds) and return per-category and overall averages.

Testing

  • Ran git diff --check which reported no issues.
  • Attempted to compile with ./gradlew :layer-admin:compileJava but it failed in this environment due to an initial JDK classfile/version mismatch (Unsupported class file major version 69).
  • Re-ran compilation with JAVA_HOME=/root/.local/share/mise/installs/java/17.0.2 ./gradlew :layer-admin:compileJava and --offline, both of which failed because the Gradle Spring Boot plugin (org.springframework.boot:3.3.1) could not be resolved in the current environment or local cache.

Codex Task

Summary by CodeRabbit

새로운 기능

  • 관리자 회고 분석: 지정한 기간에 대해 전체 회고, 팀 회고, 개별 회고의 평균 생성 주기를 초 단위로 조회할 수 있는 새로운 분석 기능이 추가되었습니다.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

개요

이 PR은 회고 생성 주기의 평균 시간을 계산하고 조회하는 새로운 관리자 엔드포인트를 추가합니다. 날짜 범위 내 이벤트 타임스탬프를 쿼리하고 연속된 이벤트 간의 간격을 평균하여 전체, 팀, 개별 회고의 생성 주기 평균을 반환합니다.

변경사항

회고 생성 주기 평균 조회 기능

계층 / 파일 설명
응답 데이터 정의
layer-admin/src/main/java/org/layer/admin/retrospect/controller/dto/RetrospectCreationCycleAverageResponse.java
RetrospectCreationCycleAverageResponse 레코드는 총 평균 시간, 팀 회고 평균 시간, 개별 회고 평균 시간을 나타내는 세 개의 double 필드를 정의합니다.
데이터 접근 계층
layer-admin/src/main/java/org/layer/admin/retrospect/repository/AdminRetrospectHistoryRepository.java
두 개의 새로운 쿼리 메서드를 추가합니다. findEventTimesBetween()은 날짜 범위 내 모든 이벤트 타임스탬프를 반환하고, findEventTimesBetweenBySpaceCategory()는 동일 범위에서 공간 범주별로 필터링된 타임스탬프를 반환합니다.
서비스 로직
layer-admin/src/main/java/org/layer/admin/retrospect/service/AdminRetrospectService.java
getRetrospectCreationCycleAverage() 메서드는 저장소에서 모든 회고와 범주별 이벤트 타임스탬프를 조회한 후, 연속된 타임스탬프 간의 평균 간격을 계산하고 응답 DTO를 반환합니다. 또한 평균 계산을 수행하는 calculateAverageSeconds() 헬퍼 메서드를 추가합니다.
API 엔드포인트
layer-admin/src/main/java/org/layer/admin/retrospect/controller/AdminRetrospectController.java
GET /admin/retrospect/creation-cycle-average 엔드포인트를 추가합니다. 시작 날짜와 종료 날짜 파라미터를 받아 서비스 메서드로 위임하고, ResponseEntity로 감싼 응답을 반환합니다.

예상 코드 리뷰 노력

🎯 2 (Simple) | ⏱️ ~10분

🐰 데이터 흐름 정확히 하니,
연속 시간들 평균을 구해,
팀과 개인 구분하여 계산하고,
엔드포인트로 깔끔하게 드러내네!
새로운 지표, 반짝반짝! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning Pull request description provides motivation, detailed description of changes, and testing attempts. However, it does not follow the repository's required template structure with sections like '📝 PR 타입', '📢 변경 사항', etc. Reformat the description to follow the repository's required template: add checkboxes for PR type selection, organize changes under '📢 변경 사항', add '❗️To Reviewer' section, and include complete '⚙️ 테스트 결과' with query logs.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Pull request title clearly and specifically describes the main change: adding a new admin API endpoint for calculating retrospect creation cycle averages.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/add-api-for-average-retrospective-data

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@layer-admin/src/main/java/org/layer/admin/retrospect/repository/AdminRetrospectHistoryRepository.java`:
- Around line 36-46: The JOIN in
AdminRetrospectHistoryRepository.findEventTimesBetweenBySpaceCategory can
produce duplicate or temporally incorrect matches because it joins only on
spaceId; update the query to match the AdminSpaceHistory row that reflects the
space's category at the retrospective eventTime (e.g., add "AND s.eventTime <=
r.eventTime" and choose the latest s.eventTime per space prior to r.eventTime
via a subquery or window function), and/or apply DISTINCT to the selected
r.eventTime to avoid duplicates; locate the query string in
AdminRetrospectHistoryRepository and modify it to enforce s.eventTime <=
r.eventTime and select the most recent AdminSpaceHistory record per spaceId
before r.eventTime (or add DISTINCT) so results are temporally accurate and
deduplicated.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c4ed1134-5de7-4374-aa36-9ec7e6ab49d6

📥 Commits

Reviewing files that changed from the base of the PR and between 4c5aae0 and 54b39d1.

📒 Files selected for processing (4)
  • layer-admin/src/main/java/org/layer/admin/retrospect/controller/AdminRetrospectController.java
  • layer-admin/src/main/java/org/layer/admin/retrospect/controller/dto/RetrospectCreationCycleAverageResponse.java
  • layer-admin/src/main/java/org/layer/admin/retrospect/repository/AdminRetrospectHistoryRepository.java
  • layer-admin/src/main/java/org/layer/admin/retrospect/service/AdminRetrospectService.java

Comment on lines +36 to +46
@Query("SELECT r.eventTime " +
"FROM AdminRetrospectHistory r " +
"JOIN AdminSpaceHistory s ON r.spaceId = s.spaceId " +
"WHERE r.eventTime BETWEEN :startTime AND :endTime " +
"AND s.category = :category " +
"ORDER BY r.eventTime ASC")
List<LocalDateTime> findEventTimesBetweenBySpaceCategory(
@Param("startTime") LocalDateTime startTime,
@Param("endTime") LocalDateTime endTime,
@Param("category") AdminSpaceCategory category
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# AdminSpaceHistory 엔티티 구조 및 spaceId 중복 여부 확인

# AdminSpaceHistory 엔티티 클래스 찾기
fd -e java AdminSpaceHistory

# AdminSpaceHistory의 필드와 관계 확인
rg -A 20 'class AdminSpaceHistory' --type java

# spaceId를 기준으로 그룹화하는 다른 쿼리가 있는지 확인 (중복 처리 패턴 파악)
rg -n 'AdminSpaceHistory.*spaceId' --type java -C 3

Repository: depromeet/layer-server

Length of output: 3104


🏁 Script executed:

# Check AdminRetrospectHistory entity structure
fd -e java AdminRetrospectHistory | head -5

# Get full AdminRetrospectHistory class
rg -A 30 'class AdminRetrospectHistory' --type java -m 1

# Check other queries in the repository that use AdminSpaceHistory to understand patterns
rg 'JOIN AdminSpaceHistory|FROM AdminSpaceHistory' --type java -B 3 -A 8

Repository: depromeet/layer-server

Length of output: 7401


🏁 Script executed:

# Check if there are unique constraints or indexes on spaceId in AdminSpaceHistory
rg '@Unique|@Index|@Column.*unique' layer-admin/src/main/java/org/layer/admin/space/entity/AdminSpaceHistory.java

# Check the full AdminSpaceHistory entity to see all fields and constraints
cat -n layer-admin/src/main/java/org/layer/admin/space/entity/AdminSpaceHistory.java

# Check if there are tests using this method to understand expected behavior
rg 'findEventTimesBetweenBySpaceCategory' --type java -B 3 -A 5

Repository: depromeet/layer-server

Length of output: 4772


JOIN 쿼리의 정확성 문제를 확인했습니다.

spaceId 기반 JOIN이 잠재적으로 잘못된 결과를 생성할 수 있습니다:

  1. 중복 문제: AdminSpaceHistoryspaceId에 대한 유니크 제약이 없어, 동일한 spaceId에 여러 레코드가 존재할 수 있습니다. 이 경우 JOIN 결과로 동일한 eventTime이 중복 반환됩니다.

  2. 시간적 정확성 부재: 현재 쿼리는 AdminSpaceHistory에 시간 필터가 없어, 회고 생성 시점(r.eventTime)의 스페이스 카테고리를 반영하지 않습니다. 스페이스 카테고리가 변경된 경우, 잘못된 카테고리로 분류될 수 있습니다.

  3. 데이터 무결성: spaceId만으로 JOIN하면 과거에 변경된 다른 카테고리 상태까지 모두 매칭되어, 의도하지 않은 데이터 포함으로 통계 계산이 부정확해질 수 있습니다.

해결 방안:

  • DISTINCT를 추가하거나
  • AND s.eventTime <= r.eventTime 조건으로 회고 생성 시점의 카테고리만 매칭하거나
  • 필요에 따라 가장 최근의 스페이스 상태만 선택하도록 수정해야 합니다.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@layer-admin/src/main/java/org/layer/admin/retrospect/repository/AdminRetrospectHistoryRepository.java`
around lines 36 - 46, The JOIN in
AdminRetrospectHistoryRepository.findEventTimesBetweenBySpaceCategory can
produce duplicate or temporally incorrect matches because it joins only on
spaceId; update the query to match the AdminSpaceHistory row that reflects the
space's category at the retrospective eventTime (e.g., add "AND s.eventTime <=
r.eventTime" and choose the latest s.eventTime per space prior to r.eventTime
via a subquery or window function), and/or apply DISTINCT to the selected
r.eventTime to avoid duplicates; locate the query string in
AdminRetrospectHistoryRepository and modify it to enforce s.eventTime <=
r.eventTime and select the most recent AdminSpaceHistory record per spaceId
before r.eventTime (or add DISTINCT) so results are temporally accurate and
deduplicated.

@mikekks mikekks closed this May 9, 2026
@mikekks mikekks deleted the codex/add-api-for-average-retrospective-data branch May 9, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant