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

Export to csv #1941

Merged
merged 4 commits into from
Nov 10, 2024
Merged

Export to csv #1941

merged 4 commits into from
Nov 10, 2024

Conversation

jo-elimu
Copy link
Member

Issue Number

Purpose

  • Ensure CSVs are up-to-date with the latest code changes.

Technical Details

Testing Instructions

Screenshots


Format Checks

Note

Files in PRs are automatically checked for format violations with mvn spotless:check.

If this PR contains files with format violations, run mvn spotless:apply to fix them.

@jo-elimu jo-elimu self-assigned this Nov 10, 2024
@jo-elimu jo-elimu requested a review from a team as a code owner November 10, 2024 03:57
Copy link

codecov bot commented Nov 10, 2024

Codecov Report

Attention: Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.

Project coverage is 15.97%. Comparing base (feb8e1b) to head (4078d1f).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
.../content/multimedia/image/ImageEditController.java 0.00% 17 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1941      +/-   ##
============================================
- Coverage     15.99%   15.97%   -0.03%     
  Complexity      482      482              
============================================
  Files           257      257              
  Lines          7838     7852      +14     
  Branches        807      808       +1     
============================================
  Hits           1254     1254              
- Misses         6534     6548      +14     
  Partials         50       50              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

coderabbitai bot commented Nov 10, 2024

Walkthrough

The changes in the ImageEditController, Image, and JpaToGsonConverter classes enhance the image editing functionality by adding session management, refining error handling, and modifying how image data is stored and serialized. The ImageEditController now includes session attributes and improved logging for image contributions. The Image class marks the bytes field as deprecated and introduces lazy loading for better performance. Lastly, the JpaToGsonConverter class alters the serialization logic by excluding the image byte size from the ImageGson object.

Changes

File Path Change Summary
src/main/java/ai/elimu/web/content/multimedia/image/ImageEditController.java - Added HttpSession session parameter to handleRequest and handleSubmit methods.
- Updated logic for pinning files to IPFS to include timing metrics and create ImageContributionEvent.
- Altered URL construction for Discord messaging to use HTTP.
- Refined error handling in handleSubmit for image title and file type validation.
- Updated handleAddContentLabelRequest and handleRemoveContentLabelRequest to increment revision number for content label changes.
src/main/java/ai/elimu/model/content/multimedia/Image.java - Marked bytes field and its getter/setter methods as @Deprecated.
- Annotated bytes field with @Basic(fetch = FetchType.LAZY).
src/main/java/ai/elimu/rest/v2/JpaToGsonConverter.java - Commented out the line that sets the bytesSize property in the getImageGson method.

Assessment against linked issues

Objective Addressed Explanation
Move storage of images from database to IPFS (#1933)
Add CID to REST API (#1933)
Add functionality for adding CID to pre-existing images (#1933)
Handle scenario where Pinata API key/secret is missing (#1933) It is unclear if this scenario is addressed.
Add CID to CSV export & import (#1933) This functionality has not been implemented.

Possibly related PRs

  • Add CID to CSV export #1938: The changes in the ImageEditController class regarding the handling of image data and the introduction of the cid field are directly related to the modifications made in the ImageCsvExportController, which now includes the cid in the CSV export functionality.

Suggested reviewers

  • eymaal
  • Souvik-Cyclic
  • nya-elimu

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 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
Contributor

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between feb8e1b and 31ccc76.

⛔ Files ignored due to path filters (3)
  • src/main/resources/db/content_PROD/eng/images.csv is excluded by !**/*.csv, !**/*.csv
  • src/main/resources/db/content_PROD/hin/images.csv is excluded by !**/*.csv, !**/*.csv
  • src/main/resources/db/content_PROD/tgl/images.csv is excluded by !**/*.csv, !**/*.csv
📒 Files selected for processing (1)
  • src/main/java/ai/elimu/web/content/multimedia/image/ImageEditController.java (3 hunks)
🔇 Additional comments (1)
src/main/java/ai/elimu/web/content/multimedia/image/ImageEditController.java (1)

84-84: Addition of HttpSession parameter is appropriate.

The inclusion of HttpSession session in the method signature enables access to session attributes and is necessary for the new functionality.

nya-elimu
nya-elimu previously approved these changes Nov 10, 2024
To reduce memory consumption, do not call `image.getBytes()`

#1933
Copy link
Contributor

@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

📥 Commits

Reviewing files that changed from the base of the PR and between 31ccc76 and 4078d1f.

📒 Files selected for processing (2)
  • src/main/java/ai/elimu/model/content/multimedia/Image.java (3 hunks)
  • src/main/java/ai/elimu/rest/v2/JpaToGsonConverter.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/ai/elimu/rest/v2/JpaToGsonConverter.java
🔇 Additional comments (3)
src/main/java/ai/elimu/model/content/multimedia/Image.java (3)

8-8: LGTM: Import added for lazy loading support

The FetchType import is correctly added to support the lazy loading configuration.


Line range hint 27-31: Consider strengthening CID field constraints post-migration

The CID field's comment indicates it's based on the file content's hash, but:

  1. It's not marked as @NotNull (currently commented out)
  2. There's no validation for CID format
  3. No clear indication of when it becomes mandatory

Consider adding:

  1. A validation annotation for CID format
  2. A migration timeline for making it @NotNull
  3. Documentation about the IPFS pinning status expectations

Let's check the current CID usage:

#!/bin/bash
# Check for CID validation or processing
rg "setCid|getCid|validateCid" --type java

# Look for IPFS/Pinata configuration
fd -e properties -e yaml -e yml | xargs rg "ipfs|pinata"

Line range hint 19-24: Consider relaxing @NotNull constraint during migration

While deprecating and lazy-loading the bytes field aligns with the migration to IPFS, keeping it as @NotNull might cause issues during the transition period. Consider:

  1. Making it nullable during migration
  2. Adding documentation about the migration timeline
  3. Implementing a migration strategy for existing records

Let's verify the current usage of this field:

@nya-elimu nya-elimu merged commit 9bb5379 into main Nov 10, 2024
11 of 14 checks passed
@nya-elimu nya-elimu deleted the 1933-export-to-csv branch November 10, 2024 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move storage of images from database to IPFS
2 participants