refactor: centralize DateFilter utility for upcoming/past logic#138
Merged
refactor: centralize DateFilter utility for upcoming/past logic#138
Conversation
Extracts the duplicated 'upcoming = start >= now OR end >= now' and 'past = start < now AND (end < now OR no end)' logic into a single DateFilter class with two output formats: - meta_query(): WP_Query arrays for EventQueryBuilder - sql(): raw SQL joins + WHERE for Taxonomy_Helper and external consumers EventQueryBuilder and Taxonomy_Helper now delegate to DateFilter instead of each maintaining their own copy of the condition logic.
Contributor
Homeboy Results —
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extracts the duplicated upcoming/past condition logic into a single
DateFilterutility class with two output formats:meta_query()— WP_Query arrays (used by EventQueryBuilder)sql()— raw SQL joins + WHERE fragments (used by Taxonomy_Helper, calendar-stats, PageBoundary)Before: the definition of "upcoming" was copy-pasted in 4 places across 2 repos. Changing it required updating all of them (which is exactly the bug that caused the wrong counts).
After: one class, one definition. Change it once, every consumer gets the update.