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

Iris: Fix message rating #9653

Merged
merged 1 commit into from
Nov 3, 2024
Merged

Iris: Fix message rating #9653

merged 1 commit into from
Nov 3, 2024

Conversation

alexjoham
Copy link
Member

@alexjoham alexjoham commented Nov 2, 2024

Checklist

General

  • I tested all changes and their related features with all corresponding user types on a test server.
  • This is a small issue that I tested locally and was confirmed by another developer on a test server.
  • I chose a title conforming to the naming conventions for pull requests.

Motivation and Context

This PR fixes the problem with rating Iris messages; the messages couldn't be rated anymore, and Iris showed an error.

Description

As there was an update with the REST controller and the IrisChatHttpService was not updated, a simple change was needed to resolve this problem. The change now sends the value via the body as a raw value.

Steps for Testing

Prerequisites:

  • Course with Iris activated
  1. Log in to Artemis
  2. Navigate to a course or exercise and send Iris a message
  3. Try to rate the received answer and check if it is still rated after a reload and no error is thrown

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance even for very large courses with more than 2000 students.
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance even for very large courses with more than 2000 students.

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Performance Tests

  • Test 1
  • Test 2

Test Coverage

Client

Class/File Line Coverage Confirmation (assert/expect)
iris-chat-http.service.ts 93.1% ✅ ❌

Summary by CodeRabbit

  • New Features

    • Improved the rateMessage functionality by sending the helpful parameter as part of the request body, enhancing the structure of HTTP requests.
  • Bug Fixes

    • No significant bugs reported; existing functionalities remain intact.
  • Documentation

    • Updated method signature for clarity on the new request handling approach.

@alexjoham alexjoham self-assigned this Nov 2, 2024
@alexjoham alexjoham requested a review from a team as a code owner November 2, 2024 11:04
@github-actions github-actions bot added the client Pull requests that update TypeScript code. (Added Automatically!) label Nov 2, 2024
Copy link

coderabbitai bot commented Nov 2, 2024

Walkthrough

The changes involve a modification to the rateMessage method in the IrisChatHttpService class. The helpful parameter is now sent in the body of the HTTP PUT request instead of as part of the URL path. This adjustment aligns with conventional practices for sending data in HTTP requests. Other methods in the service remain unchanged, and the overall control flow and error handling mechanisms are preserved.

Changes

File Path Change Summary
src/main/webapp/app/iris/iris-chat-http.service.ts Modified rateMessage method to send helpful parameter in request body instead of URL path. Other methods remain unchanged.

Suggested labels

tests, ready for review, client, iris

Suggested reviewers

  • krusche

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 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 or @coderabbitai title 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.

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: 0

🧹 Outside diff range and nitpick comments (1)
src/main/webapp/app/iris/iris-chat-http.service.ts (1)

98-98: Consider adding error handling documentation.

While the implementation is correct, it would be helpful to document the expected error scenarios (e.g., invalid message ID, session not found) to guide component-level error handling.

Add JSDoc to describe error scenarios:

     /**
      * Sets a helpfulness rating for a message
      * @param {number} sessionId of the session of the message that should be rated
      * @param {number} messageId of the message that should be rated
      * @param {boolean} helpful rating of the message
      * @return {Observable<EntityResponseType>} an Observable of the HTTP responses
+     * @throws {HttpErrorResponse} 404 if message or session not found
+     * @throws {HttpErrorResponse} 403 if user not authorized to rate message
      */
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4954074 and 0489d55.

📒 Files selected for processing (1)
  • src/main/webapp/app/iris/iris-chat-http.service.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/main/webapp/app/iris/iris-chat-http.service.ts (1)

Pattern src/main/webapp/**/*.ts: angular_style:https://angular.io/guide/styleguide;methods_in_html:false;lazy_loading:true;code_reuse:true;tests:meaningful;types:PascalCase;enums:PascalCase;funcs:camelCase;props:camelCase;no_priv_prefix:true;strings:single_quotes;localize:true;btns:functionality;links:navigation;icons_text:newline;labels:associate;code_style:arrow_funcs,curly_braces,open_braces_same_line,indent_4;memory_leak_prevention:true;routes:naming_schema;chart_framework:ngx-charts;responsive_layout:true

🔇 Additional comments (1)
src/main/webapp/app/iris/iris-chat-http.service.ts (1)

98-98: LGTM! The implementation follows Angular best practices.

The change correctly moves the helpful parameter from URL path to request body, which is more RESTful and aligns with conventional practices for PUT requests.

Let's verify the REST controller endpoint compatibility:

✅ Verification successful

The frontend service implementation correctly matches the backend endpoint

The REST controller endpoint in IrisMessageResource.java accepts the helpful parameter as a request body (@RequestBody Boolean helpful), which perfectly aligns with the HTTP service implementation that sends the parameter in the request body using httpClient.put(). The endpoint URL structure /sessions/${sessionId}/messages/${messageId}/helpful also matches exactly between frontend and backend.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the REST controller endpoint matches the new implementation
# Expected: Controller should accept the boolean value in request body

# Search for the corresponding REST controller endpoint
rg -t java -A 10 "helpful.*IrisMessage" src/main/java

Length of output: 55


Script:

#!/bin/bash
# Let's try different search patterns to locate the REST controller endpoint

# Search for controller methods handling message rating
rg -t java "PUT.*messages/.*helpful" src/main/java

# Search for controller class handling Iris messages
rg -t java "class.*Controller.*Iris" src/main/java

# Search for helpful-related method signatures
rg -t java "@PutMapping.*helpful" src/main/java

Length of output: 477


Script:

#!/bin/bash
# Let's examine the implementation of the helpful endpoint in IrisMessageResource.java
rg -A 10 "@PutMapping.*helpful" src/main/java/de/tum/cit/aet/artemis/iris/web/IrisMessageResource.java

Length of output: 877

Copy link
Contributor

@iyannsch iyannsch left a comment

Choose a reason for hiding this comment

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

Code changes make sense imo, having the value in the body looks better than again pushing it into the path 👍

Copy link

@HawKhiem HawKhiem left a comment

Choose a reason for hiding this comment

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

Tested on TS1. Iris response is still rated after reload

image

Copy link
Contributor

@sebastianloose sebastianloose left a comment

Choose a reason for hiding this comment

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

Tested locally. Rating messages now works as expected

Copy link
Contributor

@coolchock coolchock left a comment

Choose a reason for hiding this comment

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

code changes make sense

@krusche krusche changed the title Iris: Fix Iris message rating Iris: Fix message rating Nov 3, 2024
@krusche krusche merged commit 71151b7 into develop Nov 3, 2024
76 of 83 checks passed
@krusche krusche deleted the bugfix/iris/fix-message-rating branch November 3, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix client Pull requests that update TypeScript code. (Added Automatically!) ready to merge
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants