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

Run a full sync every 19 minutes #165

Merged
merged 3 commits into from
Jun 24, 2024
Merged

Run a full sync every 19 minutes #165

merged 3 commits into from
Jun 24, 2024

Conversation

nylonee
Copy link
Owner

@nylonee nylonee commented Jun 24, 2024

Description

Since Plex RSS feeds are really flaky, we run a full sync every 19 minutes so that users at least still get the benefits of Watchlistarr without needing to restart.

Checklist

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

Summary by CodeRabbit

  • Documentation

    • Updated the description of Plex Watchlist RSS Feeds to indicate the current issue of only showing the most recent 50 movies/shows.
  • Refactor

    • Renamed parameters and functions in code for better clarity and alignment with their purpose.
  • Tests

    • Updated test calls to reflect the new parameter names.

Copy link

coderabbitai bot commented Jun 24, 2024

Walkthrough

The changes update documentation for the Plex Watchlist RSS Feeds, which currently only displays the most recent 50 entries and is noted as broken. The run function in PlexTokenSync.scala renames the parameter firstRun to runFullSync for clarity. Modifications in Server.scala include renaming a function and adding a new one for full synchronization. Corresponding changes are reflected in the test file PlexTokenSyncSpec.scala.

Changes

File Change Summary
README.md Updated description of Plex Watchlist RSS Feeds to indicate it is currently broken.
src/main/scala/PlexTokenSync.scala Renamed run function parameter firstRun to runFullSync for improved clarity.
src/main/scala/Server.scala Updated import, renamed plexTokenSync function to plexRssSync, and added new plexFullSync method.
src/test/scala/PlexTokenSyncSpec.scala Modified run method call to use runFullSync instead of firstRun.

Poem

In fields of code where rabbits roam,
We tweak and fix, our bytes now home.
A sync renewed, full flow unfurled,
With runFullSync, we save the world. 🐇✨
From feed to test, improvements bloom,
A joyful dance in data's room.


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 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 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 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 as 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.

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

Outside diff range and nitpick comments (2)
README.md (2)

Line range hint 63-63: Missing language specification in fenced code block.

It's important for clarity and proper rendering on platforms like GitHub to specify the language for code blocks. This block should specify bash as it contains shell commands.

- ```
+ ```bash
Tools
LanguageTool

[style] ~19-~19: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ... | In order to fully integrate with Plex Watchlists, W...


Line range hint 69-69: Missing language specification in fenced code block.

Similar to the previous comment, specifying the language for code blocks enhances readability and proper syntax highlighting.

- ```
+ ```bash
Tools
LanguageTool

[style] ~19-~19: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ... | In order to fully integrate with Plex Watchlists, W...

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6cad865 and 916a5d2.

Files selected for processing (4)
  • README.md (1 hunks)
  • src/main/scala/PlexTokenSync.scala (1 hunks)
  • src/main/scala/Server.scala (3 hunks)
  • src/test/scala/PlexTokenSyncSpec.scala (1 hunks)
Additional context used
LanguageTool
README.md

[style] ~19-~19: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ... | In order to fully integrate with Plex Watchlists, W...

Markdownlint
README.md

44-44: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


63-63: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


69-69: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified

Additional comments not posted (7)
src/main/scala/Server.scala (4)

2-2: Updated import statement to support additional parallel operations.

The change from catsSyntaxTuple3Parallel to catsSyntaxTuple4Parallel reflects the addition of another parallel operation in the run method. This is a necessary change to accommodate the new plexFullSync function.


28-30: Addition of plexFullSync to the tuple of parallel operations.

The inclusion of plexFullSync in the parallel operations tuple ensures that the full synchronization process runs concurrently with the other sync processes. This is in line with the PR's objective to run a full sync every 19 minutes.


46-56: Refactoring and renaming of plexTokenSync to plexRssSync.

The function plexRssSync has been refactored from the previous plexTokenSync to focus on RSS-based synchronization. The logic within the function remains largely the same, now explicitly setting runFullSync to false for RSS syncs, which is a logical change given the context of the function's renaming and purpose.


57-65: Introduction of the plexFullSync function for full synchronization.

This function is a new addition and is crucial for achieving the PR's goal of performing a full sync every 19 minutes. It correctly sets runFullSync to true, ensuring that a full sync is performed, and recursively calls itself after a 19-minute interval, aligning with the PR's objectives.

src/main/scala/PlexTokenSync.scala (1)

16-34: Refactored run function to support conditional full synchronization.

The function now handles a runFullSync boolean to decide between fetching a complete self watchlist or returning an empty set, which is a significant change to support conditional logic based on full sync requirements. The detailed logging and conditional checks enhance the function's clarity and functionality, aligning with the PR's goals for more reliable synchronization.

README.md (1)

15-15: Updated documentation for Plex Watchlist RSS Feeds.

The documentation now correctly reflects that the Plex Watchlist RSS Feeds method is currently broken and only displays the most recent 50 movies/shows. This update is crucial for setting the right expectations for users.

src/test/scala/PlexTokenSyncSpec.scala (1)

26-26: Updated test case to reflect changes in PlexTokenSync.run.

The test case has been updated to use the runFullSync parameter, ensuring that the unit tests are aligned with the changes made in the main codebase. This is crucial for maintaining the reliability of the test suite.

for {
config <- fetchLatestConfig(configRef)
_ <- PlexTokenSync.run(config, httpClient, runFullSync = true)
_ <- IO.sleep(19.minutes)
Copy link
Owner Author

Choose a reason for hiding this comment

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

Forgot to add my reasoning for why 19 minutes specifically - it avoids accidental clustering (e.g. if a few servers in the world are set to restart at midnight every night, this gives enough randomness that they won't start hammering Plex every 20 mins)

@nylonee nylonee merged commit cbe01de into main Jun 24, 2024
1 check passed
@nylonee nylonee deleted the full-sync-every-19-mins branch June 24, 2024 19:29
@Dankni95
Copy link

Dankni95 commented Jul 1, 2024

@nylonee is the 19 min sync the case for plex premium users too?

The example in readme says instant, but i cant seem to make it work.

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.

2 participants