Granular ws
I realised that we send the entire websocket payload every second this PR makes it that we only ever send the things that change
this makes the app transmit around 8x less data. more importantly, it would allow the consumer to do less work on updating regardless, the amount of data transmitted is very low (around 200b for a full packet) and it is arguable whether it is worth it
Walkthrough
The update to TimerService.ts introduces a more nuanced handling of the onAir and timer properties based on playback state and timing conditions. This change ensures that the onAir status is only modified when necessary, enhancing the responsiveness and accuracy of state management in the application's event system.
Changes
| File | Change Summary |
|---|---|
.../TimerService.ts |
Added a conditional check for hasChangedPlayback to selectively update onAir. Modified the updating process for timer to be more condition-specific, optimizing state management. |
Recent Review Details
Configuration used: CodeRabbit UI
Commits
Files that changed from the base of the PR and between 7448c70533997a1e6a0363ea6a99565ad5c87222 and 51f71a6c23043510645fc66093bbe371be9314fb.Files selected for processing (1)
- apps/server/src/services/TimerService.ts (1 hunks)
Additional comments not posted (2)
apps/server/src/services/TimerService.ts (2)
154-156: Ensure that the comparison logic forhasChangedPlaybackcorrectly reflects the intended conditions for updating theonAirproperty. This is crucial for the effectiveness of the data optimization strategy.#!/bin/bash # Verify that the playback state comparison is correctly implemented across the application. ast-grep --lang typescript --pattern $'TimerService.previousState.timer?.playback !== $_.timer.playback'
159-159: Consider optimizing the condition for updating thetimerproperty by ensuring thatdeepEqualis only called when necessary. This can help reduce computational overhead.
[!WARNING]
Following problems were encountered
- Git: Failed to clone repository. Please contact CodeRabbit support.
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?
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
@coderabbitaiin 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
@coderabbitaiin 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.
-
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 pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger a review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai helpto 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.yamlfile 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.
cool! we could also add in the event change list to the re-fetch message or do it as a separate PR
Ontime does not benefit from that change, so lets do it later when the companion module is ready