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

feat(disasters panel): 20511 Added config-based filters by last N days (updatedAt and startedAt fields) #942

Merged

Conversation

albaranau
Copy link
Contributor

@albaranau albaranau commented Dec 27, 2024

https://kontur.fibery.io/Tasks/Task/FE-Last-N-days-filter-for-startedAt-and-updatedAt-fields-20511

Summary by CodeRabbit

  • New Features

    • Introduced new filtering options for event lists based on the last N days for both start and update timestamps.
    • Added optional properties to enhance filtering configurations.
  • Bug Fixes

    • Improved filtering logic for existing functions to utilize a new helper function, enhancing modularity.
  • Documentation

    • Updated type definitions to include new optional properties for event filtering.

@albaranau albaranau requested a review from a team December 27, 2024 11:49
Copy link
Contributor

coderabbitai bot commented Dec 27, 2024

Walkthrough

The pull request introduces enhanced event filtering capabilities by adding two new functions, filterByLastNDaysUpdatedAt and filterByLastNDaysStartedAt, to the local event filtering system. These functions allow filtering events based on their update and start timestamps within a specified number of days. The changes include modifying the LocalEventListFilters type to support new optional filtering properties and refactoring the existing filtering logic to improve modularity and reusability.

Changes

File Change Summary
src/features/events_list/types.ts Added optional lastNDaysUpdatedAt and lastNDaysStartedAt properties to LocalEventListFilters type
src/features/events_list/helpers/localEventFilters.ts - Added filterByLastNDaysUpdatedAt and filterByLastNDaysStartedAt functions
- Introduced filterByMinTime and getNDaysBack utility functions
- Refactored existing filtering methods
src/features/events_list/atoms/sortedEventList.ts Updated local event filtering logic to incorporate new timestamp-based filters

Sequence Diagram

sequenceDiagram
    participant User
    participant EventList
    participant FilterHelpers
    participant Events

    User->>EventList: Apply filters
    EventList->>FilterHelpers: filterByLastNDaysUpdatedAt/StartedAt
    FilterHelpers->>FilterHelpers: Calculate min timestamp
    FilterHelpers->>Events: Filter events within time range
    FilterHelpers-->>EventList: Filtered events
    EventList-->>User: Display filtered events
Loading

Poem

🐰 Hopping through events, day by day,
Filtering timestamps in a clever way
Last N days, a new filtering delight
Rabbit's code makes everything just right!
Events sorted with precision and care 🕒

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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

Language To Recheck Fuzzy Untranslated Total
ar 3 24 101 128
de 2 24 101 127
es 3 24 101 128
id 2 24 101 127
ko 3 24 101 128
uk 0 7 8 15

Copy link

Bundle size diff

Old size New size Diff
5.14 MB 5.14 MB 378 B (0.01%)

Copy link

codecov bot commented Dec 27, 2024

Codecov Report

Attention: Patch coverage is 0% with 39 lines in your changes missing coverage. Please review.

Project coverage is 9.43%. Comparing base (34cd404) to head (8bee6e2).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../features/events_list/helpers/localEventFilters.ts 0.00% 34 Missing ⚠️
src/features/events_list/atoms/sortedEventList.ts 0.00% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main    #942      +/-   ##
========================================
- Coverage   9.44%   9.43%   -0.02%     
========================================
  Files        677     677              
  Lines      29388   29421      +33     
  Branches    1187    1187              
========================================
  Hits        2777    2777              
- Misses     26074   26107      +33     
  Partials     537     537              
Components Coverage Δ
UI Components 0.26% <ø> (ø)
Core Logic 15.78% <ø> (ø)
Features 1.13% <0.00%> (-0.01%) ⬇️
Utilities 45.64% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Preview environments for this PR:

These previews are automatically updated with each commit.

Note: After a new deployment, it may take a few minutes for the changes to propagate and for caches to update. During this time, you might experience temporary loading issues or see an older version of the app. If the app fails to load, please wait a few minutes and try again.

Copy link
Contributor

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 34cd404 and 8bee6e2.

📒 Files selected for processing (3)
  • src/features/events_list/atoms/sortedEventList.ts (2 hunks)
  • src/features/events_list/helpers/localEventFilters.ts (2 hunks)
  • src/features/events_list/types.ts (1 hunks)
🔇 Additional comments (10)
src/features/events_list/types.ts (1)

11-14: Confirm priority note for date filters.
The comments clearly indicate that minUpdatedAt and minStartedAt take precedence over their corresponding lastNDays* counterparts. This is logical and well-documented. Ensure the same behavior is consistently enforced in the application code, and consider adding test coverage to confirm the precedence logic.

src/features/events_list/helpers/localEventFilters.ts (5)

4-10: Consider edge cases for day calculations.
Your approach to filtering by last N days is clear; however, watch out for edge cases like days = 0 or negative values, and events that have an invalid or missing date. You might also consider how time zones could affect the comparison if your environment must handle multiple time zones.


12-18: Maintain consistent approach for startedAt filter.
This parallels the filterByLastNDaysUpdatedAt function effectively. Again, be mindful of invalid or missing date values.


23-23: Reuse of filterByMinTime is a solid improvement.
This refactoring increases clarity and reduces repetition. Good job!


31-31: Refactoring with filterByMinTime ensures DRY principle.
Consistent usage of filterByMinTime fosters cleaner and more maintainable code.


75-85: Null or invalid date handling.
filterByMinTime skips events that have invalid or absent date fields and excludes them from the results. This seems appropriate, but ensure that data consumers understand that such events are effectively filtered out.

src/features/events_list/atoms/sortedEventList.ts (4)

9-10: Imports effectively extend filtering capabilities.
The newly imported functions align with the added filter properties. This maintains a clear structure and usage.


61-61: Good practice to group date filters in a dedicated block.
Keeping related filters together enhances readability and discoverability of the code.


64-65: Conditionally apply last N days updatedAt filter.
This correctly respects the documented priority of minUpdatedAt over lastNDaysUpdatedAt.


69-70: Conditionally apply last N days startedAt filter.
Likewise, minStartedAt takes precedence over lastNDaysStartedAt. This is consistent with the intended filtering logic.

Copy link

codecov bot commented Dec 27, 2024

Bundle Report

Changes will increase total bundle size by 378 bytes (0.01%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
konturio/disaster-ninja-fe-esm 5.4MB 378 bytes (0.01%) ⬆️

@albaranau albaranau merged commit 0f20ac9 into main Dec 27, 2024
16 of 22 checks passed
@albaranau albaranau deleted the 20511-fe-last-n-days-filter-for-createdat-and-updatedat-fields branch December 27, 2024 12:24
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