Skip to content

chore: remove redundant calls to format already formatted Datetime strings#11121

Open
Bigpet wants to merge 1 commit intoopensearch-project:mainfrom
Bigpet:feauture/fix_timezone_dependant_test
Open

chore: remove redundant calls to format already formatted Datetime strings#11121
Bigpet wants to merge 1 commit intoopensearch-project:mainfrom
Bigpet:feauture/fix_timezone_dependant_test

Conversation

@Bigpet
Copy link

@Bigpet Bigpet commented Jan 3, 2026

Description

Remove redundant calls to format already formatted Datetime strings
The tests for the now unused removed function also used to fail unless the timezone was set to UTC.
So there's some test flakiness that was reduced.

Issues Resolved

timezone sensitive tests removed

Screenshot

no visible change

Testing the changes

no functional change.
Tests all pass and if manual testing was done with the PPL query builder.

Changelog

  • skip

Check List

  • All tests pass
    • yarn test:jest (with the exception of calls reportOptInStatus if reportOptInStatusChange is true, but that failed on my machine before the changes as well)
    • yarn test:jest_integration
  • [ ] New functionality includes testing. no new functionatity
  • [ ] New functionality has been documented. no new functionatity
  • [ ] Update CHANGELOG.md no new functionatity
  • Commits are signed per the DCO using --signoff

Summary by CodeRabbit

  • Refactor
    • Optimized internal date handling in the query enhancement plugin by streamlining utility functions and removing unused code dependencies for improved code maintainability.

✏️ Tip: You can customize this high-level summary in your review settings.

The tests for the now unused removed function also used to fail unless the
timezone was set to UTC.

Signed-off-by: Peter Tissen <dravorek@gmail.com>
@github-actions github-actions bot added first-time-contributor Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry labels Jan 3, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 3, 2026

📝 Walkthrough

Walkthrough

This PR removes the unused formatDate utility function from the common utilities module, eliminates its related tests, and updates the time filter logic to use raw date values directly without formatting.

Changes

Cohort / File(s) Summary
Test cleanup
src/plugins/query_enhancements/common/utils.test.ts
Removed formatDate-related test cases and import statement; only isPPLSearchQuery and throwFacetError imports remain.
Utility removal
src/plugins/query_enhancements/common/utils.ts
Removed exported formatDate(dateString: string): string function; other exports (getFields, etc.) unchanged.
Filter logic simplification
src/plugins/query_enhancements/public/search/filters/filter_utils.ts
Removed formatDate import; updated getTimeFilterWhereClause to use raw fromDate and toDate values directly in WHERE clause construction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops through code so clean,
Removing functions unforeseen,
No formatDate shall clutter here,
Just raw dates bright and crystal clear,
With timestamps dancing, code's now lean! 🐰✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing redundant formatDate calls from datetime-handling code.
Description check ✅ Passed The description covers all key sections with sufficient detail: explains the change, notes test flakiness reduction, confirms tests pass, and marks changelog as skip for this chore.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d053e90 and fd85792.

📒 Files selected for processing (3)
  • src/plugins/query_enhancements/common/utils.test.ts
  • src/plugins/query_enhancements/common/utils.ts
  • src/plugins/query_enhancements/public/search/filters/filter_utils.ts
💤 Files with no reviewable changes (1)
  • src/plugins/query_enhancements/common/utils.ts
🔇 Additional comments (2)
src/plugins/query_enhancements/common/utils.test.ts (1)

6-6: LGTM! Import correctly updated to reflect removed utility.

The import statement properly removes formatDate while retaining the other utilities. This aligns with the removal of the formatDate function and its associated tests.

src/plugins/query_enhancements/public/search/filters/filter_utils.ts (1)

24-25: LGTM! Simplified logic correctly uses pre-formatted date strings.

The change eliminates the redundant formatting by using the already-formatted fromDate and toDate values directly from formatTimePickerDate. Verification confirms formatDate has been completely removed from the codebase, and the WHERE clause construction is correct for PPL queries.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time-contributor Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants