Skip to content

refactor: centralize DateFilter utility for upcoming/past logic#138

Merged
chubes4 merged 1 commit intomainfrom
refactor/date-filter-utility
Mar 21, 2026
Merged

refactor: centralize DateFilter utility for upcoming/past logic#138
chubes4 merged 1 commit intomainfrom
refactor/date-filter-utility

Conversation

@chubes4
Copy link
Member

@chubes4 chubes4 commented Mar 21, 2026

Summary

Extracts the duplicated upcoming/past condition logic into a single DateFilter utility 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.

             ┌──────────────┐
             │  DateFilter   │
             │               │
             │ upcoming_meta_query()
             │ upcoming_sql()
             │ past_meta_query()
             │ past_sql()
             └───────┬───────┘
        ┌────────────┼────────────┐
        │            │            │
EventQueryBuilder  Taxonomy   calendar-stats
                   Helper     (extrachill-events)

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.
@chubes4 chubes4 merged commit 7c99dd9 into main Mar 21, 2026
1 check failed
@homeboy-ci
Copy link
Contributor

homeboy-ci bot commented Mar 21, 2026

Homeboy Results — data-machine-events

Homeboy

Failure Digest

Lint Failure Digest

Test Failure Digest

Audit Failure Digest

Autofixability classification

  • Overall: auto_fixable
  • Autofix enabled: yes
  • Autofix attempted this run: no
  • Auto-fixable failed commands:
    • lint
    • test
  • Failed commands with available automated fixes:
    • lint
    • test

Machine-readable artifacts

  • homeboy-lint-summary.json
  • homeboy-test-failures.json
  • homeboy-audit-summary.json
  • homeboy-autofixability.json

⚡ Scope: changed files only

audit (changed files only)

  • Drift increased: no

lint (changed files only)

test (changed files only)

Tooling versions
  • Homeboy CLI: homeboy 0.85.1+be7e22b
  • Extension: wordpress from https://github.com/Extra-Chill/homeboy-extensions
  • Extension revision: unknown
  • Action: Extra-Chill/homeboy-action@v2

Homeboy Action v1

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