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

Deprecated api remove #196

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

troshab
Copy link

@troshab troshab commented Dec 8, 2024

Description

I've updated work with *arr to non deprecated api

Checklist

  • Documentation Updated
  • sbt scalafmtAll Run (and optionally sbt scalafmtSbt)
  • At least one approval from a codeowner

Summary by CodeRabbit

  • New Features

    • Enhanced flexibility in fetching movie and series exclusions with the addition of dynamic query parameters.
    • Updated endpoints for fetching exclusions to improve data retrieval.
  • Bug Fixes

    • Improved error messaging for response decoding to provide clearer context.
  • Documentation

    • Updated method signatures to reflect the inclusion of query parameters in relevant functions.

remove deprecated
update deprecated api
Copy link

coderabbitai bot commented Dec 8, 2024

Walkthrough

The changes involve modifications to the RadarrUtils and SonarrUtils traits, specifically enhancing the getToArr method to accept an additional parameter for query parameters. In RadarrUtils, the fetchMovies method now calls getToArr with a specific endpoint and query parameters for fetching exclusions. Similarly, in SonarrUtils, the fetchSeries method has updated its endpoint for exclusions and also passes query parameters. The internal logic of getToArr in both traits has been adjusted to construct URLs dynamically based on these parameters.

Changes

File Path Change Summary
src/main/scala/radarr/RadarrUtils.scala Updated getToArr method to include a params parameter. Modified fetchMovies to use getToArr with a specific endpoint and query parameters.
src/main/scala/sonarr/SonarrUtils.scala Updated getToArr method to include a params parameter. Modified fetchSeries to use a new endpoint with query parameters. Updated error message in getToArr.

Poem

In the code where rabbits play,
New paths for queries come to stay.
With endpoints bright and params clear,
Fetching data brings us cheer!
Hops of joy in every line,
In the world of code, we shine! 🐇✨


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

@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

🧹 Outside diff range and nitpick comments (1)
src/main/scala/sonarr/SonarrUtils.scala (1)

85-88: Consider extracting common URL construction logic

The URL construction logic is identical between RadarrUtils and SonarrUtils. Consider extracting this into a shared utility trait to promote DRY principles.

trait ArrBaseUtils {
  protected def buildUrlWithParams(baseUrl: Uri, endpoint: String, params: Map[String, Any]): Uri =
    params.foldLeft(baseUrl / "api" / "v3" / endpoint) {
      case (url, (key, value)) => url.withQueryParam(key, value.toString)
    }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between dc9ef85 and 06b098b.

📒 Files selected for processing (2)
  • src/main/scala/radarr/RadarrUtils.scala (2 hunks)
  • src/main/scala/sonarr/SonarrUtils.scala (2 hunks)
🔇 Additional comments (4)
src/main/scala/radarr/RadarrUtils.scala (3)

68-73: Clean implementation of dynamic query parameters

The implementation is well-structured and type-safe. Good use of foldLeft for building the URL with query parameters.


75-79: LGTM: Error handling remains robust

The response handling and decoding logic maintains proper error handling while accommodating the new URL construction.


28-28: Verify pagination behavior with pageSize=-1

While using pageSize=-1 to fetch all records in one request is convenient, it could impact performance with large datasets. Verify that:

  1. The new API endpoint supports this usage
  2. There are no memory constraints when dealing with large exclusion lists
✅ Verification successful

Let's examine the actual usage of pageSize=-1 in both files to understand the pattern better.


Let's check if there are any other pagination patterns or pageSize usages in the codebase to understand if this is a consistent approach.


Let's check the implementation of getToArr to understand how it handles the response and if there are any safeguards for large datasets.


Let's try to find the getToArr implementation using ripgrep instead.


Based on the complete context gathered, I can now generate the final response:

Using pageSize=-1 with paged endpoints appears to be a consistent pattern

The codebase shows this is an established pattern used consistently in both Radarr and Sonarr implementations:

  • Both services use identical pagination approach for their exclusion endpoints
  • The getToArr implementation handles responses safely using EitherT for error handling
  • The response is processed lazily through IO monad, which helps manage memory efficiently
  • This pattern aligns with the API's v3 specification for both services
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other instances of pageSize=-1 to understand if this is a common pattern
rg -l "pageSize.*-1"

Length of output: 102


Script:

#!/bin/bash
# Show the context of pageSize=-1 usage in both files
rg "pageSize.*-1" -B 2 -A 2

Length of output: 986


Script:

#!/bin/bash
# Search for other pagination patterns and pageSize usage
rg "pageSize.*\d+" -B 2 -A 2
# Also check for any paged endpoint usage
rg "/paged" -B 2 -A 2

Length of output: 1966


Script:

#!/bin/bash
# Search for getToArr implementation
ast-grep --pattern 'def getToArr'

Length of output: 35


Script:

#!/bin/bash
# Search for getToArr implementation using ripgrep with context
rg "getToArr" -B 3 -A 10

Length of output: 5627

src/main/scala/sonarr/SonarrUtils.scala (1)

27-27: Consistent with RadarrUtils implementation

The change to use the paginated endpoint with pageSize=-1 mirrors the RadarrUtils implementation. Consider the same performance considerations mentioned in RadarrUtils.

misscopypasted

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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: 1

🧹 Outside diff range and nitpick comments (1)
src/main/scala/sonarr/SonarrUtils.scala (1)

85-88: Add type safety for query parameter values

The current implementation calls toString on any value type, which could produce unexpected results for complex types. Consider adding type constraints or validation for parameter values.

-  )(baseUrl: Uri, apiKey: String, endpoint: String, params: Map[String, Any] = Map.empty): EitherT[IO, Throwable, T] = {
+  )(baseUrl: Uri, apiKey: String, endpoint: String, params: Map[String, String] = Map.empty): EitherT[IO, Throwable, T] = {
   val urlWithParams = params.foldLeft(baseUrl / "api" / "v3" / endpoint) {
-    case (url, (key, value)) => url.withQueryParam(key, value.toString)
+    case (url, (key, value)) => url.withQueryParam(key, value)
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 06b098b and a7ee8b4.

📒 Files selected for processing (1)
  • src/main/scala/sonarr/SonarrUtils.scala (2 hunks)
🔇 Additional comments (2)
src/main/scala/sonarr/SonarrUtils.scala (2)

85-94: LGTM! Clean and functional implementation

The updated getToArr method implementation with dynamic query parameter support is well-structured and maintains good functional programming practices.


27-27: Consider pagination handling for large datasets

While using pageSize=-1 fetches all exclusions in one request, this approach might cause performance issues or timeouts with large datasets. Consider implementing proper pagination handling.

Let's check if there are any timeout configurations or similar patterns in the codebase:

@@ -24,7 +24,7 @@ trait SonarrUtils extends SonarrConversions {
if (bypass) {
EitherT.pure[IO, Throwable](List.empty[SonarrSeries])
} else {
getToArr[List[SonarrSeries]](client)(baseUrl, apiKey, "importlistexclusion")
getToArr[List[SonarrSeries]](client)(baseUrl, apiKey, "importlistexclusion/paged", Map("pageSize" -> "-1"))
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the test specifications and usage patterns, I can now generate the final response:

API endpoint change appears to be inconsistent

The code changes the endpoint from importlistexclusion to importlistexclusion/paged, but the test specifications consistently use /api/v3/importlistexclusion without the /paged suffix. This inconsistency suggests the change might not be compatible with the API specification.

  • src/test/scala/sonarr/SonarrUtilsSpec.scala uses /api/v3/importlistexclusion
  • src/test/scala/PlexTokenSyncSpec.scala uses /api/v3/importlistexclusion
  • The test data in importlistexclusion.json is structured for the non-paged endpoint
🔗 Analysis chain

Verify API endpoint compatibility

Please ensure that the new importlistexclusion/paged endpoint is part of the official Sonarr API v3 specification.


Let me gather more information about the API endpoint by checking the test data and any documentation files.


Let me check the test specifications to understand how the API endpoint is being used in tests.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any other occurrences of the old or new endpoint
rg -i "importlistexclusion" 

Length of output: 941


Script:

#!/bin/bash
# Check the test JSON file to understand the API structure
cat src/test/resources/importlistexclusion.json

# Look for any API documentation files
fd -e md -e txt -e yaml -e json . | grep -i "api\|swagger\|openapi" || true

Length of output: 197


Script:

#!/bin/bash
# Check the test specifications for API endpoint usage
cat src/test/scala/sonarr/SonarrUtilsSpec.scala
cat src/test/scala/PlexTokenSyncSpec.scala

Length of output: 12144

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.

1 participant