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

Development: Handle lecture files persistency directly #7921

Merged
merged 42 commits into from
Mar 8, 2024

Conversation

julian-christl
Copy link
Member

@julian-christl julian-christl commented Jan 20, 2024

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) database calls.
  • I followed the coding and design guidelines.
  • I documented the Java code using JavaDoc style.

Motivation and Context

In #5427 and #6569 I replaced the two-parted upload with a single multipart upload but forgot to remove the delayed persistence of the file path that was now obsolete.

Description

  • Replaced file handling of attachments, attachment units and slides for creation, update and deletion
  • removed entity-based persistence for attachments, attachment units and slides
  • removed entity-based persistence for course icons as I forgot in a previous PR
  • opened up direct save in FileService to allow saving files with their original file name, though with some random section to prevent overrides
  • fixed tests which were handling the file upload directly
  • set some methods of the FilePathService to static to use it in the test factory

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Students

Note: While creating and editing, keep track with your student account if everything works out from the student's point of view (especially the download of the files)

  1. Create a lecture
  2. Create a file lecture unit
  3. Update the file lecture unit with full changes
  4. Update the file lecture unit gradually (with and without a new file)
  5. (Upload a PDF file if not already done)
  6. Make sure the PDF got split into slides by creating a communication post and attempting to reference a slide in there.
  7. Make sure the reference is not broken

Navigate to attachments:

  • Create an attachment
  • Update the attachment with a new file
  • Update the attachment without a new file
  • Make sure that the student can see the file and the changes correctly

Testserver States

Note

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







Review Progress

Performance Review

  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Class/File Line Coverage Confirmation (assert/expect)
src/main/java/de/tum/in/www1/artemis/service/AttachmentUnitService.java 100%
src/main/java/de/tum/in/www1/artemis/service/FileService.java 87.2%
src/main/java/de/tum/in/www1/artemis/service/LectureUnitProcessingService.java 91.5%
src/main/java/de/tum/in/www1/artemis/service/LectureUnitService.java 85.7%
src/main/java/de/tum/in/www1/artemis/service/SlideSplitterService.java 85.4%
src/main/java/de/tum/in/www1/artemis/web/rest/AttachmentResource.java 98.3%

The sections I touched are covered well. FileService coverage technically even increased.

Summary by CodeRabbit

  • New Features
    • Enhanced file handling for Attachments, Courses, and Slides.
    • Improved fetching of lecture units with competencies and slides.
  • Refactor
    • Streamlined file path generation and saving logic.
    • Removed redundant file management imports and methods.
  • Tests
    • Updated tests to align with the enhanced file handling processes.

@julian-christl julian-christl self-assigned this Jan 20, 2024
Copy link

coderabbitai bot commented Jan 20, 2024

Walkthrough

The modifications across various files in the Artemis project predominantly focus on refining file handling and management. Key changes include the removal of specific file management methods and services, adjustments in repository interfaces to enhance data retrieval, and updates in service classes to improve file processing and saving mechanisms. These alterations aim to streamline file-related operations, ensuring more efficient handling of attachments, lecture materials, and course icons, while also optimizing the interaction with the underlying file system.

Changes

File(s) Change Summary
.../domain/Attachment.java, .../domain/Course.java, .../domain/lecture/Slide.java Removed file management methods, services, and related fields.
.../repository/LectureUnitRepository.java, .../repository/LectureRepository.java Updated to include new methods for fetching lecture units with competencies, slides, and attachments.
.../service/AttachmentUnitService.java, .../service/CompetencyProgressService.java,
.../service/EntityFileService.java, .../service/FileService.java,
.../service/LectureUnitProcessingService.java, .../service/LectureUnitService.java,
.../service/QuizExerciseService.java, .../service/SlideSplitterService.java
Introduced new imports, updated method logic for file handling, and modified method calls to accommodate changes in file management.
.../web/rest/AttachmentResource.java, .../web/rest/CourseResource.java,
.../web/rest/admin/AdminCourseResource.java, .../web/rest/LectureResource.java
Adjusted file handling in REST endpoints, including file creation, update, and deletion logic.
.../test/... (Various test classes) Updated test logic to reflect changes in file handling and attachment management.

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>.
    • Generate unit-tests 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 tests 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@github-actions github-actions bot added the server Pull requests that update Java code. (Added Automatically!) label Jan 20, 2024
@github-actions github-actions bot added the tests label Jan 20, 2024
@julian-christl julian-christl changed the title Chore/simplify attachment save Development: Handle lecture files persistency directly Jan 20, 2024
Base automatically changed from chore/simplify-course-icon-save to develop January 21, 2024 08:47
@julian-christl julian-christl marked this pull request as ready for review January 27, 2024 22:39
@julian-christl julian-christl requested a review from a team as a code owner January 27, 2024 22:39
Copy link

github-actions bot commented Mar 6, 2024

⚠️ Unable to deploy to test servers ⚠️

Testserver "artemis-test2.artemis.cit.tum.de" is already in use by PR #8139.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Mar 6, 2024
@coolchock coolchock added deploy:artemis-test2 and removed deployment-error Added by deployment workflows if an error occured labels Mar 6, 2024
Copy link

github-actions bot commented Mar 6, 2024

⚠️ Unable to deploy to test servers ⚠️

Testserver "artemis-test2.artemis.cit.tum.de" is already in use by PR #8139.

@github-actions github-actions bot added the deployment-error Added by deployment workflows if an error occured label Mar 6, 2024
@coolchock coolchock added deploy:artemis-test2 and removed deployment-error Added by deployment workflows if an error occured labels Mar 6, 2024
@coolchock coolchock temporarily deployed to artemis-test2.artemis.cit.tum.de March 6, 2024 23:24 — with GitHub Actions Inactive
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.

tested on ts2, LGTM

Copy link
Contributor

@rstief rstief left a comment

Choose a reason for hiding this comment

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

Code looks good 👍

Copy link
Contributor

@Strohgelaender Strohgelaender left a comment

Choose a reason for hiding this comment

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

code

@MaximilianAnzinger MaximilianAnzinger added the maintainer-approved The feature maintainer has approved the PR label Mar 8, 2024
@julian-christl julian-christl added this to the 6.9.1 milestone Mar 8, 2024
@krusche krusche merged commit 6db0380 into develop Mar 8, 2024
111 of 119 checks passed
@krusche krusche deleted the chore/simplify-attachment-save branch March 8, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component:Lecture maintainer-approved The feature maintainer has approved the PR ready to merge server Pull requests that update Java code. (Added Automatically!) tests too-long-open !!! This is an antipattern, we should aim for small PRs that are only open for a short time !!!
Projects
None yet
Development

Successfully merging this pull request may close these issues.