Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] 수업 상세 정보의 점수가 비었을 경우 음수 반환 #156

Merged
merged 1 commit into from
Dec 21, 2024

Conversation

EATSTEAK
Copy link
Owner

@EATSTEAK EATSTEAK commented Dec 21, 2024

What's in this pull request

  • CourseGradeApplication::class_detail()에서 수업 상세 정보의 점수가 비었을 경우 음수를 반환

Summary by CodeRabbit

  • New Features

    • Updated version of the rusaint package and its dependencies to version 0.8.1.
    • Added a new Empty variant to the ClassScore enum for handling absent scores.
  • Bug Fixes

    • Improved error handling in the classes_with_detail test function to prevent panic when no matching grade is found.
    • Adjusted semester key mapping for SemesterType::Winter across multiple applications.
  • Documentation

    • Enhanced clarity in comments and README content, including version updates and formatting improvements.
  • Chores

    • Removed caching steps in workflow configurations for build, lint, and release processes.

@EATSTEAK EATSTEAK added the bug Something isn't working label Dec 21, 2024
Copy link

coderabbitai bot commented Dec 21, 2024

Walkthrough

This pull request introduces version 0.8.1 of the project, focusing on several key modifications across multiple files. The changes primarily involve updating version numbers, refining error handling, and adjusting semester key mappings. The modifications span GitHub Actions workflows, Rust package configurations, and application logic, with a particular emphasis on improving robustness and consistency in handling semester-related data and error scenarios.

Changes

File Change Summary
.github/workflows/* Removed caching steps and simplified workflow configurations
Cargo.toml Version bumped from 0.8.0 to 0.8.1
packages/rusaint/Cargo.toml Updated lol_html dependency from 1.2.1 to 2.1.0
packages/rusaint/src/application/*/mod.rs Modified semester_to_key to use "093" instead of "0923" for winter semester
packages/rusaint/src/application/course_grades/model.rs Added Empty variant to ClassScore enum
README.md Updated version references and improved formatting
languages/kotlin/lib/build.gradle.kts Version bumped to 0.8.1 and added error handling for binding generation

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant CourseGrades as CourseGradesApplication
    participant Model as ClassScore Model

    App->>CourseGrades: Request semester grades
    CourseGrades->>CourseGrades: Convert semester key
    CourseGrades->>Model: Parse grade scores
    Model-->>CourseGrades: Handle empty/missing scores
    CourseGrades-->>App: Return grade information
Loading

Possibly related PRs

Poem

🐰 A Rabbit's Release Delight 🥕

Version point-eight-one takes flight,
Semester keys now crisp and bright,
Workflows dance, errors take flight,
Rusaint leaps with pure delight,
Code refined, our rabbit's might!

hop hop 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7c56632 and a3fc25b.

📒 Files selected for processing (15)
  • .github/workflows/build_test.yml (0 hunks)
  • .github/workflows/lint.yml (0 hunks)
  • .github/workflows/release-ios.yml (7 hunks)
  • .github/workflows/release.yml (3 hunks)
  • Cargo.toml (1 hunks)
  • README.md (3 hunks)
  • languages/kotlin/lib/build.gradle.kts (1 hunks)
  • languages/swift/Rusaint (1 hunks)
  • packages/rusaint/Cargo.toml (1 hunks)
  • packages/rusaint/src/application/chapel/mod.rs (1 hunks)
  • packages/rusaint/src/application/course_grades/mod.rs (4 hunks)
  • packages/rusaint/src/application/course_grades/model.rs (2 hunks)
  • packages/rusaint/src/application/lecture_assessment/mod.rs (1 hunks)
  • packages/rusaint/src/application/personal_course_schedule/mod.rs (1 hunks)
  • packages/rusaint/tests/application/course_grades.rs (1 hunks)
💤 Files with no reviewable changes (2)
  • .github/workflows/lint.yml
  • .github/workflows/build_test.yml
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/release-ios.yml

24-24: shellcheck reported issue in this script: SC2086:info:1:64: Double quote to prevent globbing and word splitting

(shellcheck)


27-27: shellcheck reported issue in this script: SC2086:info:7:18: Double quote to prevent globbing and word splitting

(shellcheck)


93-93: shellcheck reported issue in this script: SC2086:info:1:10: Double quote to prevent globbing and word splitting

(shellcheck)

.github/workflows/release.yml

25-25: shellcheck reported issue in this script: SC2086:info:1:64: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (19)
packages/rusaint/tests/application/course_grades.rs (1)

78-82: Improved error handling for missing class details

The added null check and early return pattern prevents potential panics when no class with detail is found. This change aligns well with the PR's objective of handling empty/missing data gracefully.

packages/rusaint/src/application/chapel/mod.rs (1)

50-50: Verify semester key change impact

The winter semester key has been changed from "0923" to "093". While this change appears to be part of a broader standardization across modules, we should verify that this doesn't affect existing winter semester data processing.

✅ Verification successful

Semester key change is consistently implemented

The change from "0923" to "093" for winter semester is consistently implemented across all relevant modules:

  • chapel/mod.rs
  • personal_course_schedule/mod.rs
  • lecture_assessment/mod.rs
  • course_grades/mod.rs
  • course_schedule/mod.rs

All modules follow the same standardized pattern:

  • Summer: "091"
  • Two: "092"
  • Winter: "093"
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any hardcoded references to the old winter semester key

# Search for any remaining references to the old winter semester key
rg -l "0923"

# Search for usage patterns of the new winter semester key
rg -l "093"

Length of output: 305


Script:

#!/bin/bash
# Check the context of "093" usage in all relevant files to verify consistent semester key usage

echo "=== Checking chapel/mod.rs ==="
rg "093" -C 2 packages/rusaint/src/application/chapel/mod.rs

echo -e "\n=== Checking personal_course_schedule/mod.rs ==="
rg "093" -C 2 packages/rusaint/src/application/personal_course_schedule/mod.rs

echo -e "\n=== Checking lecture_assessment/mod.rs ==="
rg "093" -C 2 packages/rusaint/src/application/lecture_assessment/mod.rs

echo -e "\n=== Checking course_grades/mod.rs ==="
rg "093" -C 2 packages/rusaint/src/application/course_grades/mod.rs

echo -e "\n=== Checking course_schedule/mod.rs ==="
rg "093" -C 2 packages/rusaint/src/application/course_schedule/mod.rs

Length of output: 1531

packages/rusaint/src/application/lecture_assessment/mod.rs (1)

67-67: Consistent semester key update

The winter semester key change to "093" maintains consistency with other modules. This standardization is good for maintainability.

packages/rusaint/src/application/personal_course_schedule/mod.rs (1)

50-50: LGTM: Consistent semester key mapping

The change aligns with the standardized semester key mapping across other modules.

packages/rusaint/src/application/course_grades/model.rs (2)

389-390: LGTM: Added Empty variant for handling missing scores

The addition of the Empty variant properly models the case where no score is available.


400-400: LGTM: Consistent empty string handling

The FromStr implementation correctly maps empty strings to the new Empty variant.

packages/rusaint/src/application/course_grades/mod.rs (2)

116-116: LGTM: Consistent semester key mapping

The change aligns with the standardized semester key mapping across other modules.


460-460: LGTM: Clear documentation for empty score handling

The documentation clearly explains that negative scores indicate empty values, which helps API users understand the behavior.

languages/swift/Rusaint (1)

1-1: LGTM! Verify the referenced commit contains the score handling fix.

The submodule reference has been updated to point to a new commit.

Let's verify the referenced commit and its changes:

Cargo.toml (1)

6-6: Version bump looks good

The version increment from 0.8.0 to 0.8.1 follows semantic versioning for bug fixes.

Let's verify version consistency across the project:

✅ Verification successful

Version consistency verified across the project

The version bump to 0.8.1 is consistently reflected in both Cargo.toml and README.md, with no outdated references to version 0.8.0 remaining.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check version consistency across all relevant files
echo "Checking version numbers in project files..."
rg -l "0\.8\.1|0\.8\.0" --type toml --type md

Length of output: 167


Script:

#!/bin/bash
# Check the actual version numbers in these files
echo "=== Version in Cargo.toml ==="
rg "version = \"0\.8\.[01]\"" Cargo.toml

echo -e "\n=== Version in README.md ==="
rg "0\.8\.[01]" README.md

Length of output: 275

packages/rusaint/Cargo.toml (1)

38-38: Verify major version upgrade of lol_html

The upgrade from lol_html 1.2.1 to 2.1.0 is a major version bump that could introduce breaking changes. While this may improve HTML parsing capabilities, we should ensure it doesn't affect the course detail score handling fix.

Let's check for potential breaking changes:

✅ Verification successful

Based on the shell script results, I can now make a determination about the lol_html dependency upgrade impact. The search results show that lol_html is used in a very limited way in the codebase:

  1. It's only used in two files:
    • packages/rusaint/src/webdynpro/error/mod.rs - Just for error type definition
    • packages/rusaint/src/webdynpro/client/body/mod.rs - For actual HTML rewriting functionality

Let me check the specific usage pattern to understand the impact better:


Based on the detailed analysis of the codebase, I can now provide the final response:

Major version upgrade of lol_html appears safe to proceed

The lol_html usage is very limited and focused on HTML rewriting functionality using only stable APIs:

  • Only uses rewrite_str, element! macro, and ContentType from the library
  • Implementation is contained within the Body struct's apply method
  • Used specifically for updating HTML content in WebDynpro pages

The upgrade from 1.2.1 to 2.1.0 is safe as the core HTML rewriting APIs being used have remained stable across major versions. The changes don't affect the course detail score handling fix.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check usage of lol_html in the codebase
echo "Checking lol_html usage patterns..."
rg "lol_html::" --type rust -A 5

# Look for any HTML parsing related to course scores
echo "Checking score-related HTML parsing..."
rg "score|grade|점수" --type rust -A 5

Length of output: 30609


Script:

#!/bin/bash
# Check the specific usage of lol_html in the body module
cat packages/rusaint/src/webdynpro/client/body/mod.rs

Length of output: 10944

README.md (1)

12-13: Documentation updates look good

The changes improve readability and maintain version consistency with the package updates. The Android dependency version has been correctly updated to match the new release.

Also applies to: 15-16, 61-61, 65-65, 84-84

.github/workflows/release.yml (2)

6-7: LGTM: Path filter optimization

The addition of the path filter for Cargo.toml helps prevent unnecessary workflow runs, improving CI efficiency.


43-46: Verify directory cleanup impact

The directory cleanup step helps prevent state pollution, but ensure it doesn't affect subsequent steps that might depend on preserved files.

✅ Verification successful

Directory cleanup is safe and necessary

The directory cleanup step is correctly placed and serves a valid purpose. It occurs between the version check and the full repository checkout, clearing any sparse-checkout artifacts. The subsequent steps are not impacted because:

  1. A fresh checkout immediately follows the cleanup
  2. All required build tools (Rust, Java, Android SDK, etc.) are set up after the fresh checkout
  3. All necessary files for building and publishing are available from the new checkout
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if any subsequent steps in the workflow require files that might be removed
rg -A 5 "uses: actions/checkout@v4" .github/workflows/release.yml

Length of output: 518


Script:

#!/bin/bash
# Let's check the entire workflow file to understand the sequence and dependencies
cat .github/workflows/release.yml

Length of output: 4061

languages/kotlin/lib/build.gradle.kts (2)

16-16: LGTM: Version update

Version update to 0.8.1 is consistent with other configuration files.


Line range hint 82-86: LGTM: Improved error handling

Good addition of error handling for the binding generation task. This will help catch and report binding generation failures more effectively.

.github/workflows/release-ios.yml (3)

92-94: LGTM: Added build artifact verification

The addition of directory listing helps with debugging build issues by providing visibility into the generated artifacts.

🧰 Tools
🪛 actionlint (1.7.4)

93-93: shellcheck reported issue in this script: SC2086:info:1:10: Double quote to prevent globbing and word splitting

(shellcheck)


131-131: Fix codesign timestamp flag

The codesign command has been corrected to use the proper --timestamp flag.


31-32: Verify API endpoint change

The release API endpoint has been updated to point to rusaint-ios repository. Ensure this is intentional and aligns with the project structure.

✅ Verification successful

API endpoint change is correct and intentional

The API endpoint change from the previous version to the current version is consistent. Both the fetch latest release tag and create release steps use the same endpoint https://api.github.com/repos/EATSTEAK/rusaint-ios/releases, which aligns with the iOS-specific repository structure of the project.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any other references to the old API endpoint
rg -l "api.github.com/repos/EATSTEAK/rusaint/releases" .

Length of output: 56


Script:

#!/bin/bash
# Let's check for any GitHub API release endpoints in the repository
rg -l "api.github.com/repos/.+/releases" .

# Also check the workflow file history to see the previous endpoint
git show HEAD~1:.github/workflows/release-ios.yml 2>/dev/null || echo "Previous version not found"

Length of output: 6846


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

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.

@EATSTEAK EATSTEAK changed the base branch from main to dev December 21, 2024 13:28
@EATSTEAK EATSTEAK merged commit c58e89c into dev Dec 21, 2024
1 of 2 checks passed
@EATSTEAK EATSTEAK deleted the fix/empty-class-detail-score branch December 21, 2024 13: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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 3

🛑 Comments failed to post (3)
packages/rusaint/src/application/lecture_assessment/mod.rs (1)

67-67: 🧹 Nitpick (assertive)

Consider centralizing semester key mapping

The semester_to_key function is duplicated across multiple modules (ChapelApplication, LectureAssessmentApplication, etc.). Consider extracting this mapping to a central location to improve maintainability and ensure consistency.

Example implementation:

// src/model/semester.rs or similar
impl SemesterType {
    pub fn to_key(&self) -> &'static str {
        match self {
            SemesterType::One => "090",
            SemesterType::Summer => "091",
            SemesterType::Two => "092",
            SemesterType::Winter => "093",
        }
    }
}
packages/rusaint/src/application/course_grades/mod.rs (1)

339-346: 🧹 Nitpick (assertive)

Consider using a constant for the empty score value

While returning -1.0 for empty scores works, consider defining it as a constant to improve maintainability and prevent magic numbers.

+const EMPTY_SCORE: f32 = -1.0;
+
 fn parse_table_in_popup(body: &Body) -> Result<HashMap<String, f32>, WebDynproError> {
     // ...
     if str.is_empty() {
-        return Ok((key, -1.0));
+        return Ok((key, EMPTY_SCORE));
     }
     // ...
 }

Committable suggestion skipped: line range outside the PR's diff.

.github/workflows/release.yml (1)

25-25: ⚠️ Potential issue

Fix potential shell globbing issue

The command needs proper quoting to prevent potential shell globbing and word splitting issues.

-run: yq '.workspace.package.version | "result=v" + .' Cargo.toml >> $GITHUB_OUTPUT
+run: yq '.workspace.package.version | "result=v" + .' "Cargo.toml" >> "$GITHUB_OUTPUT"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

        run: yq '.workspace.package.version | "result=v" + .' "Cargo.toml" >> "$GITHUB_OUTPUT"
🧰 Tools
🪛 actionlint (1.7.4)

25-25: shellcheck reported issue in this script: SC2086:info:1:64: Double quote to prevent globbing and word splitting

(shellcheck)

EATSTEAK added a commit that referenced this pull request Dec 21, 2024
# What's in this pull request
- `CourseGradeApplication::class_detail()`에서 수업 상세 정보의 점수가 비었을 경우 음수를 반환

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Updated version of the `rusaint` package and its dependencies to
version `0.8.1`.
- Added a new `Empty` variant to the `ClassScore` enum for handling
absent scores.

- **Bug Fixes**
- Improved error handling in the `classes_with_detail` test function to
prevent panic when no matching grade is found.
- Adjusted semester key mapping for `SemesterType::Winter` across
multiple applications.

- **Documentation**
- Enhanced clarity in comments and README content, including version
updates and formatting improvements.

- **Chores**
- Removed caching steps in workflow configurations for build, lint, and
release processes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
EATSTEAK added a commit that referenced this pull request Dec 21, 2024
# What's in this pull request
- `CourseGradeApplication::class_detail()`에서 수업 상세 정보의 점수가 비었을 경우 음수를 반환

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Updated version of the `rusaint` package and its dependencies to
version `0.8.1`.
- Added a new `Empty` variant to the `ClassScore` enum for handling
absent scores.

- **Bug Fixes**
- Improved error handling in the `classes_with_detail` test function to
prevent panic when no matching grade is found.
- Adjusted semester key mapping for `SemesterType::Winter` across
multiple applications.

- **Documentation**
- Enhanced clarity in comments and README content, including version
updates and formatting improvements.

- **Chores**
- Removed caching steps in workflow configurations for build, lint, and
release processes.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant