Skip to content

Commit

Permalink
date operators on cohorts
Browse files Browse the repository at this point in the history
  • Loading branch information
aspicer committed Aug 5, 2024
1 parent 06df730 commit da8ab32
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
23 changes: 22 additions & 1 deletion frontend/src/scenes/cohorts/CohortFilters/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
FilterLogicalOperator,
PropertyMathType,
PropertyOperator,
SingleFieldDateType,
TimeUnitType,
ValueOptionType,
} from '~/types'
Expand Down Expand Up @@ -200,6 +201,21 @@ export const FIELD_VALUES: Record<FieldOptionsType, FieldValues> = {
},
},
},
[FieldOptionsType.SingleFieldDateOperators]: {
label: 'Date Operators',
type: FieldOptionsType.SingleFieldDateOperators,
values: {
[SingleFieldDateType.IsDateExact]: {
label: 'on the date',
},
[SingleFieldDateType.IsDateAfter]: {
label: 'since',
},
[SingleFieldDateType.IsDateBefore]: {
label: 'before',
},
},
},
[FieldOptionsType.MathOperators]: {
label: 'Operators',
type: FieldOptionsType.MathOperators,
Expand Down Expand Up @@ -861,7 +877,12 @@ export const renderField: Record<FilterType, (props: CohortFieldProps) => JSX.El
return <CohortSelectorField {...p} fieldOptionGroupTypes={[FieldOptionsType.DateOperators]} />
},
[FilterType.MathOperator]: function _renderField(p) {
return <CohortSelectorField {...p} fieldOptionGroupTypes={[FieldOptionsType.MathOperators]} />
return (
<CohortSelectorField
{...p}
fieldOptionGroupTypes={[FieldOptionsType.MathOperators, FieldOptionsType.SingleFieldDateOperators]}
/>
)
},
[FilterType.EventsAndActionsMathOperator]: function _renderField(p) {
return <CohortSelectorField {...p} fieldOptionGroupTypes={[FieldOptionsType.EventsAndActionsMathOperators]} />
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/cohorts/CohortFilters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export enum FieldOptionsType {
LifecycleBehavioral = 'lifecycleBehavioral',
TimeUnits = 'timeUnits',
DateOperators = 'dateOperators',
SingleFieldDateOperators = 'singleFieldDateOperators',
MathOperators = 'mathOperators',
ValueOptions = 'valueOptions',
EventsAndActionsMathOperators = 'eventsAndActionsMathOperators',
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3500,6 +3500,12 @@ export enum DateOperatorType {
IsNotSet = 'is_not_set',
}

export enum SingleFieldDateType {
IsDateExact = 'is_date_exact',
IsDateBefore = 'is_date_before',
IsDateAfter = 'is_date_after',
}

export enum ValueOptionType {
MostRecent = 'most_recent',
Previous = 'previous',
Expand Down

0 comments on commit da8ab32

Please sign in to comment.