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

Add an option to get 48h of live data history #269

Merged
merged 2 commits into from
Jul 15, 2024
Merged

Add an option to get 48h of live data history #269

merged 2 commits into from
Jul 15, 2024

Conversation

vicb
Copy link
Owner

@vicb vicb commented Jul 15, 2024

Summary by Sourcery

This pull request adds support for retrieving 48 hours of live data history, refactors live data retention and interval constants into enums, and updates the logic for handling live track data to support multiple retention periods. Additionally, the privacy policy has been updated to reflect the new data retention period.

  • New Features:
    • Introduced an option to retrieve 48 hours of live data history.
  • Enhancements:
    • Refactored live data retention and interval constants into enums for better readability and maintainability.
    • Updated the logic for handling live track data to support multiple retention periods (12h, 24h, 48h).
    • Improved the process of adding and simplifying live tracks by introducing the maybePushTrack function.
  • Documentation:
    • Updated the privacy policy to reflect the new 48-hour data retention period.

Summary by CodeRabbit

  • New Features

    • Added option for displaying live track positions for up to 48 hours.
    • Updated Supporter Modal information to reflect current hosting costs.
  • Bug Fixes

    • Enhanced error handling and logging across various modules.
  • Refactor

    • Replaced old interval and retention constants with unified LiveDataIntervalSec and LiveDataRetentionSec enums.
    • Restructured data processing and track handling logic for better performance.
    • Refactored getTrackerRouter function to handle token-based requests more efficiently.
  • Documentation

    • Updated privacy policy to reflect changes in live track position display duration.

Copy link
Contributor

sourcery-ai bot commented Jul 15, 2024

Reviewer's Guide by Sourcery

This pull request introduces support for fetching and displaying 48-hour live data history. The changes include refactoring the fetcher logic to handle different time ranges, updating API endpoints, and modifying frontend components to support the new data retention periods. Additionally, enums for data retention and interval constants were introduced for better maintainability.

File-Level Changes

Files Changes
apps/fetcher/src/fetcher.ts
apps/fetcher/src/app/trackers/refresh.ts
apps/fetcher/src/app/ufos/refresh.ts
Refactored fetcher logic to support 12h, 24h, and 48h data retention, including new helper functions and updated pipeline commands.
libs/common/src/lib/live-track.ts
libs/common/src/lib/redis-keys.ts
Introduced enums for data retention and interval constants, and updated Redis keys to reflect new data retention periods.
apps/fxc-server/src/app/routes/live-track.ts
apps/fxc-front/src/app/redux/live-track-slice.ts
apps/fxc-front/src/app/components/ui/main-menu.ts
Updated API and frontend logic to support fetching and displaying 48-hour live data history.
apps/fetcher/src/app/trackers/inreach.ts
apps/fetcher/src/app/trackers/skylines.ts
apps/fetcher/src/app/trackers/flymaster.ts
apps/fetcher/src/app/trackers/spot.ts
Replaced old interval constants with new LiveDataIntervalSec enum for consistency.
apps/fxc-front/src/app/pages/admin.ts
apps/fxc-server/src/app/routes/admin.ts
Updated admin pages to use new keys for full and incremental track counts.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

coderabbitai bot commented Jul 15, 2024

Walkthrough

The updates introduce changes across multiple files, primarily involving renaming constants and restructuring code for better clarity and organization. Key constants related to time intervals and retention periods in live tracking have been refactored into enums, and function parameters have been updated accordingly. These modifications also improve error handling, logging mechanisms, and streamline the overall logic in the fetching and processing of live tracker data.

Changes

Files Change Summary
.../flymaster.ts, .../inreach.ts, .../skylines.ts, .../spot.ts, .../tracker.ts, .../xcontest.ts, .../refresh.ts, .../live-track.ts Replaced the constant LIVE_MINIMAL_INTERVAL_SEC with LiveDataIntervalSec.Recent in simplifyLiveTrack function calls.
.../refresh.ts, .../ufos/refresh.ts Renamed variables related to live data intervals and retention periods, updated assignments, and adjusted function calls.
.../fetcher.ts Removed references to old constants, introduced LiveDataRetentionSec, reorganized track processing logic, and added a new function maybePushTrack.
.../main-menu.ts, .../supporter-modal.ts Added a new <ion-select> option for 48 hours, and updated the hosting cost text.
.../admin.ts, .../privacy-policy.ts Updated keys and renamed constants related to track display durations.
.../live-track-slice.ts Updated updateTrackers function to include fetchMin calculation and use it in the fetch URL.
.../redis-keys.ts Reorganized live track keys in Redis and updated naming conventions for clarity.
.../live-track.ts Reorganized constants to enums for better clarity in defining data retention and intervals.

Poem

In the code where data flows,
Constants shift, and clarity grows,
For live tracks new enums rise,
Simplified in coder’s eyes.

Forty-eight hours now we see,
Improved the flow, refined with glee.
🐇✨🚀


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

Deploying flyxc with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3cecaba
Status: ✅  Deploy successful!
Preview URL: https://4a138e5c.flyxc.pages.dev
Branch Preview URL: https://h48.flyxc.pages.dev

View logs

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @vicb - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Incorrect key assignment (link)
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue, 10 other issues
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

apps/fetcher/src/fetcher.ts Show resolved Hide resolved
apps/fetcher/src/fetcher.ts Show resolved Hide resolved
apps/fetcher/src/app/trackers/refresh.ts Show resolved Hide resolved
apps/fetcher/src/app/trackers/refresh.ts Show resolved Hide resolved
apps/fxc-server/src/app/routes/live-track.ts Outdated Show resolved Hide resolved
apps/fetcher/src/app/trackers/inreach.ts Show resolved Hide resolved
apps/fetcher/src/app/trackers/skylines.ts Show resolved Hide resolved
apps/fetcher/src/app/trackers/spot.ts Show resolved Hide resolved
apps/fetcher/src/fetcher.ts Show resolved Hide resolved
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, codebase verification and nitpick comments (1)
apps/fetcher/src/app/trackers/refresh.ts (1)

47-47: Fix the typo in the function name.

The function name resfreshTrackers has a typo. It should be refreshTrackers.

- export async function resfreshTrackers(
+ export async function refreshTrackers(
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fbb4c37 and 3cecaba.

Files selected for processing (20)
  • apps/fetcher/src/app/trackers/flymaster.ts (2 hunks)
  • apps/fetcher/src/app/trackers/inreach.ts (2 hunks)
  • apps/fetcher/src/app/trackers/refresh.ts (5 hunks)
  • apps/fetcher/src/app/trackers/skylines.ts (2 hunks)
  • apps/fetcher/src/app/trackers/spot.ts (2 hunks)
  • apps/fetcher/src/app/trackers/tracker.ts (2 hunks)
  • apps/fetcher/src/app/trackers/xcontest.ts (2 hunks)
  • apps/fetcher/src/app/ufos/refresh.ts (2 hunks)
  • apps/fetcher/src/fetcher.ts (3 hunks)
  • apps/fxc-front/src/app/components/ui/main-menu.ts (1 hunks)
  • apps/fxc-front/src/app/components/ui/supporter-modal.ts (1 hunks)
  • apps/fxc-front/src/app/logic/live-track.ts (2 hunks)
  • apps/fxc-front/src/app/pages/admin.ts (2 hunks)
  • apps/fxc-front/src/app/pages/privacy-policy.ts (1 hunks)
  • apps/fxc-front/src/app/redux/live-track-slice.ts (1 hunks)
  • apps/fxc-front/src/app/workers/live-track.ts (2 hunks)
  • apps/fxc-server/src/app/routes/admin.ts (1 hunks)
  • apps/fxc-server/src/app/routes/live-track.ts (3 hunks)
  • libs/common/src/lib/live-track.ts (2 hunks)
  • libs/common/src/lib/redis-keys.ts (1 hunks)
Files skipped from review due to trivial changes (4)
  • apps/fetcher/src/app/trackers/spot.ts
  • apps/fxc-front/src/app/components/ui/supporter-modal.ts
  • apps/fxc-front/src/app/logic/live-track.ts
  • apps/fxc-front/src/app/workers/live-track.ts
Additional comments not posted (31)
apps/fetcher/src/app/ufos/refresh.ts (3)

5-6: LGTM!

The introduction of LiveDataIntervalSec and LiveDataRetentionSec enums aligns with the PR objectives of refactoring constants to enums.


35-35: LGTM!

The use of LiveDataRetentionSec.Ufo for calculating ufoStartSec is consistent with the PR objectives.


51-51: LGTM!

The use of LiveDataIntervalSec.Recent in the simplifyLiveTrack function is consistent with the PR objectives.

apps/fetcher/src/app/trackers/flymaster.ts (1)

82-82: LGTM!

The use of LiveDataIntervalSec.Recent in the simplifyLiveTrack function is consistent with the PR objectives.

libs/common/src/lib/redis-keys.ts (3)

56-58: LGTM!

The introduction of new keys fetcherFullProtoH12, fetcherFullProtoH24, and fetcherFullProtoH48 is consistent with the PR objectives.


60-62: LGTM!

The introduction of new keys fetcherFullNumTracksH12, fetcherFullNumTracksH24, and fetcherFullNumTracksH48 is consistent with the PR objectives.


68-68: LGTM!

The introduction of the key fetcherIncrementalNumTracksLong is consistent with the PR objectives.

apps/fetcher/src/app/trackers/skylines.ts (1)

64-64: LGTM!

The use of LiveDataIntervalSec.Recent in the simplifyLiveTrack function is consistent with the PR objectives.

apps/fetcher/src/app/trackers/xcontest.ts (1)

10-10: LGTM!

The change to use TRACKERS_MAX_FETCH_DURATION_SEC improves code clarity and organization.

Also applies to: 44-44

apps/fxc-front/src/app/redux/live-track-slice.ts (1)

102-103: LGTM!

The change to calculate fetchMin based on state.historyMin ensures correct fetch intervals.

apps/fetcher/src/app/trackers/refresh.ts (4)

5-6: LGTM!

The changes to use LiveDataIntervalSec and LiveDataRetentionSec improve code clarity and organization.


65-65: LGTM!

The change to use fetchResults improves code readability.


81-81: LGTM!

The change to use dropBeforeSec improves code readability.


89-110: LGTM!

The changes to use LiveDataIntervalSec for simplifying tracks based on their age improve code clarity and organization.

apps/fetcher/src/app/trackers/tracker.ts (1)

4-4: LGTM!

The change to use TRACKERS_MAX_FETCH_DURATION_SEC improves code clarity and organization.

Also applies to: 126-126

apps/fxc-server/src/app/routes/live-track.ts (3)

3-3: Import statement updated to include new enums.

The import statement now includes LiveDataRetentionSec and LiveDataIntervalSec.


47-71: Updated logic to use new enums for retention intervals.

The logic has been updated to use LiveDataRetentionSec.IncrementalShort and LiveDataRetentionSec.IncrementalLong instead of hardcoded values. This improves readability and maintainability.


63-69: Added support for 48-hour data retention.

The switch statement now includes a case for 48-hour data retention using Keys.fetcherFullNumTracksH48.

apps/fxc-server/src/app/routes/admin.ts (1)

147-148: Updated keys for data retention intervals.

The keys have been updated to Keys.fetcherFullNumTracksH24 and Keys.fetcherIncrementalNumTracksLong. This aligns with the new retention intervals.

apps/fxc-front/src/app/pages/privacy-policy.ts (1)

75-76: Updated display duration of tracker positions.

The display duration of tracker positions has been extended from 24 to 48 hours. Ensure this change is communicated to users.

apps/fetcher/src/app/trackers/inreach.ts (2)

12-12: Import statement updated to include new enum.

The import statement now includes LiveDataIntervalSec.


94-95: Updated to use new enum for data interval.

The simplifyLiveTrack function now uses LiveDataIntervalSec.Recent. This improves readability and maintainability.

apps/fetcher/src/fetcher.ts (3)

7-7: Import statement approved.

The addition of LiveDataRetentionSec is consistent with the changes described in the context.


254-266: New function maybePushTrack approved.

The function appears to be correctly implemented to conditionally add a live track to a track group after removing outdated points.


164-220: Changes to updateAll function approved.

The changes are consistent with the introduction of new enums for live data retention. The logic for adding pilots and UFOs to the new track groups appears correct.

However, ensure that all function calls to updateAll are consistent with the new logic.

libs/common/src/lib/live-track.ts (3)

12-25: New enum LiveDataRetentionSec approved.

The enum is well-defined and aligns with the changes described in the context.


28-33: New enum LiveDataIntervalSec approved.

The enum is well-defined and aligns with the changes described in the context.


35-35: New constant TRACKERS_MAX_FETCH_DURATION_SEC approved.

The constant is well-defined and aligns with the changes described in the context.

apps/fxc-front/src/app/components/ui/main-menu.ts (1)

726-729: New 48-hour option in <ion-select> approved.

The addition of the 48-hour option is consistent with the changes described in the context.

apps/fxc-front/src/app/pages/admin.ts (2)

181-181: Key change in dash-summary component approved.

The change is consistent with the renaming of keys described in the context.


201-201: Key change in dash-summary component approved.

The change is consistent with the renaming of keys described in the context.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3cecaba and 7a6e093.

Files selected for processing (1)
  • apps/fxc-server/src/app/routes/live-track.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/fxc-server/src/app/routes/live-track.ts

@vicb vicb merged commit ebf1c37 into master Jul 15, 2024
4 checks passed
@vicb vicb deleted the h48 branch July 15, 2024 16:22
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