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(flags): Add relative date operators #18349

Merged
merged 5 commits into from
Nov 8, 2023
Merged

Conversation

neilkakkar
Copy link
Contributor

@neilkakkar neilkakkar commented Nov 2, 2023

Problem

fixes #17392 - part 1. UI to follow after SDK updates.

Add relative date operators, which allow you to query date/datetime properties with operators like "24h" for within last 24 hours, and "3d" for within last 3 days for example.

Also supports relative date before & after, i.e. within or outside the relative range.

The parsing is similar to what we do for insights, to keep things closely related, but not reusing the same because it has a lot more logic around team timezones and other stuff we don't need. Also less risky to keep it separate, as we wouldn't want updates there to break flags, or vice versa, since these end up going to separate systems: Flags go to postgres, insights go to clickhouse.

Changes

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

How did you test this code?

Need to update tests, resolve TODOs

@neilkakkar neilkakkar marked this pull request as ready for review November 3, 2023 15:25
parsed_dt = datetime.datetime.now(tz=ZoneInfo("UTC"))
if match:
number = int(match.group("number"))
type = match.group("type")
Copy link
Contributor

Choose a reason for hiding this comment

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

This will overshadow the built-in type() function, maybe consider a different name?

@neilkakkar neilkakkar enabled auto-merge (squash) November 8, 2023 10:55
@neilkakkar neilkakkar merged commit 0f2f82a into master Nov 8, 2023
64 checks passed
@neilkakkar neilkakkar deleted the relative-date-flags branch November 8, 2023 11:05
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.

Relative date targeting for feature flags / surveys
3 participants