Skip to content

MOSU-96 feat: 학교 조회시 현재 신청자 수 추가#101

Merged
wlgns12370 merged 8 commits intodevelopfrom
feature/mosu-96
Jul 16, 2025
Merged

MOSU-96 feat: 학교 조회시 현재 신청자 수 추가#101
wlgns12370 merged 8 commits intodevelopfrom
feature/mosu-96

Conversation

@wlgns12370
Copy link
Contributor

@wlgns12370 wlgns12370 commented Jul 15, 2025

✨ 구현한 기능

  • 학교 조회시 현재 신청자 수 필드 추가

📢 논의하고 싶은 내용

  • x

🎸 기타

  • x

Summary by CodeRabbit

  • New Features

    • School listings now display additional information, including lunch details, lunch price, application deadline, and current application counts.
    • Seven new schools with updated details and fields are now available in the system.
    • Payment data for applications has been initialized, reflecting successful and aborted payment statuses.
  • Bug Fixes

    • School listing responses now include real-time quota information for each school.
  • Documentation

    • API documentation updated to reflect new response structure for school listings.

@coderabbitai
Copy link

coderabbitai bot commented Jul 15, 2025

"""

Walkthrough

The changes update the school domain to include lunch, deadline, and quota information. The SchoolResponse and related DTOs are expanded, a new AvailableSchoolResponse is introduced, and service/controller methods are refactored to provide enriched school data with current application counts. School initialization data is also updated to include payment records linked to application schools.

Changes

File(s) Change Summary
SchoolService.java, SchoolController.java, SchoolControllerDocs.java Refactored getSchools() to getAvailableSchools(), updated return types to AvailableSchoolResponse, and added quota data.
SchoolResponse.java Modified record to remove address, add lunch, lunchPrice, deadlineTime fields, and update factory method.
AvailableSchoolResponse.java Introduced new record to encapsulate school data with current application count and quota information.
DatabaseInitializer.java Updated school initialization data to include new fields (lunch, lunchPrice, deadlineTime), added new schools, and added payment data initialization for application schools.
SchoolJpaRepository.java Modified query in countBySchoolNameGroupBy to join with payments and filter by successful payment status.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant SchoolController
    participant SchoolService
    participant SchoolQuotaCacheManager

    Client->>SchoolController: GET /schools
    SchoolController->>SchoolService: getAvailableSchools()
    loop for each school
        SchoolService->>SchoolQuotaCacheManager: getCurrentQuantity(schoolName)
        SchoolQuotaCacheManager-->>SchoolService: currentQuantity
    end
    SchoolService-->>SchoolController: List<AvailableSchoolResponse>
    SchoolController-->>Client: ApiResponseWrapper<List<AvailableSchoolResponse>>
Loading

Possibly related PRs

Suggested reviewers

  • polyglot-k

Poem

A bunny hopped into the code one night,
Adding lunch and deadlines, oh what a sight!
Schools now show quotas, so clear and bright,
With new DTOs, everything feels right.
Hopping through changes, with carrots in tow—
The school list is richer, let’s watch it grow! 🥕
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @wlgns12370, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request primarily enhances the school inquiry functionality by integrating the current number of applicants directly into the school data returned by the API. This provides users with more immediate and relevant information about school availability. Additionally, the underlying school data model has been refined to include more detailed information such as lunch options and application deadlines, improving the overall data representation.

Highlights

  • Enhanced School Information: The getSchools endpoint now returns an AvailableSchoolResponse which includes the currentQuantity (current number of applicants) for each school, providing more comprehensive information to users.
  • New Data Transfer Object: A new DTO, AvailableSchoolResponse, has been introduced to specifically encapsulate the school details along with the current applicant count.
  • School Response Model Update: The SchoolResponse DTO has been refactored to include lunch, lunchPrice, and deadlineTime fields, and the nested address object has been removed, simplifying the response structure.
  • Database Initialization Update: The DatabaseInitializer has been updated to populate the initial school data with values for the newly added lunch, lunchPrice, and deadlineTime fields, and the dummy school names have been changed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@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: 2

🔭 Outside diff range comments (1)
src/main/java/life/mosu/mosuserver/presentation/school/SchoolControllerDocs.java (1)

30-35: Fix inconsistent Swagger documentation schema.

The method signature was updated to return AvailableSchoolResponse, but the @ApiResponse content schema still references SchoolResponse.class. This inconsistency could mislead API consumers about the actual response structure.

@ApiResponse(responseCode = "200", description = "학교 목록 조회 성공",
-        content = @Content(array = @ArraySchema(schema = @Schema(implementation = SchoolResponse.class)))),
+        content = @Content(array = @ArraySchema(schema = @Schema(implementation = AvailableSchoolResponse.class)))),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 12871d5 and 8c67c1c.

📒 Files selected for processing (6)
  • src/main/java/life/mosu/mosuserver/application/school/SchoolService.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/global/initializer/DatabaseInitializer.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/school/SchoolController.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/school/SchoolControllerDocs.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/school/dto/AvailableSchoolResponse.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/school/dto/SchoolResponse.java (2 hunks)
🔇 Additional comments (6)
src/main/java/life/mosu/mosuserver/presentation/school/SchoolController.java (1)

34-38: LGTM! Controller properly updated for new response type.

The controller correctly calls the renamed service method and returns the new AvailableSchoolResponse type, maintaining consistency with the overall refactoring.

src/main/java/life/mosu/mosuserver/global/initializer/DatabaseInitializer.java (1)

116-182: LGTM! School initialization properly updated with new fields.

The initialization correctly adds the new deadlineTime, lunch, and lunchPrice fields to all schools, supporting the enhanced school data model. The data structure is consistent and well-formed.

src/main/java/life/mosu/mosuserver/presentation/school/dto/SchoolResponse.java (1)

7-30: LGTM! SchoolResponse correctly updated with new fields.

The record structure and factory method properly map the new lunch, lunchPrice, and deadlineTime fields while removing the address field. The area mapping change from name() to getAreaName() is also correctly implemented.

src/main/java/life/mosu/mosuserver/presentation/school/dto/AvailableSchoolResponse.java (1)

1-36: LGTM! Clean and well-designed DTO implementation.

The AvailableSchoolResponse record is properly structured with all necessary fields, and the static factory method correctly maps data from SchoolResponse while adding the currentQuantity field. The implementation follows good practices and supports the PR objective of including current applicant counts.

src/main/java/life/mosu/mosuserver/application/school/SchoolService.java (2)

5-5: LGTM: Import addition is appropriate.

The new import for AvailableSchoolResponse is correctly added to support the enhanced response structure.


21-21: Remove inaccurate breaking-change warning

All references to the old getSchools() service method have been updated to getAvailableSchools(), and no calls to schoolService.getSchools() remain in the codebase. The controller still exposes the getSchools() endpoint (unchanged) and delegates to the new service method, so there’s no broken consumer.

• No occurrences of schoolService.getSchools() found
• Controller docs and implementation retain the same endpoint name and have been updated to use AvailableSchoolResponse

Please disregard the original breaking-change comment.

Likely an incorrect or invalid review comment.

Comment on lines +25 to +32
.map(school -> {
SchoolResponse schoolResponse = SchoolResponse.from(school);

Long currentQuantity = schoolQuotaCacheManager.getSchoolApplicationCounts(
schoolResponse.schoolName());

return AvailableSchoolResponse.from(schoolResponse, currentQuantity);
})
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Add error handling and consider performance optimization.

The implementation has several potential issues:

  1. No error handling: The cache manager call could fail, causing the entire operation to fail
  2. N+1 problem: Making individual cache calls for each school could be inefficient
  3. Null handling: No handling for null currentQuantity values

Consider this improved implementation:

 return schoolJpaRepository.findAll()
         .stream()
-        .map(school -> {
-            SchoolResponse schoolResponse = SchoolResponse.from(school);
-
-            Long currentQuantity = schoolQuotaCacheManager.getSchoolApplicationCounts(
-                    schoolResponse.schoolName());
-
-            return AvailableSchoolResponse.from(schoolResponse, currentQuantity);
-        })
+        .map(school -> {
+            SchoolResponse schoolResponse = SchoolResponse.from(school);
+            
+            try {
+                Long currentQuantity = schoolQuotaCacheManager.getSchoolApplicationCounts(
+                        schoolResponse.schoolName());
+                return AvailableSchoolResponse.from(schoolResponse, 
+                        currentQuantity != null ? currentQuantity : 0L);
+            } catch (Exception e) {
+                // Log error and return with default count
+                log.warn("Failed to get application count for school: {}", 
+                        schoolResponse.schoolName(), e);
+                return AvailableSchoolResponse.from(schoolResponse, 0L);
+            }
+        })
         .toList();

For better performance, consider batch operations if the cache manager supports it:

// Get all school names first
List<String> schoolNames = schoolJpaRepository.findAll()
    .stream()
    .map(School::getName)
    .toList();

// Batch get application counts
Map<String, Long> applicationCounts = schoolQuotaCacheManager.getBatchApplicationCounts(schoolNames);

// Then map with cached results
return schoolJpaRepository.findAll()
    .stream()
    .map(school -> {
        SchoolResponse schoolResponse = SchoolResponse.from(school);
        Long currentQuantity = applicationCounts.getOrDefault(schoolResponse.schoolName(), 0L);
        return AvailableSchoolResponse.from(schoolResponse, currentQuantity);
    })
    .toList();
🤖 Prompt for AI Agents
In src/main/java/life/mosu/mosuserver/application/school/SchoolService.java
around lines 25 to 32, the current code calls the cache manager individually for
each school without error handling, causing potential failures and performance
issues due to N+1 calls, and lacks null handling for currentQuantity. Refactor
to first collect all school names, then perform a batch cache call to get
application counts in one operation, handle any exceptions from the cache
manager gracefully, and use getOrDefault to assign zero when currentQuantity is
null before mapping to AvailableSchoolResponse.

public class SchoolService {

private final SchoolJpaRepository schoolJpaRepository;
private final SchoolQuotaCacheManager schoolQuotaCacheManager;
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify cache manager implementation for performance and reliability.

The new dependency schoolQuotaCacheManager is properly injected, but ensure that:

  1. The cache manager is optimized for batch operations if dealing with many schools
  2. It has proper error handling and fallback mechanisms
  3. Cache invalidation strategies are in place for real-time accuracy

🏁 Script executed:

#!/bin/bash
# Description: Verify the SchoolQuotaCacheManager implementation for performance and error handling

# Search for the cache manager implementation
ast-grep --pattern 'class SchoolQuotaCacheManager {
  $$$
}'

# Also search for the getSchoolApplicationCounts method implementation
ast-grep --pattern 'getSchoolApplicationCounts($$$) {
  $$$
}'

Length of output: 127


🏁 Script executed:

#!/bin/bash
# Locate the SchoolQuotaCacheManager implementation file
echo "Searching for SchoolQuotaCacheManager.java..."
fd --extension java SchoolQuotaCacheManager

# If found, inspect class declaration and key methods
for file in $(fd --extension java SchoolQuotaCacheManager); do
  echo -e "\n--- Inspecting $file ---"
  # Show class declaration and first 200 lines
  sed -n '1,200p' "$file" | sed -n '/class SchoolQuotaCacheManager/,/^}/p'
  echo -e "\nMethod definitions in $file:"
  grep -RnoP 'public\s+.*getSchoolApplicationCounts' "$file"
  grep -RnoP 'public\s+.*batch' "$file"
  grep -RnoP -i 'error|exception|fail' "$file"
  grep -RnoP -i 'invalidate|evict|clear' "$file"
done

Length of output: 3583


Implement batching, error handling, and cache invalidation in SchoolQuotaCacheManager

The current implementation in
src/main/java/life/mosu/mosuserver/application/school/SchoolQuotaCacheManager.java
uses per‐key loops and has no error handling or eviction logic. To improve performance and reliability, please:

  • Replace individual set calls in cacheSchoolMaxCapacities() and cacheSchoolCurrentApplicationCounts() with Redis pipelining or opsForValue().multiSet() for bulk writes.
  • Wrap all Redis operations (set, get, increment, decrement) in try/catch blocks and fall back to schoolRepository reads if Redis is unavailable.
  • Add cache expiration or explicit invalidation methods (e.g. redisTemplate.expire(...) or invalidateSchoolCache(String schoolName)) to ensure real-time accuracy.
🤖 Prompt for AI Agents
In
src/main/java/life/mosu/mosuserver/application/school/SchoolQuotaCacheManager.java
around line 18, the current cache methods use per-key loops without error
handling or cache eviction. Refactor cacheSchoolMaxCapacities() and
cacheSchoolCurrentApplicationCounts() to use Redis pipelining or
opsForValue().multiSet() for bulk writes to improve performance. Wrap all Redis
operations like set, get, increment, and decrement in try/catch blocks to handle
Redis failures gracefully by falling back to schoolRepository reads. Add cache
expiration settings or implement explicit cache invalidation methods such as
invalidateSchoolCache(String schoolName) using redisTemplate.expire(...) to
maintain cache accuracy.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds the current number of applicants to the school list API endpoint. The changes are mostly in the service and presentation layers, with a new DTO to carry the additional information.

My review has identified a few issues:

  • A significant performance bottleneck (N+1 problem) in SchoolService due to repeated Redis calls.
  • A potential issue where the number of applicants could be null instead of 0.
  • An inconsistency in the API documentation where the response schema doesn't match the implementation.

I've provided suggestions to address these points to improve performance and correctness.

Comment on lines 23 to 33
return schoolJpaRepository.findAll()
.stream()
.map(SchoolResponse::from)
.map(school -> {
SchoolResponse schoolResponse = SchoolResponse.from(school);

Long currentQuantity = schoolQuotaCacheManager.getSchoolApplicationCounts(
schoolResponse.schoolName());

return AvailableSchoolResponse.from(schoolResponse, currentQuantity);
})
.toList();

Choose a reason for hiding this comment

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

high

This implementation has a performance issue known as the N+1 problem. It iterates through all schools and makes a separate call to Redis for each school inside the map function. This can lead to a large number of network requests and slow down the API response, especially as the number of schools grows.

To optimize this, you should fetch all school application counts in a single batch request.

Here's a suggested approach:

  1. Fetch all schools from the repository.
  2. Collect all school names.
  3. Make a single batch call to SchoolQuotaCacheManager to get all counts (this would require adding a new method to SchoolQuotaCacheManager that accepts a list of school names and uses Redis' MGET command).
  4. Create a map of school names to their application counts.
  5. Stream over the schools list and use the map to look up the count for each school.

Example implementation:

public List<AvailableSchoolResponse> getAvailableSchools() {
    List<SchoolJpaEntity> schools = schoolJpaRepository.findAll();
    List<String> schoolNames = schools.stream()
            .map(SchoolJpaEntity::getSchoolName)
            .toList();

    // This method would need to be implemented in SchoolQuotaCacheManager
    // to perform a batch fetch from Redis.
    Map<String, Long> applicationCounts = schoolQuotaCacheManager.getSchoolApplicationCountsInBatch(schoolNames);

    return schools.stream()
            .map(school -> {
                SchoolResponse schoolResponse = SchoolResponse.from(school);
                Long currentQuantity = applicationCounts.getOrDefault(school.getSchoolName(), 0L);
                return AvailableSchoolResponse.from(schoolResponse, currentQuantity);
            })
            .toList();
}

This change will significantly improve the performance of this endpoint.

school.lunchPrice(),
school.deadlineTime(),
school.examDate(),
currentQuantity,

Choose a reason for hiding this comment

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

high

The schoolQuotaCacheManager.getSchoolApplicationCounts() method can return null if a school has no applications yet and its count is not in the cache. This will result in currentQuantity being null in the API response, which can be problematic for clients.

It's better to treat a missing count as zero. You can ensure currentQuantity is never null by providing a default value here.

Suggested change
currentQuantity,
currentQuantity != null ? currentQuantity : 0L,

@@ -31,5 +32,5 @@ public interface SchoolControllerDocs {
content = @Content(array = @ArraySchema(schema = @Schema(implementation = SchoolResponse.class)))),

Choose a reason for hiding this comment

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

medium

The OpenAPI documentation for this endpoint is incorrect. The schema implementation is set to SchoolResponse.class, but the controller method now returns a list of AvailableSchoolResponse. This will cause the generated API documentation to show the wrong response model for clients.

Please update the schema to use AvailableSchoolResponse.class to match the actual response type.

Suggested change
content = @Content(array = @ArraySchema(schema = @Schema(implementation = SchoolResponse.class)))),
content = @Content(array = @ArraySchema(schema = @Schema(implementation = AvailableSchoolResponse.class)))),

@wlgns12370 wlgns12370 added this to the 모수 MVP API 구현 milestone Jul 15, 2025
@wlgns12370 wlgns12370 linked an issue Jul 15, 2025 that may be closed by this pull request
@wlgns12370 wlgns12370 merged commit 447e374 into develop Jul 16, 2025
1 of 2 checks passed
@wlgns12370 wlgns12370 deleted the feature/mosu-96 branch July 16, 2025 09:29
Copy link

@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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8c67c1c and 08a618f.

📒 Files selected for processing (3)
  • src/main/java/life/mosu/mosuserver/domain/school/SchoolJpaRepository.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/global/initializer/DatabaseInitializer.java (8 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/school/SchoolControllerDocs.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/life/mosu/mosuserver/presentation/school/SchoolControllerDocs.java
🔇 Additional comments (5)
src/main/java/life/mosu/mosuserver/global/initializer/DatabaseInitializer.java (5)

5-5: Import additions look appropriate.

The new imports for LocalDateTime, UUID, and payment-related classes are correctly added to support the enhanced initialization logic.

Also applies to: 12-12, 28-32, 65-65


80-82: Method signature change is properly implemented.

The initializeApplications method now returns the created application schools to enable subsequent payment initialization, which is the correct approach for the data dependency chain.


128-136: School initialization enhanced with required fields.

The school initialization now includes the new deadlineTime, lunch, and lunchPrice fields, providing realistic test data that aligns with the enhanced school model.

Also applies to: 138-146, 147-156, 158-166, 167-176, 178-186


193-195: Application initialization properly refactored.

The method signature and logic have been updated to collect and return created application schools, enabling the payment initialization flow.

Also applies to: 196-196, 219-219, 234-234, 238-239


241-280: Payment initialization logic is well-implemented.

The payment initialization creates a balanced dataset with half successful and half failed payments, which provides good test coverage for the payment status filtering logic in the repository query.

The implementation correctly:

  • Creates realistic payment amounts with proper breakdown
  • Uses appropriate payment methods and statuses
  • Maintains referential integrity with application schools
  • Provides balanced test data distribution

Comment on lines +15 to +16
LEFT JOIN PaymentJpaEntity p ON p.applicationSchoolId = a.id
WHERE p.paymentStatus = 'DONE'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix query logic to include schools with zero paid applications.

The current WHERE clause will exclude schools that have no applications with successful payments from the result set entirely. This is likely incorrect behavior - schools with 0 paid applications should still appear in the results with a count of 0.

Move the payment status condition to the JOIN clause to preserve schools with zero paid applications:

-                LEFT JOIN PaymentJpaEntity p ON p.applicationSchoolId = a.id
-                WHERE p.paymentStatus = 'DONE'
+                LEFT JOIN PaymentJpaEntity p ON p.applicationSchoolId = a.id AND p.paymentStatus = 'DONE'

This ensures all schools are included in the results, with accurate counts of only successfully paid applications.

🤖 Prompt for AI Agents
In src/main/java/life/mosu/mosuserver/domain/school/SchoolJpaRepository.java
around lines 15 to 16, the WHERE clause filtering on p.paymentStatus = 'DONE'
excludes schools without paid applications. To fix this, move the paymentStatus
= 'DONE' condition from the WHERE clause into the LEFT JOIN condition itself.
This change will preserve all schools in the results, including those with zero
paid applications, while still counting only successfully paid applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[🛠 기능 구현] 학교 조회시 현재 신청자 수 추가

1 participant

Comments