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

Implement tagging #93

Merged
merged 3 commits into from
Feb 15, 2024
Merged

Implement tagging #93

merged 3 commits into from
Feb 15, 2024

Conversation

nylonee
Copy link
Owner

@nylonee nylonee commented Feb 15, 2024

This closes #41

Summary by CodeRabbit

  • New Features

    • Added support for SONARR_TAGS and RADARR_TAGS environment variables to customize media management.
    • Introduced tag ID configurations for Sonarr and Radarr, allowing for more precise control over media categorization.
  • Enhancements

    • Improved configuration handling to include tag IDs in Sonarr and Radarr setups.
    • Enhanced Radarr and Sonarr integration by allowing tags to be specified in API requests.
  • Refactor

    • Simplified code for handling POST requests with payloads.
  • Tests

    • Added tests for new tag ID functionality in Sonarr and Radarr configurations.

Copy link

coderabbitai bot commented Feb 15, 2024

Warning

Rate Limit Exceeded

@nylonee has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 6 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between 8610d28 and c3af376.

Walkthrough

The project now supports tagging for Sonarr and Radarr, enabling dynamic content management through tags. This feature allows users to specify SONARR_TAGS and RADARR_TAGS as environment variables, which are then incorporated into the system's configuration and utilized in API requests. The changes span across Docker setup, Scala configuration classes, utility functions, and test suites, ensuring tags are properly handled and integrated within the system's workflow.

Changes

Files Change Summary
docker/entrypoint.sh Added SONARR_TAGS and RADARR_TAGS handling.
src/main/scala/.../Configuration.scala Added tagIds field to SonarrConfiguration and RadarrConfiguration.
src/main/scala/.../ConfigurationRedactor.scala, ConfigurationUtils.scala Enhanced to include tag IDs in configurations.
src/main/scala/configuration/Keys.scala Added keys for tag handling.
src/main/scala/plex/PlexUtils.scala Removed unused import.
src/main/scala/.../RadarrPost.scala, src/main/scala/.../SonarrPost.scala Added tags field to case classes.
src/main/scala/.../RadarrUtils.scala, src/main/scala/.../SonarrUtils.scala Modified function signatures to include tags.
src/test/scala/... Updated tests to include tag ID handling.

"In the realm of code and binary,
A rabbit hopped, quite timely.
With tags in tow, it leapt through code,
A feature new, now bestowed.
🐇💻🌟
'Cross Sonarr and Radarr lands,
It spread its work with gentle hands."

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.
  • 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 from git 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.

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 07b6fcc and 8610d28.
Files ignored due to path filters (1)
  • src/test/resources/tag-response.json is excluded by: !**/*.json
Files selected for processing (12)
  • docker/entrypoint.sh (1 hunks)
  • src/main/scala/configuration/Configuration.scala (1 hunks)
  • src/main/scala/configuration/ConfigurationRedactor.scala (1 hunks)
  • src/main/scala/configuration/ConfigurationUtils.scala (7 hunks)
  • src/main/scala/configuration/Keys.scala (1 hunks)
  • src/main/scala/plex/PlexUtils.scala (1 hunks)
  • src/main/scala/radarr/RadarrPost.scala (1 hunks)
  • src/main/scala/radarr/RadarrUtils.scala (1 hunks)
  • src/main/scala/sonarr/SonarrPost.scala (1 hunks)
  • src/main/scala/sonarr/SonarrUtils.scala (1 hunks)
  • src/test/scala/PlexTokenSyncSpec.scala (1 hunks)
  • src/test/scala/configuration/ConfigurationUtilsSpec.scala (4 hunks)
Files skipped from review due to trivial changes (1)
  • src/main/scala/plex/PlexUtils.scala
Additional comments: 18
src/main/scala/radarr/RadarrPost.scala (1)
  • 3-10: Changes to RadarrPost correctly introduce the tags field with appropriate default value and type.
src/main/scala/sonarr/SonarrPost.scala (1)
  • 10-11: Changes to SonarrPost correctly introduce the tags field with appropriate default value and type.
src/main/scala/configuration/Keys.scala (2)
  • 12-12: Addition of sonarrTags key is correctly implemented.
  • 19-19: Addition of radarrTags key is correctly implemented.
src/main/scala/configuration/ConfigurationRedactor.scala (2)
  • 16-16: Inclusion of sonarrTagIds in the configuration output is correctly implemented.
  • 24-24: Inclusion of radarrTagIds in the configuration output is correctly implemented.
src/main/scala/configuration/Configuration.scala (2)
  • 22-23: Addition of sonarrTagIds field to SonarrConfiguration is correctly implemented.
  • 31-32: Addition of radarrTagIds field to RadarrConfiguration is correctly implemented.
docker/entrypoint.sh (1)
  • 86-92: Conditional inclusion of SONARR_TAGS and RADARR_TAGS environment variables in the command array is correctly implemented.
src/main/scala/radarr/RadarrUtils.scala (1)
  • 30-30: Modification to addToRadarr function to include tags parameter in RadarrPost instantiation is correctly implemented.
src/main/scala/sonarr/SonarrUtils.scala (1)
  • 38-38: Modification to include tags parameter in SonarrPost instantiation is correctly implemented.
src/test/scala/PlexTokenSyncSpec.scala (2)
  • 44-45: Addition of sonarrTagIds to the test configuration for Sonarr is correctly implemented.
  • 52-53: Addition of radarrTagIds to the test configuration for Radarr is correctly implemented.
src/main/scala/configuration/ConfigurationUtils.scala (5)
  • 24-28: Modifications to create function to include sonarrTagIds and radarrTagIds in configurations are correctly implemented.
  • 82-104: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [76-112]

Changes to getSonarrConfig to handle sonarrTagIds are correctly implemented.

  • 115-141: Changes to getRadarrConfig to handle radarrTagIds are correctly implemented.
  • 144-159: Implementation of getTagIdsFromConfig to fetch tag information is correctly implemented.
  • 261-267: Refactoring of toArr to handle POST requests with payloads is correctly implemented.

Comment on lines +154 to +163
it should "fetch a tag from Sonarr/Radarr" in {

val mockConfigReader = createMockConfigReader(tags = Some("test-tag"))
val mockHttpClient = createMockHttpClient()

val config = ConfigurationUtils.create(mockConfigReader, mockHttpClient).unsafeRunSync()
noException should be thrownBy config
config.sonarrConfiguration.sonarrTagIds shouldBe Set(3)
config.radarrConfiguration.radarrTagIds shouldBe Set(3)
}
Copy link

Choose a reason for hiding this comment

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

The test case "fetch a tag from Sonarr/Radarr" lacks assertions to verify the HTTP request details, such as the request path, method, and body. Adding these assertions would ensure that the correct API endpoints are called with the expected parameters.

Consider adding assertions to verify the HTTP request details to ensure the correctness of the API calls.

Comment on lines +249 to +260
(mockHttpClient.httpRequest _).expects(
Method.POST,
Uri.unsafeFromString("http://localhost:8989").withPath(Uri.Path.unsafeFromString("/api/v3/tag")),
Some("sonarr-api-key"),
*
).returning(IO.pure(parse(Source.fromResource("tag-response.json").getLines().mkString("\n")))).anyNumberOfTimes()
(mockHttpClient.httpRequest _).expects(
Method.POST,
Uri.unsafeFromString("http://localhost:7878").withPath(Uri.Path.unsafeFromString("/api/v3/tag")),
Some("radarr-api-key"),
*
).returning(IO.pure(parse(Source.fromResource("tag-response.json").getLines().mkString("\n")))).anyNumberOfTimes()
Copy link

Choose a reason for hiding this comment

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

The wildcard matcher * used in the httpRequest mock setup for POST requests to Sonarr and Radarr tag APIs does not validate the request body. This could lead to false positives in tests if the request body format changes.

Replace the wildcard matcher with a specific matcher that validates the structure and content of the request body.

@nylonee nylonee merged commit 39d4947 into main Feb 15, 2024
2 checks passed
@nylonee nylonee deleted the implement-tagging branch February 15, 2024 14:14
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.

Add ability to add tags to requests
1 participant